/
at_noise_simple.m
executable file
·173 lines (119 loc) · 3.97 KB
/
at_noise_simple.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
function at_noise_simple(index,leg)
global datastat
% plot 1) typical temporal trace for the longest lived cell
% 2) noise spectrum
% 3) noise integrated over high frequencies + fraction of outliers
h=figure;
width=600;
height=600;
set(h,'Color','w','Position',[100 100 width height]);
set(gca,'FontSize',20);
col={'r','b','g','m','c','y','k','r','b','g','m','c','y','k'};
cc=1;
for i=index
stats=datastat(i).stats;
% plot temporal trace
% p(1).select();
% longtrace=find(stats(:,4)==3);
% id=stats(longtrace,3);
%
% longtrace=longtrace(longtrace>3);
%
% longtrace2=find(stats(longtrace-1,4)==2 & stats(longtrace-2,4)==1 & stats(longtrace-2,3)==stats(longtrace,3) & stats(longtrace-2,3)==stats(longtrace,3),1,'first');
%
% if numel(longtrace2)==0
% warndlg('There is no cell in you experiment with at least 3 consecutive divisions : crappy data ???');
% end
%
% longtrace=longtrace(longtrace2);
%
%
%
% for j=longtrace-2:longtrace
% fluo=at_name('fluo');
% htb2=stats(j,fluo);
% htb2=htb2(find(htb2~=0));
% x=1:1:length(htb2); x=x+stats(j,7)+stats(j,8);
% plot(x/20,htb2,'Color',col{cc}); hold on
% end
outliers=stats(:,6)~=0;
cellsok=stats(~outliers,:);
outliers=stats(outliers,:);
frac(cc)=100*double(size(outliers,1))/(double(size(cellsok,1))+double(size(outliers,1)));
mothers=find(cellsok(:,5)==1);
div(cc)= 3*mean(cellsok(mothers,10));
fluo=at_name('fluo');
ftot=[];
ytot=[];
mtot=[];
ftotout=[];
ytotout=[];
mtotout=[];
for j=1:length(stats(:,1))
htb2=stats(j,fluo);
htb2=htb2(htb2~=0);
htb2=(htb2-min(htb2))/(max(htb2)-min(htb2)); % normalization
t=linspace(0,2*pi,length(htb2));
htb2=htb2.*(1-cos(t)); % apodization
[f,y]=computeSpectrum(htb2);
if stats(j,6)==0
ftot=[ftot f];
ytot=[ytot y];
mtot=[mtot mean(htb2)];
else
ftotout=[ftotout f];
ytotout=[ytotout y];
mtotout=[mtotout mean(htb2)];
end
end
[fmean, ampmean, ftot, ytot]=averagespectrum(ftot,ytot,mtot);
% [fmeanout, ampmeanout, ftotout, ytotout]=averagespectrum(ftotout,ytotout,mtotout);
if cc~=1
%axes(h)
end
%p(2).select();
loglog(fmean,ampmean,'Marker','o','MarkerSize',6,'Color',col{cc},'LineWidth',2); %,'LineStyle','none'); hold on
hold on;
set(gca,'XScale','log'); set(gca,'YScale','log');
% loglog(fmeanout,ampmeanout,'Marker','x','MarkerSize',6,'Color',col{cc},'LineStyle','none'); hold on
fsel=fmean(end-3:end);
ampsel=ampmean(end-3:end);
inte(cc)=trapz(fsel,ampsel);
str{cc}=leg{cc};
str2{3*cc-2}=leg{cc};
str2{3*cc-1}=leg{cc};
str2{3*cc}=leg{cc};
%str{2*i}='';
% pause
cc=cc+1;
end
%p(1).select();
%ylabel('HTB2-GFP fluo (A.U.)'); xlabel('Time (hours)');
%legend(str2);
%p(1).select();
ylabel('Spectrum (A.U.)'); xlabel('Frequency (hours^{-1})');
legend(str);
function [fmean, ampmean, ftot, ytot]=averagespectrum(ftot,ytot,mtot)
[ftot,ix]=sort(ftot);
ytot=ytot(ix)/mean(mtot);
fmean=[];
ampmean=[];
%scale=-1:0.05:1;
%bin=10.^scale
bin=logspace(-1,1,20);
for k=1:length(bin)-1
pix=ftot>bin(k) & ftot<bin(k+1);
% temp=idx==k;
fmean=[fmean mean(ftot(pix))];
ampmean=[ampmean mean(ytot(pix))];
end
function [f amp]=computeSpectrum(htb2)
Fs = 20; % Sampling frequency in hours-1
T = 1/Fs; % Sample time
L = length(htb2)*T; % Duratio of signal in seconds
%Npoints=round(L/T);
t = 0:T:(L-T); % Time vector
NFFT = 2^nextpow2(length(t)); % Next power of 2 from length of y
Y = fft(htb2,NFFT)/length(t);
f = Fs/2*linspace(0,1,NFFT/2+1);
amp=2*abs(Y(1:NFFT/2+1));