forked from mbussonn/analyse_response_function
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreanalyse_preprocessed_data_folder_3.m
More file actions
executable file
·114 lines (100 loc) · 4.4 KB
/
reanalyse_preprocessed_data_folder_3.m
File metadata and controls
executable file
·114 lines (100 loc) · 4.4 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
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
function reanalyse_preprocessed_data_folder_3(path)
%here we reprocess the response and the fluctuation data
%path='E:\Science\data\response_function\pre_analysed_data\healthy_cells'
path='E:\Science\data\response_function\pre_analysed_data\starved_new';
%path='E:\Science\data\response_function\pre_analysed_data\starved_and_depleted_old'
files=dir([path,'\*.mat']);
for i=1:length(files)
load([path,'\',files(i).name]);
for j=1:length(response)
p=response(j).path;
%[res,f]=process_response_data_from_raw_data(p)
f_fit=10;
[res,f,res_all_x,res_all_y,xy_k_extract,fbl,Pbl,k_fit]=process_response_data_plus_trap_calibration(p,f_fit);
% loglog(f,abs(real(res(:,1))));
% hold on
% loglog(f,imag(res(:,1)),'r');
% hold off
response(j).k_fit=k_fit; %#ok<*AGROW>
response(j).res_all_x=res_all_x;
response(j).res_all_y=res_all_y;
response(j).alphax=res(:,1);
response(j).alphay=res(:,2);
response(j).f=f;
response(j).xy_k_extract=xy_k_extract;
response(j).fbl=fbl;
response(j).Pbl=Pbl;
pause(0.1)
save([path,'\',files(i).name],'fluctuation','o_slope','override','response');
end
for j=1:length(fluctuation)
%allignment_frequency
fa=40;
if strcmp(path,'E:\Science\data\response_function\pre_analysed_data\starved_new')
fa=120;
end
d=fluctuation(j).data;
for k=1:length(response)
[~,i_min]=min(abs(fa-response(k).fbl(response(k).act_trap,:)));
c_corr_i(k)=response(k).Pbl(response(k).act_trap,i_min)*1e-12;
cf_corr_i(k)=response(k).fbl(response(k).act_trap,i_min);
end
at=response(k).act_trap;
c_corr=mean(c_corr_i);
cf_corr_i=mean(cf_corr_i);
ind=0;
for k=1:length(d)
ind=ind+1;
[~,i_min]=min(abs(fa-d(k).f));
f_out(ind,:)=d(k).f;
px(ind,:)=d(k).px;
slope(ind)=d(k).slopes(1);
px_corr(ind,:)=d(k).px*(c_corr/px(ind,i_min));
end
fm=mean(f_out);
pxm=mean(px);
clear f_out
clear px
hold off
loglog(fluctuation(j).f,fluctuation(j).psdxy(1,:),response(1).fbl(at,:)',response(1).Pbl(at,:)'*1e-12)
hold on
for i2=1:length(response)
loglog(response(i2).f,imag(response(i2).alphax)*4.1e-21./(response(i2).f'*pi),'r')
end
[~,i_min]=min(abs(fa-fluctuation(j).f));
fluctuation(j).psd_corrected=fluctuation(j).psdxy(1,:)*(c_corr/fluctuation(j).psdxy(1,i_min));
%now I combine the high frequency from the high laser power with
%the low frequency from the low laser power. The overlap frequency
%region will be 50-100 Hz
f_min=40;
f_max=80;
if strcmp(path,'E:\Science\data\response_function\pre_analysed_data\starved_new')
f_min=60;
f_max=200;
end
[~,i_min]=min(abs(f_max-fluctuation(j).f));
fluctuation(j).f_low=fluctuation(j).f(1:i_min);
fluctuation(j).psd_low=fluctuation(j).psd_corrected(1:i_min);
[~,i_min]=min(abs(f_min-response(1).fbl(at,:)));
fluctuation(j).f_high=response(1).fbl(at,i_min:end)';
fluctuation(j).psd_high=response(1).Pbl(at,i_min:end)'*1e-12;
hold off
%here I create a sorted psd anf frequency vector that will be used
%for the paper. This then extends the data to the high frequencies
%and it is justified by the fact that the high frequency data for
%strong and weak traps will overlap. This overlap was also used to
%adjust the low laser data for possible noise effects on the
%calibration
psd_int(1,:)=[fluctuation(j).f_low fluctuation(j).f_high'];
psd_int(2,:)=[fluctuation(j).psd_low fluctuation(j).psd_high'];
psd_out=(sortrows(psd_int',1))';
fluctuation(j).psd_final=psd_out;
loglog(fluctuation(j).f_low,fluctuation(j).psd_low,'+r')
hold on
loglog(fluctuation(j).f_high,fluctuation(j).psd_high,'+k')
pause(1)
end
save([path,'\',files(i).name],'fluctuation','o_slope','override','response');
clear response
clear psd_int;
end