Retrieve slice / stack information from ROI Manager

Hello, I have a stack with multiple ROI drawn on each slice. All of these ROI have been added to the ROI Manager. For a particular ROI, I want to identify which slice/position it belongs to.

Within the ROI manager, if I click a particular ROI => Properties, the properties window displays the position (slice number), but I don’t know how to record this within a macro? The ImageJ website here shows that the naming scheme for each ROI should be XXXX-YYYY-ZZZZ, where XXXX indicates the slice number. However, for me the naming scheme is displayed as AAAA-BBBB, where AAAA is just the ROI number. Is there a way to change the naming scheme to display the slice/position number? Or another way to access this? Thank you.

Edit: I’m sure there is a better way, but I was able to do it using the following in a for loop.

roiManager("select", i);
print(getSliceNumber());

I seem to recall having a similar issue myself. One would have thought you could use Roi.getProperty but that (as well as Roi.getProperties) appears to not work. Starting with 1.52r, it looks like you should be able to use Roi.getPosition.

Here is what I did trying to use Roi.getProperty. Maybe someone who knows more could tell me if I am doing something wrong.

/*
open and image and select some ROIs
*/
roiManager("select", 0);
a = Roi.getProperty("position");
print(a);