-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplayRF.m
81 lines (71 loc) · 2.41 KB
/
displayRF.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function displayRF(rf, fperiod, blocksize)
%
% future function?
% ROI-averaged STA:
% roi = ellipseMask(mean_img);
% totRoi_1D_array = reshape(totRoi,[],1); % as 1-D
% totRoi_Spectrum = RawImgReshaped(totRoi_1D_array,:).';
if nargin < 3 || isempty(blocksize)
blocksize = 50; %um
elseif nargin < 2 || isempty(fperiod)
fperiod = 0.03322955;
elseif nargin < 1 || isempty(rf)
disp('RF should be given');
return;
end
Xstim = 1; Ystim = 1;
% stim size & reshape [ch, frames]
Dim = ndims(rf);
if Dim >3
disp('[fn: displayRF] rf is dim>3 array. It should be dim 1~3 data');
return;
elseif Dim ==3
[Xstim, Ystim, N] = size(rf);
elseif Dim == 2
[Ystim, N] = size(rf);
elseif Dim == 1
N = length(rf);
end
t_label = 0:fperiod:fperiod*(N-1);
t_label = -fliplr(t_label);
if (Xstim == 1) || (Ystim == 1)
rf = reshape(rf, Xstim*Ystim, []);
[~, ind] = max(rf(:));
[iy_max, if_max] = ind2sub(size(rf), ind);
[~, ind] = min(rf(:));
[iy_min, if_min] = ind2sub(size(rf), ind);
figure('position', [900, 400, 420, 900]);
subplot(1,3,1); imagesc(rf); colorbar;
subplot(1,3,2); plot( vec(rf(iy_max,:)) );
subplot(1,3,3); plot( vec(rf(iy_min,:)) );
return;
else
[~, ind] = max(rf(:));
[ix_max, iy_max, if_max] = ind2sub(size(rf), ind);
[~, ind] = min(rf(:));
[ix_min, iy_min, if_min] = ind2sub(size(rf), ind);
figure('position', [550, 550, 940, 200]);
subplot(1,3,1); imagesc(rf(:,:,if_max)); axis off;
colorbar; axis equal tight;
xlabel(['t = ', num2str(t_label(if_max)*1000,'%.0f'),' ms']);
subplot(1,3,2); imagesc(rf(:,:,if_min)); axis off;
colorbar; axis equal tight;
xlabel(['t = ', num2str(t_label(if_min)*1000,'%.0f'),' ms']);
%temporal profile
rf1D = reshape(rf, Xstim*Ystim, []);
t_rf = sum(rf1D, 1);
subplot(1,3,3);
%plot( vec(rf(ix_min,iy_min,:)) );
plot(t_label, t_rf, 'LineWidth', 1.6);
xlabel('time [s]','FontSize',16);
ylabel('STA','FontSize',16);
xlim([t_label(1), 0]);
ax = gca;
ax.XGrid = 'on';
ax.XTick = -fliplr(0:0.1:0.5);
ax.YTick = [];
ax.YTickLabel = {};
end
%bc;
end
% implay