-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasure_multiImage_CZI_5chMP.ijm
135 lines (110 loc) · 4.28 KB
/
measure_multiImage_CZI_5chMP.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
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
macro 'convert CZI to tiff' {
/*
* - converts czi files into TIFF and analyses them.
* - the macro ask for an input folder that should contain 1 or more czi files.
* - if they are tilescans, it saves each tile out as a tif and analyses independently.
* - each series is saved as one tiff. The name of the series is appended to the file name.
* - The TIFFs are saved in a folder generated by the macro in the same
* - parent folder as the lifs, with the same prefix for the folder name, with TIFF suffix.
* - The analyses are stored in separate folders in a similar manner with the names _Areas
* - and _Objects
*
*/
run("Bio-Formats Macro Extensions");
dir1 = getDirectory("Choose folder with czi files ");
list = getFileList(dir1);
setBatchMode(true);
// create folders for the tifs
dir1parent = File.getParent(dir1);
dir1name = File.getName(dir1);
dir2 = dir1parent+File.separator+dir1name+"_Tiffs";
dir3 = dir2+File.separator+"_Areas";
dir4 = dir2+File.separator+"_Objects";
if (File.exists(dir2)==false) {
File.makeDirectory(dir2); // new directory for tiff
}
if (File.exists(dir3)==false) {
File.makeDirectory(dir3); // new directory for area analsysis
}
if (File.exists(dir4)==false) {
File.makeDirectory(dir4); // new directory for object analysis
}
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
print("processing ... "+i+1+"/"+list.length+"\n "+list[i]);
filename = dir1 + list[i];
if (endsWith(filename, "czi")){
path=dir1+list[i];
//how many series in this czi file?
Ext.setId(path);//-- Initializes the given path (filename).
Ext.getSeriesCount(seriesCount); //-- Gets the number of image series in the active dataset.
for (j=1; j<=seriesCount; j++) {
run("Bio-Formats", "open=path autoscale color_mode=Default view=Hyperstack stack_order=XYCZT series_"+j);
name=File.nameWithoutExtension;
seriesname=name;
// saveAs("/Users/glyn_nelson/Desktop/test/cziTest/heart_point3airy_decon_with_measured_PSF-2.tif");
saveAs("TIFF", dir2+File.separator+name+"#"+j+".tif");
//Now analyse the image
//modified for 4 channel images ch1 920 SHG, ch2 920 GFP, ch3 1040 SHG, ch4 1040 AF/vasc dye
title =getTitle();
rename("tilescan1cleaner_4wk");
run("Make Composite");
//first merge both shg as a minimum to remove shot noise
run("Duplicate...", "title=shg1 duplicate channels=1");
selectWindow("tilescan1cleaner_4wk") ;
run("Duplicate...", "title=shg2 duplicate channels=4");
imageCalculator("Min create", "shg1","shg2");
selectWindow("Result of shg1");
rename("SHG_" + title);
run("Despeckle");
run("Set Measurements...", "area mean standard perimeter integrated area_fraction limit display redirect=None decimal=3");
run("Measure");
close();
selectWindow("shg1");
close();
selectWindow("shg2");
close();
//now clean up GFP using the AF in red channel
selectWindow("tilescan1cleaner_4wk") ;
run("Duplicate...", "title=green duplicate channels=2");
//selectWindow("tilescan1cleaner_4wk") ;
//run("Duplicate...", "title=greenBgrnd duplicate channels=3");
//imageCalculator("Subtract create", "green","greenBgrnd");
//selectWindow("Result of green");
//setAutoThreshold("Huang dark");
//run("Convert to Mask");
//run("Close");
rename("GFP_" + title);
//setMinAndMax(1000, 4095);
//run("Despeckle");
//run("Apply LUT");
run("Measure");
//rename("binary");
saveAs("Results", dir3+File.separator+name+"#"+j+"_GFPandColl_Area.csv");
run("Clear Results");
selectWindow("GFP_"+title);
//setAutoThreshold("IsoData dark");
//setAutoThreshold("Huang dark");
//run("Convert to Mask"); //needs to be made binary for the dilate to run
//run("Dilate");
run("Gaussian Blur...", "sigma=4"); //obviously loses the binary-ness
//setAutoThreshold("MaxEntropy dark");
run("Convert to Mask");
//run("Make Binary");
//selectWindow("binary");
rename("GFPbinary_" + title);
run("Analyze Particles...", "size=30.00-Infinity display");
//run("Analyze Particles...", "size=30-Infinity summarize");
//SelectWindow(Summary);
saveAs("Results", dir4+File.separator+name+"#"+j+"_GFP_Objects.csv");
run("Clear Results");
run("Close All");
// run("Collect Garbage");
}
}
//showMessage(" Well, I think we gave them a damn good thrashing there, what what??");
run("Close All");
setBatchMode(false);
}
showMessage(" Well, I think we gave them a damn good thrashing there, what what??");
// macro