Get and Set Image Properties

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

Get and Set Image Properties

Gabriel Landini
Hi,
With this plugin:

http://rsbweb.nih.gov/ij/plugins/imp-props.html

one can set and get properties to an ImagePlus.
Am I correct in the assumption that these properties are not saved anywhere
and destroyed as one closes the ImagePlus? (I realised that they are not saved
in the tiff headers if one saves the image with set properties).

Also is there a way from the macro language to list all the properties already
set in a particular image?

Many thanks

G.
Reply | Threaded
Open this post in threaded view
|

Re: Get and Set Image Properties

Rasband, Wayne (NIH/NIMH) [E]
On Apr 29, 2010, at 12:29 PM, Gabriel Landini wrote:

> Hi,
> With this plugin:
>
> http://rsbweb.nih.gov/ij/plugins/imp-props.html
>
> one can set and get properties to an ImagePlus.
> Am I correct in the assumption that these properties are not saved anywhere
> and destroyed as one closes the ImagePlus? (I realised that they are not saved
> in the tiff headers if one saves the image with set properties).
>
> Also is there a way from the macro language to list all the properties already
> set in a particular image?
>
> Many thanks

The "Info" property (a string) is saved in the TIFF header and the setMetadata() and getMetadata() macro functions can be used to save and restore it. Multiple key/value pairs can be saved as an "Info" property by using the List.* macro functions. Here is an example:

  List.clear;
  List.set("Name", getTitle);
  List.set("Dir", getDirectory("image"));
  List.set("Size", getWidth*getHeight);
  setMetadata("Info", List.getList);
  path = getDirectory("temp")+"test.tif";
  saveAs("tif", path);
  close;
  open(path);
  properties = getMetadata("Info");
  List.setList(properties);
  print("Name: "+List.get("Name"));
  print("Dir: "+List.get("Dir"));
  print("Size: "+List.get("Size"));

-wayne
Reply | Threaded
Open this post in threaded view
|

Conserving ROIs

Zachary Freyberg
Hi all,
I've been trying to compare changes in puncta intensity in a specific  
ROI within a region of brain before and after tissue treatment. One  
problem that I've encountered is trying to copy the exact same ROI  
that I've traced around my anatomic region of interest (in the before  
image) to precisely the same place in the after image (assuming that  
both are perfectly registered of course) so that I could compare the  
region. Therefore, does anybody have a sense of how to copy the  
free-hand drawn ROI from the before image to the after image? Any  
thoughts are much appreciated.

Best,
Zach Freyberg
Reply | Threaded
Open this post in threaded view
|

Re: Conserving ROIs

Aryeh Weiss
Zachary Freyberg wrote:

> Hi all,
> I've been trying to compare changes in puncta intensity in a specific
> ROI within a region of brain before and after tissue treatment. One
> problem that I've encountered is trying to copy the exact same ROI that
> I've traced around my anatomic region of interest (in the before image)
> to precisely the same place in the after image (assuming that both are
> perfectly registered of course) so that I could compare the region.
> Therefore, does anybody have a sense of how to copy the free-hand drawn
> ROI from the before image to the after image? Any thoughts are much
> appreciated.
>
> Best,
> Zach Freyberg
>

Have you tried the ROI manager (analyze-->tools-->ROI manager... )?

--aryeh
--
Aryeh Weiss
School of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051
Reply | Threaded
Open this post in threaded view
|

Re: Get and Set Image Properties

Gabriel Landini
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
On Thursday 29 Apr 2010  16:57:28 you wrote:
> The "Info" property (a string) is saved in the TIFF header and the
> setMetadata() and getMetadata() macro functions can be used to save and
> restore it. Multiple key/value pairs can be saved as an "Info" property by
> using the List.* macro functions. Here is an example:

Thanks Wayne.
I see now that one can get the Info key through ImProps plugin as well.

Is there a way of getting  the list of all the key names associated to an
ImagePlus (that includes the "Info" property name as well as the other key
names set with ImProps)?

I guess there is no way of doing this?

Many thanks

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Get and Set Image Properties

Michael Schmid
Hi Gabriel,

you don't need a List.getKeys() macro function (though it would be  
nice to have one), it is just a few lines of macro code:

//properties is the String from getMetadata that you feed into  
List.setList

propArray=split(properties,"\n");
keyArray=newArray(lengthOf(propArray));
for (i=0; i<lengthOf(propArray); i++) {
   keyAndValue=split(propArray[i],"=");
   keyArray[i]=keyAndValue[0];
}

Keys and values must not contain commas, linefeed or '=' characters.

Michael
________________________________________________________________

On 30 Apr 2010, at 18:04, Gabriel Landini wrote:

> On Thursday 29 Apr 2010  16:57:28 you wrote:
>> The "Info" property (a string) is saved in the TIFF header and the
>> setMetadata() and getMetadata() macro functions can be used to  
>> save and
>> restore it. Multiple key/value pairs can be saved as an "Info"  
>> property by
>> using the List.* macro functions. Here is an example:
>
> Thanks Wayne.
> I see now that one can get the Info key through ImProps plugin as  
> well.
>
> Is there a way of getting  the list of all the key names associated  
> to an
> ImagePlus (that includes the "Info" property name as well as the  
> other key
> names set with ImProps)?
>
> I guess there is no way of doing this?
>
> Many thanks
>
> Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Get and Set Image Properties

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Gabriel Landini
On Apr 30, 2010, at 12:04 PM, Gabriel Landini wrote:

> On Thursday 29 Apr 2010  16:57:28 you wrote:
>> The "Info" property (a string) is saved in the TIFF header and the
>> setMetadata() and getMetadata() macro functions can be used to save and
>> restore it. Multiple key/value pairs can be saved as an "Info" property by
>> using the List.* macro functions. Here is an example:
>
> Thanks Wayne.
> I see now that one can get the Info key through ImProps plugin as well.
>
> Is there a way of getting  the list of all the key names associated to an
> ImagePlus (that includes the "Info" property name as well as the other key
> names set with ImProps)?
>
> I guess there is no way of doing this?

You can get a list of all the keys in Java or JavaScript by calling ImagePlus.getProperties() and using enumeration to loop through the properties. Here is a JavaScript example:

  img = IJ.getImage();
  props = img.getProperties();
  e = props.propertyNames();
  while (e.hasMoreElements()) {
     key = e.nextElement();
     println(key);
  }

Note that only the "Info" property (a string) is easily accessible by macros, saved in the TIFF header and displayed by the Image>Show Info command.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Get and Set Image Properties

Gabriel Landini
In reply to this post by Michael Schmid
On Friday 30 April 2010 18:06:50 you wrote:
> you don't need a List.getKeys() macro function (though it would be
> nice to have one), it is just a few lines of macro code:

Thanks Michael & Wayne.
It was actually Wayne's solution what I was looking for (ie keys in addition
to the "Info" metadata one), now I realise that my question was perhaps a bit
obscure.
The issue was that ImpProps allows one to retrieve the contents of a property
(including the "Info" string) but one has to know in advance that the key
exists. Wayne script lists all the keys and that was what I was looking for.
Thanks again,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Conserving ROIs

Christine Labno
In reply to this post by Aryeh Weiss
Hi Zach,

Aryeh's suggestion will work, especially for multiple ROIs.  

A little bit easier way to transfer just one ROI is to draw
your region on one image, select the other image and choosing
the command Edit --> Selection --> Restore Selection (or
Ctrl+Shift+E for the keyboard shortcut).

Works like a dream for me.  
Best, Christine

---- Original message ----
>Date: Fri, 30 Apr 2010 06:53:38 +0300
>From: Aryeh Weiss <[hidden email]>  
>Subject: Re: Conserving ROIs  
>To: [hidden email]
>
>Zachary Freyberg wrote:
>> Hi all,
>> I've been trying to compare changes in puncta intensity in
a specific
>> ROI within a region of brain before and after tissue
treatment. One
>> problem that I've encountered is trying to copy the exact
same ROI that
>> I've traced around my anatomic region of interest (in the
before image)
>> to precisely the same place in the after image (assuming
that both are
>> perfectly registered of course) so that I could compare the
region.
>> Therefore, does anybody have a sense of how to copy the
free-hand drawn
>> ROI from the before image to the after image? Any thoughts
are much
>> appreciated.
>>
>> Best,
>> Zach Freyberg
>>
>
>Have you tried the ROI manager (analyze-->tools-->ROI
manager... )?

>
>--aryeh
>--
>Aryeh Weiss
>School of Engineering
>Bar Ilan University
>Ramat Gan 52900 Israel
>
>Ph:  972-3-5317638
>FAX: 972-3-7384051
Christine Labno, Ph.D.
Asst. Technical Director
Light Microscopy Core
University of Chicago
Office of Shared Research Facilities
Abbott 129
(773) 834-9040 (phone)

Please consider the environment before printing this email.