-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_Image_Batch_Splitting.ijm
executable file
·56 lines (48 loc) · 1.59 KB
/
3_Image_Batch_Splitting.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
s=File.separator;
Dialog.create("Bruker Data Manager");
Dialog.addCheckbox("Input Directory = Output Directory", true);
Dialog.addMessage("Channel Splitting:");
Dialog.addCheckbox("Split Channels and Keep:", true);
Dialog.addToSameRow();
items=newArray("Stack_Extr", "C2toC1_Reg", "C1toC2_Reg");
Dialog.addChoice("", items, "C1_Reg.tif");
items = newArray("C1", "C2");
Dialog.addRadioButtonGroup("", items, 1, 2, "C2");
Dialog.show();
inDisOutD=Dialog.getCheckbox();
ChSplitKeep=Dialog.getCheckbox();
ChSplitKeepChoice=Dialog.getChoice();
Keep=Dialog.getRadioButton();
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);
if (ChSplitKeep==true) {
SplitChannelsAndKeep(inDir, outDir);
}
print("Done");
setBatchMode(false);
function SplitChannelsAndKeep(inDir, outDir) {
list = getFileList(inDir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/")) {
SplitChannelsAndKeep(inDir+list[i], outDir+list[i]);
}
else if ((endsWith(list[i], ChSplitKeepChoice+".tif"))&&(!File.exists(replace(outDir+s+list[i], ChSplitKeepChoice, ChSplitKeepChoice+"_"+Keep+"_Spl.tif")))) {
open(outDir+list[i]);
name=File.getName(outDir+list[i]);
selectWindow(name);
run("Split Channels");
selectWindow(Keep+"-"+name);
saveAs("tiff", replace(outDir+s+list[i], ChSplitKeepChoice, ChSplitKeepChoice+"_"+Keep+"_Spl"));
run("Close All");
}
}
}