Inconsistency between ROI names in ROI Manager when loaded from file

Tags: #<Tag:0x00007fb88217c568> #<Tag:0x00007fb88217c2e8>


I noticed that the ROI name listed in the ROI Manager can differ from the ROI name reported by the Measure command under certain circumstances, when loading ROIs from file (both .roi and .zip):

  • Save an existing ROI as a .roi file
  • Rename the file
  • Open the rename .roi file

The name of the ROI in the list will correspond to the new file name, but when you use Measure, the label will contain the original name.

The following macro illustrates this (while at it, I discovered a few other flaws, see the comment in the code and below):

tempDir = getDirectory("temp");

run("Blobs (25K)");
run("Set Measurements...", "display redirect=None decimal=3");

makeRectangle(50, 50, 80, 80);
roiManager("Select", 0);
roiManager("Rename", "original");
print("Trying to save");
// contrary to the documentation, the following only works with zip files
// roiManager("save selected", tempDir + "newName.roi");
waitForUser("Please save the selected ROI as original.roi in your temp folder (" + tempDir + "),\nthen click OK");
print("Trying to rename");
File.rename(tempDir + "original.roi", tempDir + "newName.roi");
print("Trying to open");
roiManager("Open", tempDir + "newName.roi");

This will create the following results table:

1 blobs.gif:original
2 blobs.gif:original

while the ROI Manager looks like this:


I suggest that the behavior be corrected such that the ROI names correspond, either by:

  • changing the ROI name in the list to what’s in the file content, not the file name, or
  • changing the ROI name reported by the Analyzer to correspond to the file name (i.e. rename the ROI accordingly)

As mentioned above, I also discovered the following inconsistencies:

  • The macro recorder doesn’t record anything when saving a single .roi file using More >> Save…

  • Contrary to the documentation:

    roiManager(“save selected”, file-path)
    Saves the selected ROI as a .roi file.

    the function does not work as expected when providing a file path ending on .roi. An error message is displayed: “Name must end with ‘.zip’”

@Wayne any ideas?


Not sure what the problem is, Jan,

but here are the labels I see in the Results-table:


The ROI-manager shows what you’ve posted.

ImageJ 1.51w, Java 1.6.0_65, macOS 10.11.6



The macro recorder gives me:
saveAs("Selection", "/Users/hg/Downloads/original.roi");

Using this macro call works as expected, i.e. without any alert.

Using the save function of the ROI-manager, something I wasn’t aware of, shows indeed the behaviour described by you.

Again one of those effects that we know from Windows:
Various ways to achieve the same functionality lead to confusion and misbehaviour. Why not use a well-choosen single and intuitive way to get a certain functionality?


These problems are fixed in the daily build (1.52a49). Here is an updated version of the test macro:

  dir = getDirectory("temp");
  run("Blobs (25K)");
  run("Set Measurements...", "display");
  makeRectangle(50, 50, 80, 80);
  roiManager("Select", 0);
  roiManager("Rename", "original");
  roiManager("save", dir+"original.roi");
  rtn=File.rename(dir+"original.roi", dir+"newName.roi");
  roiManager("Open", dir+"newName.roi");