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
- Save an existing ROI as a
- Rename the file
- Open the rename
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("reset"); roiManager("Add"); 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"); roiManager("deselect"); roiManager("Measure");
This will create the following results table:
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
.roifile 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?