-
Notifications
You must be signed in to change notification settings - Fork 0
/
7_Image_Batch_Calcium_Traces_from_RoiSet.ijm
executable file
·57 lines (50 loc) · 1.71 KB
/
7_Image_Batch_Calcium_Traces_from_RoiSet.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
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("_C2_Reg", "_C2toC1_Reg_C2_Spl", "_BSub");
Dialog.addChoice("Extract From:", items, "_BSub");
Dialog.addMessage("Delete Files:");
Dialog.show();
inDisOutD=Dialog.getCheckbox();
ExtrFrom=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!");
}
}
setBatchMode(true);
MeanGrayValueExtraction(inDir, outDir);
setBatchMode(false);
function MeanGrayValueExtraction(inDir, outDir) {
run("Set Measurements...", "mean redirect=None decimal=3");
run("Input/Output...", "jpeg=85 gif=-1 file=.csv");
list = getFileList(inDir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/")) {
MeanGrayValueExtraction(inDir+list[i], outDir+list[i]);
}
else if ((endsWith(list[i], ExtrFrom+".tif"))&&(!File.exists(replace(outDir+s+list[i], ExtrFrom+".tif", ExtrFrom+"_MeanGray.csv")))) {
open(outDir+list[i]);
name=File.getName(outDir+list[i]);
selectWindow(name);
roiManager("Open", replace(outDir+s+list[i], ExtrFrom+".tif", "_RoiSet.zip"));
roiManager("Select", 0);
roiManager("Multi Measure");
selectWindow("Results");
saveAs("Results", replace(outDir+s+list[i], ExtrFrom+".tif", ExtrFrom+"_MeanGray.csv"));
close("Results");
roiManager("Select", 0);
roiManager("Delete");
roiManager("Select", 0);
roiManager("Delete");
close(name);
run("Close All");
}
}
}