-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_Image_Batch_Segmentation.ijm
executable file
·67 lines (60 loc) · 2.02 KB
/
5_Image_Batch_Segmentation.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
s=File.separator;
Dialog.create("Bruker Data Manager");
Dialog.addCheckbox("Input Directory = Output Directory", true);
Dialog.addMessage("Extract Mean Gray Values from ROI:");
items=newArray("_SReg", "_C1_Reg", "_C2_Reg", "_C2toC1_Reg", "_C1toC2_Reg");
Dialog.addChoice("Extract From:", items, "C1_Reg.tif");
items1=newArray("Maximum Intensity", "Average Intensity");
Dialog.addChoice("Projection for ROI:", items1, "Average Intensity");
Dialog.show();
inDisOutD=Dialog.getCheckbox();
ExtrFrom=Dialog.getChoice();
Projection=Dialog.getChoice();
inDir=getDirectory("Choose the Raw Data Containing Folder");
if (inDisOutD==true) {
outDir=inDir;
}
else {
outDir=getDirectory("Choose Output Folder");
if ((inDir==outDir) || (startsWith(outDir, inDir))) {
exit("Input folder must be different from and not within output folder!");
}
}
SingleCellSegmentation(inDir, outDir);
function SingleCellSegmentation(inDir, outDir) {
list = getFileList(inDir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/")) {
SingleCellSegmentation(inDir+list[i], outDir+list[i]);
}
else if ((endsWith(list[i], ExtrFrom+".tif"))&&(!File.exists(replace(outDir+s+list[i], ExtrFrom+".tif", ExtrFrom+"_RoiSet.zip")))) {
open(outDir+list[i]);
name=File.getName(outDir+list[i]);
selectWindow(name);
run("Z Project...", "projection=["+Projection+"]");
selectWindow("AVG_"+name);
run("Duplicate...", "title=Mask");
selectWindow("Mask");
run("Make Binary");
setTool("wand");
run("ROI Manager...");
waitForUser("Select the Cell/ROI please");
roiManager("Add");
roiManager("Select", 0);
roiManager("Rename", "Cell");
run("Make Inverse");
roiManager("Add");
roiManager("Select", 1);
roiManager("Rename", "Background");
roiManager("Select", newArray(0,1));
roiManager("Save", replace(outDir+s+list[i], ExtrFrom+".tif", ExtrFrom+"_RoiSet.zip"));
selectWindow(name);
close(name);
close("Results");
roiManager("Select", newArray(0,1));
roiManager("Delete");
run("Close");
run("Close All");
}
}
}