Rename ROIs lose Z position

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Rename ROIs lose Z position

Chad McCormick
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.

Any suggestions how I can keep my naming system and still have the ROIs be slice specific?

Thanks,

Chad McCormick
Reply | Threaded
Open this post in threaded view
|

Re: Rename ROIs lose Z position

dscho
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
Reply | Threaded
Open this post in threaded view
|

Re: Rename ROIs lose Z position

Chad McCormick
In reply to this post by Chad McCormick
Johannes,

Thanks for your input.  Given your suggestion, I've updated my code so that when I rename the ROIs, I preserve the existing (4digit)-(4digit)-something architecture by appending a delimiter with my specific name.  This way ImageJ can still use the method getSliceNumber properly and I can still manage the names of ROIs as I see fit.  Any sorting or calls to specific ROIs based on name can be done by splitting the name at the delimiter.

Example:
Before zzzz-yyyy-xxxx
After zzzz-yyyy-xxxx#cellName_subCellularName

Again, this is only a workaround as it would be nice if ImageJ did not store the Z position in the ROI name as it already does not store the XY position in the ROI name.

Thanks again for your help.

-- Chad McCormick
Reply | Threaded
Open this post in threaded view
|

Re: Rename ROIs lose Z position

Rasband, Wayne (NIH/NIMH) [E]
> 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.
>
> Any suggestions how I can keep my naming system and still have the ROIs be slice specific?

These problems are fixed ImageJ in 1.45d. The ROI Manager "Update" command updates the Z position and a renamed ROI does not lose its Z position. The Roi class now has setPosition() and getPosition() methods for setting and retrieving the Z position. There is a JavaScript example at

   http://imagej.nih.gov/ij/macros/js/StackOverlay.js

and a macro example at

   http://imagej.nih.gov/ij/macros/examples/StackOverlay.txt

-wayne