Repository navigation
Expand file tree
/
Copy pathcycle_fold.m
More file actions
109 lines (89 loc) · 4.76 KB
/
Copy pathcycle_fold.m
File metadata and controls
109 lines (89 loc) · 4.76 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
% function cycle_fold normalize trajectory information based on either first few frames or first percentitle of lifespan
function cycle_fold
fluN = input('how many fluorescence on this experiment :');
%%%%%%%load data%%%%%%%
all_data = input('Please type in the data set you want to plot,e.g. ''WT_20151112'': ');%assin the data name to variable all_data
name_str = all_data;%duplicate the name of the variable, make it easier to process later
eval(['load ' all_data]);%load data
eval(['all_data =' all_data ';']);%Rename the data to all_data
%%%%%%Specify normalization base%%%%%%%%
DT = input('please identify the death type that used for baseline :');%indentify the death type
if ~isempty(DT)
all_data_filtered = all_data([all_data.Death_type] == DT);%filter the data by DT
else
all_data_filtered = all_data;
end
F_f = cell(1,fluN);
for i_Ff = 1:fluN
F_f{i_Ff} = zeros(length(all_data_filtered),1);
end
% % F1_f = zeros(length(all_data_filtered),1);%Get the first cycle mean of all cells and stored in a array
% %
% % NM = zeros(length(all_data_filtered),1);%Creat an empty array to hold all cells nuclear intensity of 1st cell cycle
for k_m = 1:length(all_data_filtered)
start_1st = all_data_filtered(k_m).cycle(3);%get the start point of 1st cycle, THIS MIGHT NEED FINE TUNE
end_1st = all_data_filtered(k_m).cycle(6);%get the end point of the 1st cycle
for ik = 1:fluN
F_f{ik}(k_m) = mean(all_data_filtered(k_m).traj(start_1st:end_1st,:,ik));
end
% F1_f(k_m) = mean(all_data_filtered(k_m).traj(start_1st:end_1st,:,1));%get the average fluorescence of the 1st cell cycle
% NM(k_m) = mean(all_data_filtered(k_m).traj(start_1st:end_1st,:,end));%get the nuclear marker intensity
end
Fm = zeros(1,fluN);
for ik = 1:fluN
% % Fm(ik) = mean(F_f{ik});
Fm(ik) = mean(F_f{ik}(~isnan(F_f{ik})));
% % F1_m = mean(F1_f);%get the normalization factor for fluorescence 1
% % NM_m = mean(NM);%get the normalization factor for nuclear marker
end
% % % F1_all = zeros(length(all_data),1);
% % % NM_all = zeros(length(all_data),1);
% % % for k_mm = 1:length(all_data)
% % % start_1st = all_data(k_mm).cycle(3);%get the start point of 1st cycle
% % % end_1st = all_data(k_mm).cycle(6);%get the end point of the 1st cycle
% % % F1_all(k_mm) = mean(all_data(k_mm).traj(start_1st:end_1st,:,1));%get the average fluorescence of the 1st cell cycle
% % % NM_all(k_mm) = mean(all_data(k_mm).traj(start_1st:end_1st,:,end));
% % % eval([name_str '(' num2str(k_mm) ').F1_all= F1_all(k_m);']);
% % % eval([name_str '(' num2str(k_mm) ').NM_all= NM_all(k_m);']);
% % % end
% normalize fluorescence of all cells with the cycle_m
for k_n = 1:length(all_data)
curr_traj = [all_data(k_n).traj];%Get the traj info of current cell
curr_traj_normalized = curr_traj;
for ik = 1:fluN
curr_traj_normalized(:,:,ik) = curr_traj(:,:,ik)/Fm(ik);%normalized the fluorescence
end
% % curr_traj_normalized(:,:,end) = curr_traj(:,:,end)/NM_m;%normalized the nuclear marker
eval([name_str '(' num2str(k_n) ').traj_normalized= curr_traj_normalized;']);%Assign a new filed traj_normalized to all_data
%%%%%Get the mean fluorescence of eath cell cycle
cycles = all_data(k_n).cycle(5:end);
curr_cycle = zeros(1,length(cycles)-1);%create a empty array that hold fluorescence of each cell cycle
for c_m = 1:length(curr_cycle)
%curr_traj_Dt(k_Dt) = curr_traj_normalized(k_Dt+1,1,1)-curr_traj_normalized(k_Dt,1,1);
curr_cycle(c_m) = mean(curr_traj_normalized(cycles(c_m):cycles(c_m+1),1,1));
end
eval([name_str '(' num2str(k_n) ').cycle_m= curr_cycle;']);
%%%%%Caculate the derivitive of each cell cycle
cycle_dt = zeros(1,length(curr_cycle)-1);
for k_dt = 1:length(cycle_dt)
cycle_dt(k_dt) = curr_cycle(k_dt+1) - curr_cycle(k_dt);
end
eval([name_str '(' num2str(k_n) ').traj_Dt = cycle_dt;']);
% % %
% % % %create a empty array that hold derivitive of fluorescence cell cycle
% % % %not normalized
% % % cycle_in = zeros(1,length(cycles)-1);
% % % %get the mean fluorescence of eath cell cycle
% % % for c_in = 1:length(cycle_in)
% % % %curr_traj_Dt(k_Dt) = curr_traj_normalized(k_Dt+1,1,1)-curr_traj_normalized(k_Dt,1,1);
% % % cycle_in(c_in) = mean(all_data(k_n).traj(cycles(c_in):cycles(c_in+1),1,1));
% % % end
% % %
% % % cycle_in_dt = zeros(1,length(cycle_in)-1);
% % % for c_in = 1:length(cycle_in_dt)
% % % cycle_in_dt(c_in) = cycle_in(c_in+1)-cycle_in(c_in);
% % % end
% % % eval([name_str '(' num2str(k_n) ').cycle_in= cycle_in_dt;']);
%eval([new_name_str '(' num2str(k) ').normalization=' normal_method '{' average_type '}';']);
end
save([name_str,'.mat'],name_str)%save the normalized trajectories