-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFastFUCCI_1-cellcycle-processing_2.0.ijm
86 lines (66 loc) · 2.95 KB
/
FastFUCCI_1-cellcycle-processing_2.0.ijm
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
// Written by Patrice Mascalchi, June 2016, CRUK Cambridge Institute - Bordeaux Imaging Center, University of Bordeaux
// Macro to split multi-channel timelapse images in single green and red videos.
// IMPORTANT: Works for 2- or more channels dataset, but GREEN expected in first channel and RED in second one!
// Required plugins (all included in Fiji package): Bio-Formats, Bleach Correction
// Pre-requisite: you have to check that image processing (background subtraction, shading correction,
// optional bleach correction) is adapted to your timelapse videos. See code below for each channel...
// Parameters to be modified by user
mainpath = "E:\\Siang\\Exp59\\"; // directly containing images
format = ".czi";
// --------------------------------------------------------------------------------------------------------------
outG = mainpath + "green\\";
if (!File.exists(outG)) File.makeDirectory(outG);
outR = mainpath + "red\\";
if (!File.exists(outR)) File.makeDirectory(outR);
setBatchMode(true);
flist = SortFileList(mainpath, format);
for (f = 0; f < flist.length; f++) {
outGname = "siang-fucci_xy" + IJ.pad(f+1,3) + "_green.tif";
outRname = "siang-fucci_xy" + IJ.pad(f+1,3) + "_red.tif";
run("Bio-Formats Importer", "open=[" + mainpath + flist[f] +"] color_mode=Grayscale split_channels view=Hyperstack stack_order=Default");
wait(3000); // pause to avoid opening errors
closeWin(flist[f]+ " - C=2"); // close unused channel
// GREEN channel
selectWindow(flist[f]+ " - C=0");
rename("green.tif");
// Background subtraction and shading correction with minimum + Gaussian filter evaluation
run("Duplicate...", "title=min.tif duplicate");
run("Minimum...", "radius=30 stack");
run("Gaussian Blur...", "sigma=50 stack");
imageCalculator("Subtract stack", "green.tif", "min.tif");
// Bleach correction due to auto-fluorescence of medium
run("Bleach Correction", "correction=[Exponential Fit]");
closeWin("y = a*exp(-bx) + c");
closeWin("min.tif");
saveAs("Tiff", outG + outGname);
// RED channel
selectWindow(flist[f]+ " - C=1");
// Background subtraction with default ImageJ function (will have a shading correction effect as well)
run("Subtract Background...", "rolling=50 stack");
saveAs("Tiff", outR + outRname);
run("Close All");
}
setBatchMode(false);
waitForUser("done!");
// ------------------------------------------------------------------------------------------
// --------------------------- functions ----------------------------------------------------
function SortFileList(path, filter) { // Sort with endsWith
flist = getFileList(path);
OutAr = newArray(flist.length);
ind = 0;
for (f=0; f<flist.length; f++) {
//print(flist[f] + " : "+endsWith(flist[f], filter));
if (endsWith(flist[f], filter)) {
OutAr[ind] = flist[f];
ind++;
}
}
return Array.trim(OutAr, ind);
}
// close any window without returning any error
function closeWin(name) {
if (isOpen(name)) {
selectWindow(name);
run("Close");
}
}