Roi Manager headless mode

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

Roi Manager headless mode

Greg
Hi,

also if I think "headlessmode" is a troublesome issue for the brave developers/supporters here,
I also got the impression people are trying to fix this intermingled GUI java.awt issues inherited from imageJ 1.x .

So I read this post

http://imagej.1557.x6.nabble.com/Headless-execution-of-RoiManager-true-gives-exception-td5008274.html 

where it states that the ROI Manager is not available in headless mode.
I want to ask how the situation concerning(!) the ROI manager is nowadays ?
It is a really useful tool, and I would like to use it for some cluster headlessmode image analysis.

I thought about implementing some of its functionality on my own, but I think this can get tedious ?!

Greets,
Greg
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager headless mode

Rasband, Wayne (NIH/NIMH) [E]
On Feb 24, 2015, at 9:28 AM, Greg <[hidden email]> wrote:
>
> Hi,
>
> also if I think "headlessmode" is a troublesome issue for the brave
> developers/supporters here,
> I also got the impression people are trying to fix this intermingled GUI
> java.awt issues inherited from imageJ 1.x .

Consider using an Overlay instead of the RoiManager. An Overlay is like an RoiManager without a GUI. Here is a JavaScript example that creates an Overlay and lists all of its ROIs:

  img = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif");
  IJ.setAutoThreshold(img, "Default");
  IJ.run(img, "Analyze Particles...", "  show=[Overlay Outlines] exclude");
  overlay = img.getOverlay();
  for (i=0; i<overlay.size(); i++)
     IJ.log(i+" "+overlay.get(i));

-wayne

> So I read this post
>
> http://imagej.1557.x6.nabble.com/Headless-execution-of-RoiManager-true-gives-exception-td5008274.html 
>
> where it states that the ROI Manager is not available in headless mode.
> I want to ask how the situation concerning(!) the ROI manager is nowadays ?
> It is a really useful tool, and I would like to use it for some cluster
> headlessmode image analysis.
>
> I thought about implementing some of its functionality on my own, but I
> think this can get tedious ?!
>
> Greets,
> Greg
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Roi-Manager-headless-mode-tp5011750.html
> Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager headless mode

Greg
Hi Wayne,

thank you very much for the quick reply, this is exact the functionality I needed!
I think you got a typo of some sort in the very last line of your snippet, I used

for i in range(overlay.size()):
    roi = overlay.get(i)

with jython and everything works as expected.

Cheers,
Greg
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager headless mode

robert atwood
In reply to this post by Greg
Hi All
I came across this thread when trying to extract the detected particles into a master program using headless mode to call Imagej , and encountering the similar problem with the ROI manager.

I have now tried to use Overlay instead as suggested by Wayne, and to some extent it works, but I cannot quite obtain the information I want, which is a list of the pixels in the detected particle.


I have used the following:

run("Analyze Particles...", "size=25-Infinity show=[Overlay Masks] include record ");

nblobs=Overlay.size;
print ("nblobs="+nblobs);

for (blob=0;blob<nblobs;blob++){
   Overlay.activateSelection(blob);
    bname=Roi.getName;
   Roi.getCoordinates(xp,yp);
   for (i=0;i<xp.length;i++){
     print(blob,bname,xp[i],yp[i]);
   }
}




This seems to behave, but the actual list returned does not make sense to me and doesn't seem to correspond to the overlay as observed in the image viewer. Is it actually a list of some other description of the particle rather than the coordinates, and the number somehow not correspond to the number printed in the overlay label output?

For example, blob #39 is listed as follows, but the attached image (I hope) shows a blob that certainly has more than 4 pixels in it, and is not anywhere near co-ordinate 3214. Furthermore the co-ordinates listed do not form a connected object, it seems like the corners of a 5 pixel square.
 <nabble_img src="imagej_blobnumber.jpg" border="0"/>


 38  1095 55
 38  1100 55
 
 39  3214 60
 39  3207 60
 39  3207 55
 39  3214 55

 40  1729 57


What I really want is a list of horizontal start- and end-points for each row passing through the blob. From a list of all pixels in each blob I can generate this fairly simply   -- or is there another way to do that inside imagej already? -- but I want to do it headless on a cluster and use some quite nice and not so simple processing that is already available in ImageJ even before the particle analysis.


Thanks
Robert


 
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager headless mode

Herbie
Dear Robert,

I'm not very familiar with "Analyze Particles..." but a quick test with
a single elliptic test particle revealed that

Roi.getCoordinates(xp,yp);

actually returns all co-ordinates of the enclosing contour.

So I guess, in order to get the content of the ROI you have either to
extract i.e. copy it, or access the content values pixel by pixel wise
according to the contour co-ordinates.

HTH

Herbie

:::::::::::::::::::::::::::::::::::::::::::
Am 22.01.16 um 14:36 schrieb robert atwood:

> Hi All
> I came across this thread when trying to extract the detected particles into
> a master program using headless mode to call Imagej , and encountering the
> similar problem with the ROI manager.
>
> I have now tried to use Overlay instead as suggested by Wayne, and to some
> extent it works, but I cannot quite obtain the information I want, which is
> a list of the pixels in the detected particle.
>
>
> I have used the following:
>
> run("Analyze Particles...", "size=25-Infinity show=[Overlay Masks] include
> record ");
>
> nblobs=Overlay.size;
> print ("nblobs="+nblobs);
>
> for (blob=0;blob<nblobs;blob++){
>     Overlay.activateSelection(blob);
>      bname=Roi.getName;
>     Roi.getCoordinates(xp,yp);
>     for (i=0;i&lt;xp.length;i++){
>       print(blob,bname,xp[i],yp[i]);
>     }
> }
>
>
>
>
> This seems to behave, but the actual list returned does not make sense to me
> and doesn't seem to correspond to the overlay as observed in the image
> viewer. Is it actually a list of some other description of the particle
> rather than the coordinates, and the number somehow not correspond to the
> number printed in the overlay label output?
>
> For example, blob #39 is listed as follows, but the attached image (I hope)
> shows a blob that certainly has more than 4 pixels in it, and is not
> anywhere near co-ordinate 3214. Furthermore the co-ordinates listed do not
> form a connected object, it seems like the corners of a 5 pixel square.
>   &lt;nabble_img src=&quot;imagej_blobnumber.jpg&quot; border=&quot;0&quot;/>
>
>
>   38  1095 55
>   38  1100 55
> *
>   39  3214 60
>   39  3207 60
>   39  3207 55
>   39  3214 55
> *
>   40  1729 57
>
>
> What I really want is a list of horizontal start- and end-points for each
> row passing through the blob. From a list of all pixels in each blob I can
> generate this fairly simply   -- or is there another way to do that inside
> imagej already? -- but I want to do it headless on a cluster and use some
> quite nice and not so simple processing that is already available in ImageJ
> even before the particle analysis.
>
>
> Thanks
> Robert
>
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Roi-Manager-headless-mode-tp5011750p5015434.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager headless mode

robert atwood
.. and it seems that index flips from 0 to 1 at some point so activateSelection(0) refers to the particle numbered 1 on the overlay :(

Oh well , back to the 'drawing' board .. and it's so close to what I want ..


 

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Herbie
> Sent: 22 January 2016 16:01
> To: [hidden email]
> Subject: Re: Roi Manager headless mode
>
> Dear Robert,
>
> I'm not very familiar with "Analyze Particles..." but a quick test with a single
> elliptic test particle revealed that
>
> Roi.getCoordinates(xp,yp);
>
> actually returns all co-ordinates of the enclosing contour.
>
> So I guess, in order to get the content of the ROI you have either to extract i.e.
> copy it, or access the content values pixel by pixel wise according to the
> contour co-ordinates.
>
> HTH
>
> Herbie
>
> :::::::::::::::::::::::::::::::::::::::::::
> Am 22.01.16 um 14:36 schrieb robert atwood:
> > Hi All
> > I came across this thread when trying to extract the detected
> > particles into a master program using headless mode to call Imagej ,
> > and encountering the similar problem with the ROI manager.
> >
> > I have now tried to use Overlay instead as suggested by Wayne, and to
> > some extent it works, but I cannot quite obtain the information I
> > want, which is a list of the pixels in the detected particle.
> >
> >
> > I have used the following:
> >
> > run("Analyze Particles...", "size=25-Infinity show=[Overlay Masks]
> > include record ");
> >
> > nblobs=Overlay.size;
> > print ("nblobs="+nblobs);
> >
> > for (blob=0;blob<nblobs;blob++){
> >     Overlay.activateSelection(blob);
> >      bname=Roi.getName;
> >     Roi.getCoordinates(xp,yp);
> >     for (i=0;i&lt;xp.length;i++){
> >       print(blob,bname,xp[i],yp[i]);
> >     }
> > }
> >
> >
> >
> >
> > This seems to behave, but the actual list returned does not make sense
> > to me and doesn't seem to correspond to the overlay as observed in the
> > image viewer. Is it actually a list of some other description of the
> > particle rather than the coordinates, and the number somehow not
> > correspond to the number printed in the overlay label output?
> >
> > For example, blob #39 is listed as follows, but the attached image (I
> > hope) shows a blob that certainly has more than 4 pixels in it, and is
> > not anywhere near co-ordinate 3214. Furthermore the co-ordinates
> > listed do not form a connected object, it seems like the corners of a 5 pixel
> square.
> >   &lt;nabble_img src=&quot;imagej_blobnumber.jpg&quot;
> > border=&quot;0&quot;/>
> >
> >
> >   38  1095 55
> >   38  1100 55
> > *
> >   39  3214 60
> >   39  3207 60
> >   39  3207 55
> >   39  3214 55
> > *
> >   40  1729 57
> >
> >
> > What I really want is a list of horizontal start- and end-points for
> > each row passing through the blob. From a list of all pixels in each blob I
> can
> > generate this fairly simply   -- or is there another way to do that inside
> > imagej already? -- but I want to do it headless on a cluster and use
> > some quite nice and not so simple processing that is already available
> > in ImageJ even before the particle analysis.
> >
> >
> > Thanks
> > Robert
> >
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> > http://imagej.1557.x6.nabble.com/Roi-Manager-headless-mode-
> tp5011750p5
> > 015434.html Sent from the ImageJ mailing list archive at Nabble.com.
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Roi Manager headless mode

Michael Schmid
Hi Robert,

using the 'Blobs' sample image with the default threshold, your macro for printing the coordinates works perfectly well.

Note that the particles are numbered, e.g. 1-60, which is the 'natural' numbering that a user would expect.
Nevertheless, the index 'blobs' runs from 0-59 (starting at 0 is the usual convention in Java and ImageJ; with the numbering stack slices in ImageJ being the only exception).
So it is fine that the particle displayed as '1' is addressed by activateSelection(0).
Simply use your macro's index + 1 to get the corresponding label in the image.

Michael
________________________________________________________________
On Jan 22, 2016, at 19:43, Robert Atwood wrote:

> .. and it seems that index flips from 0 to 1 at some point so activateSelection(0) refers to the particle numbered 1 on the overlay :(
>
> Oh well , back to the 'drawing' board .. and it's so close to what I want ..
>
>
>
>
>> -----Original Message-----
>> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
>> Herbie
>> Sent: 22 January 2016 16:01
>> To: [hidden email]
>> Subject: Re: Roi Manager headless mode
>>
>> Dear Robert,
>>
>> I'm not very familiar with "Analyze Particles..." but a quick test with a single
>> elliptic test particle revealed that
>>
>> Roi.getCoordinates(xp,yp);
>>
>> actually returns all co-ordinates of the enclosing contour.
>>
>> So I guess, in order to get the content of the ROI you have either to extract i.e.
>> copy it, or access the content values pixel by pixel wise according to the
>> contour co-ordinates.
>>
>> HTH
>>
>> Herbie
>>
>> :::::::::::::::::::::::::::::::::::::::::::
>> Am 22.01.16 um 14:36 schrieb robert atwood:
>>> Hi All
>>> I came across this thread when trying to extract the detected
>>> particles into a master program using headless mode to call Imagej ,
>>> and encountering the similar problem with the ROI manager.
>>>
>>> I have now tried to use Overlay instead as suggested by Wayne, and to
>>> some extent it works, but I cannot quite obtain the information I
>>> want, which is a list of the pixels in the detected particle.
>>>
>>>
>>> I have used the following:
>>>
>>> run("Analyze Particles...", "size=25-Infinity show=[Overlay Masks]
>>> include record ");
>>>
>>> nblobs=Overlay.size;
>>> print ("nblobs="+nblobs);
>>>
>>> for (blob=0;blob<nblobs;blob++){
>>>    Overlay.activateSelection(blob);
>>>     bname=Roi.getName;
>>>    Roi.getCoordinates(xp,yp);
>>>    for (i=0;i&lt;xp.length;i++){
>>>      print(blob,bname,xp[i],yp[i]);
>>>    }
>>> }
>>>
>>>
>>>
>>>
>>> This seems to behave, but the actual list returned does not make sense
>>> to me and doesn't seem to correspond to the overlay as observed in the
>>> image viewer. Is it actually a list of some other description of the
>>> particle rather than the coordinates, and the number somehow not
>>> correspond to the number printed in the overlay label output?
>>>
>>> For example, blob #39 is listed as follows, but the attached image (I
>>> hope) shows a blob that certainly has more than 4 pixels in it, and is
>>> not anywhere near co-ordinate 3214. Furthermore the co-ordinates
>>> listed do not form a connected object, it seems like the corners of a 5 pixel
>> square.
>>>  &lt;nabble_img src=&quot;imagej_blobnumber.jpg&quot;
>>> border=&quot;0&quot;/>
>>>
>>>
>>>  38  1095 55
>>>  38  1100 55
>>> *
>>>  39  3214 60
>>>  39  3207 60
>>>  39  3207 55
>>>  39  3214 55
>>> *
>>>  40  1729 57
>>>
>>>
>>> What I really want is a list of horizontal start- and end-points for
>>> each row passing through the blob. From a list of all pixels in each blob I
>> can
>>> generate this fairly simply   -- or is there another way to do that inside
>>> imagej already? -- but I want to do it headless on a cluster and use
>>> some quite nice and not so simple processing that is already available
>>> in ImageJ even before the particle analysis.
>>>
>>>
>>> Thanks
>>> Robert
>>>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html