Repository navigation
Expand file tree
/
Copy pathsingle_cell_smooth.m
More file actions
196 lines (177 loc) · 6.92 KB
/
Copy pathsingle_cell_smooth.m
File metadata and controls
196 lines (177 loc) · 6.92 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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
%% Plot two colors on the same figure
%% the age sort and death type selection are off
%%
clear all
load NAM_1000min_20160518;
red = [1,0,0];
green = [0,1,0];
% all_data = input('Please type in the data set you want to plot,e.g. ''WT_20151112'': ');%Get the name of data
% Flu = input('Please type in the fluorescence channel you want to plot, e.g. [1 2] :');%Get the fluorescence channel number
% Label = input('Please type in the label for the fluorescence channel, e.g. ''NYN'' :');
% DT = input('Please type in what death type you want to plot, eg.. 1 : ');
% eval(['load ' all_data ';']);%load data
% eval(['all_data =' all_data ';']);%Rename the data want to plot to all_data
all_data = nestedSortStruct(NAM_1000min_20160518,'age');%Sort the data according to their lifespan
% all_data = all_data([all_data.Death_type] == DT);%Plot only death 1 and death 2
all_data = all_data([all_data.Death_type] == 1);
%Flu = input('Please type in the fluorescence channel you want to plot, e.g. [1 2] :');%Get the fluorescence channel number
for i=1:length(all_data)
date = all_data(i).Date;
date = num2str(date);
if strcmp(date,'20160417')
interval=6;
else
interval=15;
end
%Get the max of axis
% max_x = zeros(1,length(all_data));%Create a empty array to store max of x axis of each cell
% max_y = zeros(2,length(all_data));%Create a empty array to store max of y axis of each cell
life_end = all_data(i).cycle(end);
%Get the start frame of cell lifespan
life_start = all_data(i).cycle(3);
%Get the frames of lifespan for index fluorescence
FLS = life_start:life_end;
curr_trace=all_data(i).traj_normalized((FLS),1,1);
xq=life_start:(1/interval):life_end;
curr_trace_i=interp1(FLS,curr_trace,xq,'Spline');
xq2=(life_start-1)*interval:(life_end-1)*interval;
FLS2 =(life_start-1)*interval:interval:(life_end-1)*interval;
r=600/length(curr_trace_i);
curr_trace_s = smooth(curr_trace_i,r,'rloess');
all_data_2(i).traj_i=curr_trace_i;
all_data_2(i).traj_s=curr_trace_s;
end
save('data_final_s2','all_data_2','all_data');
% x_max=max(max(length(all_data_2.traj_i)));
% y_max=max(max(all_data_2.traj_i));
%
% % Specify how many each want for each subplot: Image Per Subplot
% IPS = input('please specifiy how many subplot per figure: pick 4,9,16,25 or 36 ');
% % Get the column and/or row number of each subplot: Column And Row
% CNR = sqrt(IPS);
% % Get the number of subplot is need: Number of Subplot
% NOS = ceil(length(all_data)/IPS);
%
%
% figure;
% for j=1:79
% figure;
%
% figure;
% plot(FLS2,curr_trace,'k.','MarkerSize',10);
% hold on;
% plot(xq2,curr_trace_i,'b.','MarkerSize',5);
% hold on;
% plot(xq2,curr_trace_smooth,'r-','LineWidth',2);
%
% end
% % for i_xy = 1:length(all_data)
% max_x(i_xy) = all_data(i_xy).cycle(end)
% %;%Get the last lifespan of the cell
% max_y(1,i_xy) = max(all_data(i_xy).traj_normalized(all_data(i_xy).cycle(5):all_data(i_xy).cycle(end),:,Flu(1)));%Get the max flu during the current lifespan
% max_y(2,i_xy) = max(all_data(i_xy).traj_normalized(all_data(i_xy).cycle(5):all_data(i_xy).cycle(end),:,Flu(2)));
% end
% max_y1 = max(max_y(1,:));
% max_y2 = max(max_y(2,:));
% max_x = max(max_x);
%
% % Specify how many each want for each subplot: Image Per Subplot
% IPS = input('please specifiy how many subplot per figure: pick 4,9,16,25 or 36 ');
% % Get the column and/or row number of each subplot: Column And Row
% CNR = sqrt(IPS);
% % Get the number of subplot is need: Number of Subplot
% NOS = ceil(length(all_data)/IPS);
%
%
% % Initiating subplot
% % For each figure
% for FN = 1:NOS
% figure
% %Determin the cell index on the subplot
% if length(all_data) >= IPS*FN
% CI = 1:IPS;
% elseif length(all_data) < IPS*FN
% CI = 1:(length(all_data)-IPS*(FN-1));
% end
%
% for i_CI = CI
% subplot(CNR,CNR,i_CI);
% %Get the Current Cell Index
% CCI = (FN-1)*IPS + i_CI;
% %Get the end frame of cell lifespan
% life_end = all_data(CCI).cycle(end);
% %Get the start frame of cell lifespan
% life_start = all_data(CCI).cycle(3);
% %Get the frames of lifespan for index fluorescence
% FLS = life_start:life_end;
% %Get the cell cycle info
% cycles = all_data(CCI).cycle(3:end);
% %Remove the zeros
% cycles = cycles(cycles>0);
%
% %Extract the curr_traj info and smooth it within 6 window
% curr_trace_Flu = all_data(CCI).traj_normalized(FLS,:,Flu(1));
% curr_trace_End = all_data(CCI).traj_normalized(FLS,:,Flu(2));
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%% To convert the unit of x axis from frames to minius %%%%%%%
% date = all_data(CCI).Date;
% date = num2str(date);
% if strcmp(date,'20151112')
% FLS = 6*FLS;
% curr_trace_Flu = smooth(curr_trace_Flu,30);
% curr_trace_End = smooth(curr_trace_End,30);
% cycles2 = 6*cycles;
% else
% FLS = 15*FLS;
% curr_trace_Flu = smooth(curr_trace_Flu,12);
% curr_trace_End = smooth(curr_trace_End,12);
% cycles2 = 15*cycles;
% end
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% %Plot Fluorescence channel and the Nuclear marker Channel
% [hAx,hl1,hl2] = plotyy(FLS,curr_trace_Flu,FLS,curr_trace_End);
%
% box off
%
% %Set up the properties of 1st axis
% hAx(1).YLim = [0 3];
% hAx(1).YTickMode = 'auto';
% hAx(1).XLim = [0 6*max_x];%% use 6 min interval or 15 min interal depend on the data
% hl1.LineWidth = 1.5;
% hAx(1).YColor = 'blue';
% hl1.Color = 'blue';
% ylabel(hAx(1),Label);
%
%
% %Set up the properties of 2nd axis
% hAx(2).YLim = [0 3];
% hAx(2).YTickMode = 'auto';
% hAx(2).XLim = [0 6*max_x];
% hl2.LineWidth = 1.5;
% hAx(2).YColor = 'red';
% hl2.Color = 'red';
% ylabel(hAx(2),'Nhp6a-iRFP');
%
% xlabel(hAx(1),'Time (min)');
%
% cell_title = [num2str(all_data(CCI).age) ',',all_data(CCI).id, ',',num2str(all_data(CCI).Date),',','DT', num2str(all_data(CCI).Death_type)];
%
% title(cell_title);
%
% %Add the cell cycle line
% y1 = get(gca,'ylim');
% for k_y = cycles2
% line([k_y k_y],y1,'Color','k','LineStyle','--','LineWidth',1.5)
% end
% set(gca,'FontSize',12)
%
% end
%
% % % % % % % % [ax,h3]=suplabel('NTS1-pGPD-GFP' ,'t');
% % % % % % % % set(h3,'FontSize',20)
%
% end
%