Roi.getName does not function wile zero images are open

Strangely an image needs to be open in order to consult the names of the rois in the ROI Manager. With Rois in the Roi Manager and no images open,

thisName = Roi.getName;

fails with the error message that no images are open.

Of course one can check for the number of open images and open a dummy image, but it seems more elegant when the ROI Manager could handle this request without images being open.

In an attempt to imitate the behaviour of ObjectJ by @Norbert_Vischer, and bind ROIs to image files where they originate from, renaming the ROI to contain the path-and-filename in the ROI Manager works OK. It is the retrieval (in order to assess presence of said file in the said path) that fails in the no-images-open case, otherwise this method works well.

Upgrade to the ImageJ 1.53c40 daily build and use the new RoiManager.getName() macro function. Here is a example:

  run("Blobs (25K)");
  run("Analyze Particles...", "add");
  for (i=0; i<roiManager("count"); i++)
     print(i, RoiManager.getName(i));
1 Like

Thanks @Wayne.

Also good to learn that a Roi.setProperty/Roi.getProperty in combination with the RoiManager survives a save/delete/open cycle.