-
Notifications
You must be signed in to change notification settings - Fork 1
/
ISI_plotAllFrames.m
executable file
·100 lines (81 loc) · 2.88 KB
/
ISI_plotAllFrames.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
function h = ISI_plotAllFrames(ISIdata, clim, prmts, cmap)
% h = ISI_plotAllFrames(ISIdata, clim, colormap)
% Plot grid array of frames over time with timestamps.
%
% Modified by Per M Knutsen , Feb 02 2012
%
h = figure;
set(h, 'color', 'k')
colormap(cmap);
% 1st derivative (change in pixel values over time)
nDer = 0;
if nDer > 0
mFrames = diff(ISIdata.deltaSignal, nDer, 3);
else
mFrames = ISIdata.deltaSignal;
end
totalNframes = ISIdata.nFramesPerTrial - nDer;
maxrow = 5;
nrow = maxrow;
ncol = double(ceil(totalNframes/maxrow));
if ncol <= maxrow - 2 % narrow number of cols, try recalculating
nrow = maxrow - 1;
ncol = ceil(totalNframes/nrow);
end
nframes = 1;
nrow = floor(sqrt(double(totalNframes))) - 2;
ncol = round(double(totalNframes) / nrow);
if ~isnan(prmts.smoothSigma) && prmts.smoothSigma > 0
mWin = fspecial('gaussian', prmts.smoothSigma*3, prmts.smoothSigma);
else
mWin = NaN;
end
for j = 1:nrow
for i = 1:ncol
if nframes > totalNframes
break;
end
f = (j-1)*ncol+i;
% Generate axes
axes('position', [(i*(1/ncol))-(1/ncol) 1-(j*(1/nrow)) 1/ncol 1/nrow]) % modified Per Jan 10th 2012
frame = mFrames(:,:,f); %ISIdata.deltaSignal(:,:,f);
if ~isempty(frame)
% median filter
if isfield(prmts, 'medFilter')
frame = medfilt2(frame, prmts.medFilter);
end
% Smooth frame
if ~isnan(mWin)
frame = single(filter2(mWin, frame, 'same'));
end
% Mask frame
if prmts.useManualMask
tMask = prmts.manualMask;
if ~isempty(tMask)
frame(~tMask.mROI) = NaN;
end
end
% Display frame
imagesc(frame);
axis image; axis off;
if ~isempty(clim)
set(gca,'clim', clim);
end
end
% Set timestamp
nT = (f+(ISIdata.frame_rate/ISIdata.bin_duration)-1+nDer) ...
/ (ISIdata.frame_rate/ISIdata.bin_duration) ...
- (ISIdata.nPreStimFrames/(ISIdata.frame_rate/ISIdata.bin_duration)) ...
- 1;
%vTime = (((ISIdata.frame_rate/ISIdata.bin_duration):f+((ISIdata.frame_rate/ISIdata.bin_duration)-1)) ...
% / (ISIdata.frame_rate/ISIdata.bin_duration)) ...
% - (ISIdata.nPreStimFrames / (ISIdata.frame_rate/ISIdata.bin_duration)) ...
% - 1;
hTxt = text(15, 30, [num2str(nT) ' s'], ...
'color', 'w', 'backgroundcolor', 'k'); % modified Per Jan 10th 2012
set(hTxt, 'fontsize', 7)
nframes=nframes+1;
end
end
set(h, 'position',[20 50 1200 670], 'color', 'k');
return