-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDFFcellPlot.m
More file actions
80 lines (53 loc) · 1.64 KB
/
DFFcellPlot.m
File metadata and controls
80 lines (53 loc) · 1.64 KB
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
CellSignal = zeros(size(mean_cell,1)*size(mean_cell,2), size(mean_cell{1,1},1));
k = 1;
for i = 1:size(mean_cell,1)
for j = 1:size(mean_cell,2)
CellSignal(k, :) = mean_cell{i,j}';
k = k+1;
end
end
%
signalmat = CellSignal';
Ntimes=size(signalmat,1);
dt=0.49;
window=fix(30/dt); % baseline is calculated for a window of 30s)
order=fix(0.08*window);
background = 0;
baseline=ordfilt2(signalmat, order, (1:window)')-background;
baselinesm=filter(ones(1,window)/window,1,baseline);
t1=min(fix(1.5*window), size(baselinesm,1)-1);
ai=baselinesm(t1,:);
bi=repmat(ai,t1,1);
baselinesm(1:t1,:)=bi;
af=baselinesm(Ntimes-t1,:);
bf=repmat(af,t1,1);
baselinesm((Ntimes-t1+1):Ntimes,:)=bf;
DFF=(signalmat-baselinesm-background)./baselinesm;
DFF = D.DFF;
DFF(DFF==Inf)=0;
DFF(isnan(DFF)) = 0 ;
DFFdisp=DFF;
DFFdisp(find(DFF<0.02))=0;
figure, imshow(DFFdisp', []);
DFFcomplement = imcomplement(DFFdisp');
figure, imshow(DFFcomplement, []);
DFFdisp1 = DFFdisp;
% plot 1
shock = 125:125:525;
figure, hold on;
image(256*rescalegd(transpose(DFFdisp1))); % good plot, scaled with 1% and 99% range
% vline(shock, 'r');
hold off;
% plot 2
shock = 125:125:525;
figure, hold on;
image(scaledata(transpose(DFFdisp1), 0, 1024)); % good plot
vline(shock, 'r');
hold off;
% plot trace
for i = 1:335
% i = 294;
figure, hold on;
plot(DFFdisp(:,i)); vline(shock, 'r');
hold off;
end