String from textROI?

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

String from textROI?

ChrisH
As an ImageJ 'newbie' my apologies if I have missed an obvious solution to my question:
I have written a plugin that automatically adds supplemental information to each image in a (hyper)stack by adding textROI's  using .setPosition to an overlay.  This is doing what I hoped - the overlay is saved in the tiff file of the stack and so this additional metadata is displayed when the stack is opened. However I am having difficulty trying to 'recover' the information from the overlay - the .getText() method will generate a String from a textRoi, but I am having a tough time figuring out how to recover the textRoi from the overlay. Using Overlay.get(int) returns an ROI, but only of type Rectangle, not the 'original' TextRoi, and so the.getText() method fails.

Is there a way to recover the textROI's from each image in the overlay or is there another way I can efficiently combine both the visual and metadata labeling?

I appreciate any suggestions!


Chris H
Reply | Threaded
Open this post in threaded view
|

Re: String from textROI?

dscho
Hi ChrisH,

On Mon, 23 Jan 2012, ChrisH wrote:

> I have written a plugin that automatically adds supplemental information to
> each image in a (hyper)stack by adding textROI's  using .setPosition to an
> overlay.  This is doing what I hoped - the overlay is saved in the tiff file
> of the stack and so this additional metadata is displayed when the stack is
> opened. However I am having difficulty trying to 'recover' the information
> from the overlay - the .getText() method will generate a String from a
> textRoi, but I am having a tough time figuring out how to recover the
> textRoi from the overlay. Using Overlay.get(int) returns an ROI, but only of
> type Rectangle, not the 'original' TextRoi, and so the.getText() method
> fails.

You probably want to store metadata in the "Info" property of the image
anyway (storing metadata not as metadata -- which the "Info" property
represents -- but instead in an Overlay which just happens to be stored
when you save as Tiff is a bit, uhm, fragile).

This property is saved together with other metadata when you save the
image.

An example how to set the "Info" property:

        http://fiji.sc/Functions.java#l3181

But keep in mind that there might be such a property already which you
should _append_ to, not replace.

Ciao,
Johannes
Reply | Threaded
Open this post in threaded view
|

RE: String from textROI?

ChrisH

Hello Johannes - Thanks for the quick reply.

I had earlier tried using the setMetadata and getMetadata macros, but my hyperstacks have quite a lot of associated metadata for each slice such that the label in the Image display is physically too small to display it. The result is that some of my metadata and most of the ‘normal’ info in the Label is pushed off the window frame after adding my metadata. I don’t see an option to have a multi-line Label, but that could be a solution if there is a way to do that.

 

Absent other  options I could presumably store my additional metadata in the Label as you suggest, then get that data for each Image and build the overlay on the fly to provide the display, but then the ‘normal’ Label info displayed on the window header will still be off the frame so I’d have to add that to the overlay also...

 

I had hoped I could kill 2 birds with one stone and just use (potentially fragile!) overlays with multi-line textRoi’s to handle both the display and to hold the metadata. Presently that approach seems to be working well except for the problem of getting the textRoi back from the overlay using the Overlay.get() method. A work-around for that would be great but maybe there isn’t one.

 

Again, thanks for your advice ( and the link to the functions/macros – how come I hadn’t found that yet!?)

 

Chris H

 

 

From: Johannes Schindelin [via ImageJ] [mailto:ml-node+[hidden email]]
Sent: 23 January, 2012 9:35 AM
To: Harrison, Christopher (CHJH)
Subject: Re: String from textROI?

 

Hi ChrisH,

On Mon, 23 Jan 2012, ChrisH wrote:


> I have written a plugin that automatically adds supplemental information to
> each image in a (hyper)stack by adding textROI's  using .setPosition to an
> overlay.  This is doing what I hoped - the overlay is saved in the tiff file
> of the stack and so this additional metadata is displayed when the stack is
> opened. However I am having difficulty trying to 'recover' the information
> from the overlay - the .getText() method will generate a String from a
> textRoi, but I am having a tough time figuring out how to recover the
> textRoi from the overlay. Using Overlay.get(int) returns an ROI, but only of
> type Rectangle, not the 'original' TextRoi, and so the.getText() method
> fails.


You probably want to store metadata in the "Info" property of the image
anyway (storing metadata not as metadata -- which the "Info" property
represents -- but instead in an Overlay which just happens to be stored
when you save as Tiff is a bit, uhm, fragile).

This property is saved together with other metadata when you save the
image.

An example how to set the "Info" property:

        http://fiji.sc/Functions.java#l3181

But keep in mind that there might be such a property already which you
should _append_ to, not replace.

Ciao,
Johannes


If you reply to this email, your message will be added to the discussion below:

http://imagej.1557.n6.nabble.com/String-from-textROI-tp4332880p4333044.html

To unsubscribe from String from textROI?, click here.
NAML