Retrieve z-position of a roi

Hello,

is there a way to retrieve the z-position of a roi with a macro command? Maybe something like Roi.getPosition (similar to the existing command Roi.getFillColor). I can extract that info from the roi name, but maybe there is an easier solution already existing?

Thanks, Martin

Exactly this one is available in the scripting languages. From the ij.gui.Roi javadoc:

public int getPosition()

Returns the stack position (image number) of this ROI, or
zero if the ROI is not associated with a particular stack image.

You have to ask @Wayne if he wants to make this available in the macro language as well.

in a macro where your ROIs are stored in the ROI manager and you are iterating through them you can use for each ROI of index idx

roiManager("Select", idx);
Stack.getPosition(channel, slice, frame); // OR getSliceNumber() if your image is a single channel stack
3 Likes

You can get the stack position of an ROI in a macro using the eval() function, for example:

pos = eval("js","IJ.getImage().getRoi().getPosition()");
print("position="+pos);
3 Likes