-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME_for_timelapseimageprocessing.m
More file actions
332 lines (271 loc) · 11.3 KB
/
README_for_timelapseimageprocessing.m
File metadata and controls
332 lines (271 loc) · 11.3 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
%% set parent directory
mdir = mfilename('fullpath');
[~,b] = regexp(mdir,'Tracking\w*/');
if isempty(b)
[~,b] = regexp(mdir,'Tracking\w*\');
end
parentdir = mdir(1:b);
exportdir = strcat(parentdir,'Export/');
cd(parentdir)
fullT = tic;
%% set experiments
dateArray = {'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain01_44bin_exp04',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain02_44bin_exp07',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain03_44bin_exp10',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain04_44bin_exp15',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain05_44bin_exp20',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain06_44bin_exp24',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain07_44bin_exp27'};
dateArray = {'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain03_44bin_focus_exp12',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain04_44bin_focus_exp16',...
'2018_08_26 plate c2c12 116 movie_immuno_4i immunoREST_Stain05_44bin_focus_exp21'};
dateArray = {'2018_10_02 plate c2c12 116 magicRed rapamycin sapanisertib exp1'};
dateArray = {'2018_10_04 plate nmumg piggybac clones tgf long sub_clone240only exp2'};
dateArray = {'2018_10_13 plate c2c12 116 ampk activator rapamycin tgfbeta exp1'}
dateArray = {'2018_10_22 plate nmmg 235 5LH sort screen exp2'};
dateArray = {'2018_10_24 plate nmmg 235 5LH sort screen MOVIE exp2'}
dateArray = {'2018_10_30 plate c2c12 86 DALgreen autophagy fed starved rapamycin chloroquine exp1'}
dateArray = {'2018_10_30 plate c2c12 116 DALgreen rapamycin chloroquine tgfbeta movie exp1'};
dateArray = {'2018_11_01 plate c2c12 116 bix retinoic acid tgfbeta movie exp1'}
dateArray = {'2018_11_03 plate 2 c2c12 116 DALgreen rapamycin chloroquine tgf movie exp1'};
dateArray = {'2018_11_03 plate 1 c2c12 116 retinoic acid bix tgfbeta movie exp1','2018_11_03 plate 2 c2c12 116 DALgreen rapamycin chloroquine tgf movie exp1'};
dateArray = {'2018_11_03 plate 2 c2c12 116 retinoic acid tgfbeta movie exp2'};
dateArray = {'2018_11_05 plate 1 c2c12 116 retinoic acid tgfbeta movie exp1','2018_11_05 plate 2 c2c12 86 ctgf retinoic acid tgfbeta movie exp1'};
% dateArray = {'2018_11_05 plate 2 c2c12 86 ctgf retinoic acid tgfbeta movie exp1'};
dateArray = {'2018_10_30 plate c2c12 116 DALgreen rapamycin chloroquine tgfbeta movie exp1','2018_11_03 plate 2 c2c12 116 DALgreen rapamycin chloroquine tgf movie exp1'};
dateArray = {'2018_11_07 plate 1 c2c12 116 retinoic acid tgfbeta movie exp1'};
% dateArray = {'2018_11_09 plate 1 nmumg 235+157 ctgf tgfbeta movie exp1'};
dateArray = {'2018_11_07 plate 2 c2c12 116 snail 86 ctgf retinoic acid tgfbeta movie exp1'};
dateArray = {'2018_11_10 plate 1 c2c12 116 retinoic acid tgfbeta movie exp3'};
dateArray = {'2018_11_14 plate c2c12 133 caga12 retinoic acid tgfbeta movie exp1'};
dateArray = {'2018_08_18 plate c2c12 116 24 well movieimmumo immuno exp3'}
dateArray = {'2018_11_30 c2c12 new snail clones round1 plate exp1','2018_11_30 c2c12 new snail clones round1 plate exp2','2018_12_01 c2c12 new snail clones round2and3 plate exp1','2018_12_01 c2c12 new snail clones round2and3 plate exp2'};
dateArray = {'2017_11_04 plate exp1','2017_11_04 plate exp2'}
dateArray = {'2017_04_17 plate exp3','2017_04_17 plate exp4'}
%% specify which functions you which to run
extract_true = 0;
excel_true = 1;
flat_true = 0;
seg_true = 0;
autotrack_true = 1;
bleach_true = 0;
flatINDimg_true = 0;
extractTIFFflat_true = 0; %extract tiff images for making imageJ movies
TIFFmovie_true = 0; %extract tiff images for making imageJ movies
MATmovie_true = 0; %extract tiff images for making imageJ movies
exportFrames = 0;
%% Extraction Loop .mat
if extract_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
%extract images from .czi and save image stacks as .mat files
ExtractMetadataAndImages(B);
end
end
%% Extraction Loop TIFFS
if extractTIFFflat_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
%extract images from .czi and save image stacks as .mat files
ExtractMetadataAndImagesTIFF(B);
A=[];
BACKGROUND = [];
channelstoinput = {'EGFP','DIC','mKate'};
FlatfieldCorrectionOfTimeLapseImagesTIFFs(A,B,channelstoinput,BACKGROUND);
end
end
% movies TIFFs
if TIFFmovie_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
%extract images from .czi and save image stacks as .mat files
A=[];
BACKGROUND = [];
channelstoinput = {'EGFP','mKate'};
stimulationFrame = 3;
MovieMakerBaby([],B,channelstoinput,stimulationFrame)
end
end
% movies TIFFs
if MATmovie_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
%extract images from .czi and save image stacks as .mat files
A=[];
BACKGROUND = [];
channelstoinput = {'EGFP','mKate'};
stimulationFrame = 2;
MovieMakerBabyMAT([],B,channelstoinput,stimulationFrame)
end
end
%% UserInput (Excel) Details Loop
if excel_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
%extract data in excel file
cd(parentdir)
exName = strcat(B,'-metaData.mat');
makeDoseStructFromXLS(exName);
end
end
%% Flatfield correction Loop
if flat_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
% load excel-extracted data
datequery = strcat(FileName,'*DoseAndScene*');
cd(exportdir)
filelist = dir(datequery);
if isempty(filelist)
error(strcat('need to run ExtractMetadata for-',FileName));
%dosestruct = makeDoseStruct; %run function to make doseStruct
else
dosestructstruct = load(char(filelist.name));
dosestruct = dosestructstruct.dosestruct;
segInstruct = dosestructstruct.segInstruct;
end
A=[];
channelstoinput = dosestructstruct.channelNameSwapArray;
bkg = dosestructstruct.BACKGROUND;
BACKGROUND = bkg{1};
dontsegment = BACKGROUND;
% run Flatflield correction
BackgroundAndFlatfieldCorrectionOfTimeLapseImages(A,B,channelstoinput,BACKGROUND);
end
end
%% BleachCorrection correction Loop
if bleach_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
% load excel-extracted data
datequery = strcat(FileName,'*DoseAndScene*');
cd(exportdir)
filelist = dir(datequery);
if isempty(filelist)
error(strcat('need to run ExtractMetadata for-',FileName));
%dosestruct = makeDoseStruct; %run function to make doseStruct
else
dosestructstruct = load(char(filelist.name));
dosestruct = dosestructstruct.dosestruct;
segInstruct = dosestructstruct.segInstruct;
end
A=[];
channelstoinput = dosestructstruct.channelNameSwapArray;
bkg = dosestructstruct.BACKGROUND;
BACKGROUND = bkg{1};
dontsegment = BACKGROUND;
% run Flatflield correction
BleachCorrectionOfTimeLapseImages(A,B,channelstoinput,BACKGROUND);
end
end
%% Flatfield correction Loop
if flatINDimg_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
% load excel-extracted data
datequery = strcat(FileName,'*DoseAndScene*');
cd(exportdir)
filelist = dir(datequery);
if isempty(filelist)
error(strcat('need to run ExtractMetadata for-',FileName));
%dosestruct = makeDoseStruct; %run function to make doseStruct
else
dosestructstruct = load(char(filelist.name));
dosestruct = dosestructstruct.dosestruct;
segInstruct = dosestructstruct.segInstruct;
end
A=[];
channelstoinput = dosestructstruct.channelNameSwapArray;
bkg = dosestructstruct.BACKGROUND;
BACKGROUND = bkg{1};
dontsegment = BACKGROUND;
% run Flatflield correction
% BackgroundAndFlatfieldCorrectionOfTimeLapseImages(A,B,channelstoinput,BACKGROUND);
Seg_Flat_and_Sub_TimeLapseImages(A,B,channelstoinput,BACKGROUND);
end
end
%% Segmentation Loop
if seg_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
% load excel-extracted data
datequery = strcat(FileName,'*DoseAndScene*');
cd(exportdir)
filelist = dir(datequery);
if isempty(filelist)
error(strcat('need to run ExtractMetadata for-',FileName));
%dosestruct = makeDoseStruct; %run function to make doseStruct
else
dosestructstruct = load(char(filelist.name));
dosestruct = dosestructstruct.dosestruct;
segInstruct = dosestructstruct.segInstruct;
end
A=[];
channelstoinput = dosestructstruct.channelNameSwapArray;
bkg = dosestructstruct.BACKGROUND;
BACKGROUND = bkg{1};
dontsegment = BACKGROUND;
% run segmentation
% uiSegmentTimeLapseImages
SegmentationOfTimeLapseImages(A,B,dontsegment,segInstruct);
end
end
% donemail('cfrick@caltech.edu','segmentation complete','segmentation complete')
%% Autotracking and Export Loop
if autotrack_true
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
uiTrackCellzNEW(B,'AutoExportNuclei')
% uiTrackCellzNEW(B,'AutoTrackCells')
% uiTrackCellzNEW(B,'AutoExportTracks')
end
end
%% export franems
if exportFrames
for BB = dateArray
%get directory name from date Array
B = char(BB);
FileName = B;
disp(FileName)
%extract images from .czi and save image stacks as .mat files
A=[];
BACKGROUND = [];
channelstoinput = {'AlexaFluor647','Hoechst'};
channelstoinput = {'mKate'};
stimulationFrame = 2;
frameExporter([],B,channelstoinput,stimulationFrame)
end
end
fullTime = toc(fullT);
disp(['total time for all is = ', num2str(round(fullTime./60,0,'decimals')) ' minutes']);
% donemail('cfrick@caltech.edu','export complete','export complete')