Hello Wayne and Friends -
Here is some more information about what might be going on.
It looks like adding an Roi
to the RoiManager
causes
the (copy of the) Roi
in the RoiManager
to be given
the hyperstack location of the open (has focus?) image.
That is, it looks like the loss of the Roi
's hyperstack
location is associated with passing the Roi
through the
RoiManager
and is not related to saving / reopening
the Roi
.
If no image is open, the RoiManager
's Roi
keeps the
Roi
's hyperstack location. If a non-hyperstack image
is open, the hyperstack location is lost. If a hyperstack
is open, the Roi
picks up the hyperstack location of
the hyperstack’s currently displayed hyperslice.
My hint for tracking this down was the appearance of
#@ ImagePlus imp
in the script Iguerard originally posted.
Here is a demo script and its output:
from ij import IJ
from ij.gui import PointRoi
from ij.plugin.frame import RoiManager
print 'version =', IJ.getFullVersion()
rm = RoiManager (False)
print 'with no image ...'
roi = PointRoi (10, 10)
roi.setPosition (2, 2, 1)
print 'roi ...'
print 'C =', roi.getCPosition(), ', Z =', roi.getZPosition(), ', T =', roi.getTPosition()
rm.addRoi (roi)
roi_check = rm.getRoi (0)
rm.reset()
print 'roi_check ...'
print 'C =', roi_check.getCPosition(), ', Z =', roi_check.getZPosition(), ', T =', roi_check.getTPosition()
print 'with image ...'
imp = IJ.createImage ('plain image', '8-bit ramp', 256, 256, 1)
imp.show()
roi = PointRoi (20, 20)
roi.setPosition (3, 3, 2)
print 'roi ...'
print 'C =', roi.getCPosition(), ', Z =', roi.getZPosition(), ', T =', roi.getTPosition()
rm.addRoi (roi)
roi_check = rm.getRoi (0)
rm.reset()
print 'roi_check ...'
print 'C =', roi_check.getCPosition(), ', Z =', roi_check.getZPosition(), ', T =', roi_check.getTPosition()
imp.close()
print 'with hyperstack ...'
imp = IJ.createHyperStack ('hyperstack', 256, 256, 10, 10, 20, 8)
imp.setC (8)
imp.setZ (7)
imp.setT (6)
imp.show()
roi = PointRoi (30, 30)
roi.setPosition (4, 4, 3)
print 'roi ...'
print 'C =', roi.getCPosition(), ', Z =', roi.getZPosition(), ', T =', roi.getTPosition()
rm.addRoi (roi)
roi_check = rm.getRoi (0)
rm.reset()
print 'roi_check ...'
print 'C =', roi_check.getCPosition(), ', Z =', roi_check.getZPosition(), ', T =', roi_check.getTPosition()
version = 1.52r38
with no image ...
roi ...
C = 2 , Z = 2 , T = 1
roi_check ...
C = 2 , Z = 2 , T = 1
with image ...
roi ...
C = 3 , Z = 3 , T = 2
roi_check ...
C = 0 , Z = 0 , T = 0
with hyperstack ...
roi ...
C = 4 , Z = 4 , T = 3
roi_check ...
C = 8 , Z = 7 , T = 6
(My earlier claim that RoiEncoder
doesn’t write out the
hyperstack location was simply wrong. It is written out
by RoiEncoder.putHeader2()
.)
Thanks, mm