Login  Register

Re: Rename ROIs lose Z position

Posted by dscho on Mar 12, 2011; 10:00am
URL: http://imagej.273.s1.nabble.com/Rename-ROIs-lose-Z-position-tp3685300p3685303.html

Hi,

On Fri, 11 Mar 2011, Chad McCormick wrote:

> Recently I attempted to use the Update command of the roiManager in a
> macro to add a z position to 2D circular ROI and was unsuccessful.  I
> then tried a work around by using "Specify" with the third dimension and
> it worked fine, though not ideal as it creates a new ROI.  The problem
> comes that I have a strict naming system of ROIs (using cell numbers or
> subcellular localization numbers to replace the z-y-x nomenclature).  
> When I rename an ROI, the XY values are saved, but Z is lost.

Yep, that is correct. It is due to the method getSliceNumber() which very
rigidly for a format <number>-<something>-<something2> where both <number>
and <something> either must have 4 places or 5 or 6, and <something2> at
least the same number of places:

        http://pacific.mpi-cbg.de/RoiManager.java:589

The latter two parts need not be numbers at all. You can verify this
by executing the following Javascript (I tested this in Fiji's Script
Editor, obviously, so you might need to adjust it a little bit to get it
to run in ImageJ's macro editor):

        label = "0013-chad-mccormick";
        importClass(Packages.ij.IJ);
        importClass(Packages.ij.plugin.frame.RoiManager);
        IJ.log(new RoiManager().getSliceNumber(label));

So if you make sure that your renamed ROI labels start with 4 digits
encoding the slice number followed by a dash, exactly 4 characters
followed by another dash, followed by at least 4 characters, you're fine.
Example: 1492----------mitochondrion-1. Yes, this is only a workaround.

Ciao,
Johannes