-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_channel.m
More file actions
163 lines (122 loc) · 7.71 KB
/
Copy pathplot_channel.m
File metadata and controls
163 lines (122 loc) · 7.71 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
function [length_list, foci_list, birth_list, division_list, cell_list, cell_names, save_name, save_name_png, display_name] = plot_channel(dir_name, cell_data, px_to_mu, IW_thr, fnames_sort, channels, channle_idx, xlim_max, ylim_max, time_int)
parameters % load parameters
fov_index = find(fnames_sort(:,1) == channels(channle_idx,1));
fnames_fov = fnames_sort(fov_index,:);
channel_index = find(fnames_fov(:,2) == channels(channle_idx,2));
fnames_channel = fnames_fov(channel_index,:); % cell numeric identifiers
L_channles = length(fnames_channel(:,1));
foci_list = [0.0 0.0];
birth_list = 0.0;
division_list = 0.0;
cell_list = [];
cell_names = [];
length_list = [];
l_1 = 1;
i_1 = 1;
j_1 = 1;
k_1 = 1;
c_1 = 1;
cmap = colormap(gray);
% cmap = colormap(summer);
for k = 1:L_channles
fname_rec = ['f' num2str(fnames_channel(k,1),'%.2d') 'p' num2str(fnames_channel(k,2),'%.4d') 't' num2str(fnames_channel(k,3),'%.4d') 'r' num2str(fnames_channel(k,4),'%.2d')];
cell_temp = cell_data.(fname_rec);
time_temp = double(cell_temp.times); % stitch time point array of all generations into one WITHOUT division time point
birth_time_temp = double(cell_temp.birth_time); %birth time of all generations
divition_time_temp = double(cell_temp.division_time); %division time of all generations
length_temp = double(px_to_mu*cell_temp.lengths); % stitch length array of all generations into one WITHOUT division time point
width_temp = double(px_to_mu*cell_temp.widths); % stitch width array of all generations into one WITHOUT division time point
length_list = [length_list [time_temp; length_temp]];
birth_list(k_1,1) = birth_time_temp;
k_1 = k_1+1;
cell_list.(fname_rec) = cell_temp; %save all cells into handles' list.
cell_names{c_1,1} = fname_rec; %save all cells names into handles' list.
c_1 = c_1+1;
% deal with situation where the foci disp_l is interpreted as a
% numeric array/matrix as opposed to a 1d cell array of arrays
if ~double(iscell(cell_temp.disp_l))
cell_temp.disp_l = num2cell(cell_temp.disp_l, 2)' ;
cell_temp.disp_w = num2cell(cell_temp.disp_w, 2)' ;
cell_temp.foci_h = num2cell(cell_temp.foci_h, 2)' ;
end
% convert disp_l into microns
for n = 1:length(cell_temp.disp_l)
cell_temp.disp_l{1,n} = cell_temp.disp_l{1,n} * px_to_mu ;
cell_temp.disp_w{1,n} = cell_temp.disp_w{1,n} * px_to_mu ;
end
%-----------------plots-------------------
% foci position vs time
hold on;
h1 = plot(time_temp,length_temp);
h1.Color = [0.75 0.75 0.75]; set(h1,'LineWidth',2,'Markersize',2,'Marker','o','MarkerFaceColor',[0.75 0.75 0.75],'LineStyle','-');
%obtain foci positions
for p=1:length(cell_temp.times)
% check if there are foci at this time point
% plot fl profile line
if plot_fl_profile
if sum(cell_temp.fl_profiles_sub_c2{1,p})
colormap(summer);
x_positions = ones(1, length(cell_temp.fl_profiles_sub_c2{1,p})) * double(cell_temp.times(1,p));
y_positions = linspace(0, length_temp(1,p), length(cell_temp.fl_profiles_sub_c2{1,p}));
z_positions = cell_temp.fl_profiles_sub_c2{1,p};
h_flprofile = scatter(x_positions, y_positions, fl_profile_ms, z_positions, ...
'filled', 'square');
% h_flprofile.Color = colormap(summer);
h_flprofile.MarkerFaceAlpha = 0.25;
set(h_flprofile,'HitTest','off'); % these objects will not trigger GUI mouse click
end
end
if isempty(cell_temp.disp_l{1,p})==0
% plot eeach foci individually
for q=1:length(cell_temp.disp_l{1,p})
color_idx_temp = (cell_temp.disp_w{1,p}(1,q)+width_temp(1,p)/2)/width_temp(1,p);
color_idx_temp = max(0,color_idx_temp);
color_idx_temp = min(1,color_idx_temp);
color_temp = cmap(4+round(56*color_idx_temp),:); %visualize information of displacment along width direction using colormap
if cell_temp.foci_h{1,p}(1,q)>=IW_thr
h3 = plot(cell_temp.times(1,p),cell_temp.disp_l{1,p}(1,q)-0.05+length_temp(1,p)/2);
h3.Color = color_temp; set(h3,'LineWidth',1,'Markersize',4*(cell_temp.foci_h{1,p}(1,q)/IW_thr),'Marker','o','MarkerFaceColor',[1 1 1],'LineStyle','None');
set(h3,'HitTest','off'); % these objects will not trigger GUI mouse click
foci_list(i_1,:) = [double(cell_temp.times(1,p)), cell_temp.disp_l{1,p}(1,q)-0.05+length_temp(1,p)/2];
i_1 = i_1+1;
h4 = plot(cell_temp.times(1,p),cell_temp.disp_l{1,p}(1,q)+0.05+length_temp(1,p)/2);
h4.Color = color_temp; set(h4,'LineWidth',1,'Markersize',4*(cell_temp.foci_h{1,p}(1,q)/IW_thr),'Marker','o','MarkerFaceColor',[1 1 1],'LineStyle','None');
set(h4,'HitTest','off'); % these objects will not trigger GUI mouse click
foci_list(i_1,:) = [double(cell_temp.times(1,p)), cell_temp.disp_l{1,p}(1,q)+0.05+length_temp(1,p)/2];
i_1 = i_1+1;
else
h3 = plot(cell_temp.times(1,p), cell_temp.disp_l{1,p}(1,q)+length_temp(1,p)/2);
h3.Color = color_temp; set(h3,'LineWidth',1,'Markersize',(4*(2*cell_temp.foci_h{1,p}(1,q)/IW_thr))^1.5,'Marker','o','MarkerFaceColor',[1 1 1],'LineStyle','None');
set(h3,'HitTest','off'); % these objects will not trigger GUI mouse click
foci_list(i_1,:) = [double(cell_temp.times(1,p)), cell_temp.disp_l{1,p}(1,q)+length_temp(1,p)/2];
i_1 = i_1+1;
end
end
end
end
% Plot a line at the division times
b3 = plot(divition_time_temp*ones(1,2),[-10 10]);
b3.Color = [0 0 0]; set(b3,'LineWidth',0.5,'Markersize',2,'Marker','None','MarkerFaceColor',[1 1 1],'LineStyle','--');
division_list(j_1,1) = divition_time_temp;
j_1 = j_1+1;
end
b4 = plot([0 xlim_maximum],[0 0]);
b4.Color = [0 0 0]; set(b4,'LineWidth',0.5,'Markersize',2,'Marker','None','MarkerFaceColor',[1 1 1],'LineStyle','--');
txt_tmp = sprintf('frame index (%d min/frame)',time_int);
xlabel(txt_tmp,'fontsize',10);
xlim([xlim_minimum xlim_maximum])
% set(gca,'XScale','linear','XTick',[0 30 60 90 120 150 180 210 240 270 300 330 360],'XTickLabel', ...
% {'0','30','60','90','120','150','180','210','240','270','300','330','360'})
%
% set(gca,'XScale','linear','XTick',[200 230 260 290 320 350 380 410 440 470 500 530 3560],'XTickLabel', ...
% {'200','230','260','290','320','350','380','410','440','470','500','530','560'})
set(gca,'XScale','linear','XTick',[40 70 100 130 160 200 230 260 290 320 350 380 410 440 470 500 530],'XTickLabel', ...
{'40', '70', '100','130','160','200','230','260','290','320','350','380','410','440','470','500','530'})
ylabel('foci position ({\mu}m)','fontsize',10)
ylim([-1 ylim_max])
set(gca,'YScale','linear','YTick',[0 1 2 3 4 5 6 7 8],'YTickLabel',{'0','1','2','3','4','5','6','7','8'},'YGrid','Off');
set(gca,'TickLength',[0.005 0.01],'fontsize',12,'TickDir','out','PlotBoxAspectRatio',[2 1 1]);
save_name = [dir_name 'picked/' 'f' num2str(fnames_channel(k,1),'%.2d') 'p' num2str(fnames_channel(k,2),'%.4d')];
save_name_png = [dir_name 'picked_png/' 'f' num2str(fnames_channel(k,1),'%.2d') 'p' num2str(fnames_channel(k,2),'%.4d')];
display_name = ['FOV: ' num2str(fnames_channel(1,1),'%.2d') '; Channel: ' num2str(fnames_channel(1,2),'%.4d')];
end