1+ // Christophe Leterrier 18-04-2018
12macro HyperStack_to_Montage {
23
34// setBatchMode(true);
45 margin = 5;
5-
6+
7+
8+ Stack.setDisplayMode("composite");
69 inID = getImageID();
710 inTitle = getTitle();
811 getDimensions(inWidth, inHeight, inChannels, inSlices, inFrames);
912
13+
14+
1015 outLabels = getLabels(inID);
1116
1217
13-
18+
1419 selectImage(inID);
1520 run("Stack to RGB", "slices keep");
1621 rename("RGB");
1722 rgbID = getImageID();
18-
23+
1924 selectImage(inID);
2025 splitIDs = newArray(inChannels);
2126 splitTitles = newArray(inChannels);
22-
27+
2328 for (i = 0; i < inChannels; i++) {
2429 selectImage(inID);
2530 currC = i + 1;
2631 run("Duplicate...", "duplicate channels=" + currC);
2732 splitIDs[i] = getImageID();
2833 splitTitles[i] = getTitle();
29-
34+
3035 run("Grays");
3136 run("RGB Color");
3237 run("Canvas Size...", "width=" + (inWidth + margin)+ " height=" + inHeight + " position=Center-Left");
3338 makeRectangle(inWidth, 0, margin, inHeight);
3439 setForegroundColor(255, 255, 255);
3540 run("Fill", "stack");
36-
41+
3742 if (i > 0) {
3843 run("Combine...", "stack1=[" + splitTitles[i-1] + "] stack2=[" + splitTitles[i] + "]");
3944 rename(splitTitles[i]);
4045 combineID = getImageID();
4146 }
4247 }
43-
48+
4449 run("Combine...", "stack1=[" + splitTitles[inChannels - 1] + "] stack2=[RGB]");
4550 finalID = getImageID();
4651 rename(stripExt(inTitle) + "_Montage.tif");
@@ -49,8 +54,8 @@ macro HyperStack_to_Montage {
4954 Stack.setPosition(1, j + 1, 1);
5055 setMetadata("Label", outLabels[j]);
5156 }
52- Stack.setPosition(1, 1, 1);
53-
57+ Stack.setPosition(1, 1, 1);
58+
5459// setBatchMode("exit and display");
5560
5661}
0 commit comments