Macro name each Slice and give them separate commands in the same program

imagej
macro
stack

#1

Hi all,
I have created two slices. I need to an invert measure in one slice and non inverted measure in other slice. How do differentiate each slice in macro and give them seperate commands. For now I am getting same values for both the slice. Please find the attached code;

run("Set Scale...", "distance=7.6500 known=1 pixel=1 unit=unit global");

//setTool("rectangle");
makeRectangle(0, 0, 2048, 2048);
run("Crop");

setAutoThreshold("Default");
//run("Threshold...");
//setThreshold(0, 120);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Close");
run("Copy");
run("Add Slice");
run("Paste");
run("Remove Outliers...", "radius=2 threshold=80 which=Dark stack");
run("Remove Outliers...", "radius=2 threshold=80 which=Bright stack");
run("Invert", "slice");
run("Watershed", "slice");
roiManager("Set Color", "blue");
run("Analyze Particles...", "  show=[Overlay Outlines] display clear summarize add slice");
roiManager("Show All without labels");
roiManager("Set Color", "yellow");
run("Analyze Particles...", "  show=[Overlay Outlines] display summarize add slice");

#2

Brute force would change the stack of 2 slices into 2 images, perform the measurements on either image and change 2 images back to 1 stack. Alternatively, use setSlice() to select a slice and run the measurement on that slice only. Or am I missing something :wink: ?