-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path3_Macro-CycIF-wholeslidequan.ijm
101 lines (78 loc) · 2.59 KB
/
3_Macro-CycIF-wholeslidequan.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
//Read color stack/hyperstack & quantification
//20161219 Jerry Lin
//Need preprocessed/registrated tif files
//Initialization
//startimg = 1; // begin of fram
//endimg = 238; // end of frame
maskch = 7; //cycle of DAPI for generating mask
startT = getTime;
myDIR = getString("Enter the image directory","C:\\rcpnl\\shaolin-tonsil\\tonsil1\\");
myName = getString("Enter file header:","Tonsil1");
startimg= getNumber("Enter starting image:",1);
totalimage = getNumber("Enter number of images:",238);
channels=getNumber("Enter number of channels:",40);
maskch = getNumber("Enter cycle for mask:",7);
ensize = getNumber("Enter size for enlarge ROIs(3 for 10x and 6 for 40x images):",3);
//myName = getTitle;
setBatchMode(true);
for(img =startimg;img<=totalimage;img++){ //loop:img
open(myDIR+myName+"-"+img+".tif");
//break color hyperstack into stack
rename("temp");
run("Split Channels");
selectWindow("C1-temp");
run("Stack to Images");
selectWindow("C2-temp");
run("Stack to Images");
selectWindow("C3-temp");
run("Stack to Images");
selectWindow("C4-temp");
run("Stack to Images");
run("Images to Stack", "name=Stack title=-temp use");
run("Grays");
rename(myName+"-"+img);
print ("processing:"+myName+"-"+img+" time ="+(getTime-startT)/1000);
// Generate Mask/ROI
setSlice(maskch);
run("Duplicate...", "title=MASK");
run("Subtract Background...", "rolling=10 disable");
run("Subtract...", "value=1500");
//setOption("BlackBackground", false);
run("Make Binary");
run("Watershed");
roiManager("Deselect");
run("Analyze Particles...", "size=20-400 circularity=0.20-1.00 exclude clear include add");
// enlarge ROI
selectWindow("MASK");
run("Out [-]");
run("Out [-]");
counts=roiManager("count");
for(i=0; i<counts; i++) {
roiManager("Select", i);
run("Enlarge...", "enlarge="+ensize+" pixel");
roiManager("Update");
}
print ("Measuring:"+myName+"-"+img+" time ="+(getTime-startT)/1000);
roiManager("Deselect");
selectWindow("MASK");
close();
//Measure multi-stack
run("Clear Results");
run("Set Measurements...", "area mean standard min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack display add redirect=None decimal=3");
setSlice(1);
roiManager("Measure");
for (i=1;i<channels;i++) //measure each frames (expect the first frame)
{
run("Next Slice [>]");
roiManager("Measure");
}
close();
saveAs("Results", myDIR+"Results-"+myName+"-"+img+".csv");
run("Clear Results");
run("Close All");
if(counts>0){
roiManager("Delete");
} //if(count>0)
print ("Finishing:"+myName+"-"+img+" time ="+(getTime-startT)/1000);
} //loop:img
setBatchMode(false);