Quantcast

Correct Syntax to get image subtitle in python scripting language

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
GP
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Correct Syntax to get image subtitle in python scripting language

GP
Hie!

I am attempting to convert my .ijm script to python/jython and am a super beginner in the field.

In the script I extract subtitle of one the images in a step by using :: getMetadata("Label") command but am unable to find the correct syntax to use it in python script.
I tried the other mentioned subtitle commands as well : getInfo("image.subtitle") etc as by adding prefix 'IJ.run' or 'imp.' as follows::

imp = IJ.getImage()
IJ.run (imp, getMetadata("Label") or
subtitle = imp.getMetadata("Label")

Please let me know about the correct way to perform this action or if any specific library needs to be downloaded to do so. It works perfect for imp.getTitle() command.
I was not able to find the answer to it please redirect me if the question has been solved earlier.

Thanks a lot!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Correct Syntax to get image subtitle in python scripting language

ctrueden
Hi,

> In the script I extract subtitle of one the images in a step by using
> :: getMetadata("Label") command but am unable to find the correct
> syntax to use it in python script.

Unfortunately, macro functions do not always have a direct corollary in the
Java/scripting API.

What you can do is read the code which defines how the macro language
functions work. In the case of getMetadata, it is here:


https://github.com/imagej/ImageJA/blob/v1.51k/src/main/java/ij/macro/Functions.java#L3715-L3740

In this case, we can see several calls which might do the trick for you:

  metadata = imp.getProperty("Label");
  metadata = imp.getProperty("Info");
  metadata = imp.getStack().getSliceLabel(imp.getCurrentSlice());

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Mon, Apr 10, 2017 at 11:17 AM, GP <[hidden email]> wrote:

> Hie!
>
> I am attempting to convert my .ijm script to python/jython and am a super
> beginner in the field.
>
> In the script I extract subtitle of one the images in a step by using ::
> getMetadata("Label") command but am unable to find the correct syntax to
> use
> it in python script.
> I tried the other mentioned subtitle commands as well :
> getInfo("image.subtitle") etc as by adding prefix 'IJ.run' or 'imp.' as
> follows::
>
> imp = IJ.getImage()
> IJ.run (imp, getMetadata("Label") or
> subtitle = imp.getMetadata("Label")
>
> Please let me know about the correct way to perform this action or if any
> specific library needs to be downloaded to do so. It works perfect for
> imp.getTitle() command.
> I was not able to find the answer to it please redirect me if the question
> has been solved earlier.
>
> Thanks a lot!
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.
> com/Correct-Syntax-to-get-image-subtitle-in-python-
> scripting-language-tp5018489.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
GP
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Correct Syntax to get image subtitle in python scripting language

GP
Hie!

Thank you so much for the link, it's super helpful and  
 "    metadata = imp.getProperty("Label")    "  works perfect to get the subtitle. 

Best Regards,


On Mon, Apr 10, 2017 at 8:17 PM, ctrueden [via ImageJ] <[hidden email]> wrote:
Hi,

> In the script I extract subtitle of one the images in a step by using
> :: getMetadata("Label") command but am unable to find the correct
> syntax to use it in python script.

Unfortunately, macro functions do not always have a direct corollary in the
Java/scripting API.

What you can do is read the code which defines how the macro language
functions work. In the case of getMetadata, it is here:


https://github.com/imagej/ImageJA/blob/v1.51k/src/main/java/ij/macro/Functions.java#L3715-L3740

In this case, we can see several calls which might do the trick for you:

  metadata = imp.getProperty("Label");
  metadata = imp.getProperty("Info");
  metadata = imp.getStack().getSliceLabel(imp.getCurrentSlice());

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Mon, Apr 10, 2017 at 11:17 AM, GP <[hidden email]> wrote:

> Hie!
>
> I am attempting to convert my .ijm script to python/jython and am a super
> beginner in the field.
>
> In the script I extract subtitle of one the images in a step by using ::
> getMetadata("Label") command but am unable to find the correct syntax to
> use
> it in python script.
> I tried the other mentioned subtitle commands as well :
> getInfo("image.subtitle") etc as by adding prefix 'IJ.run' or 'imp.' as
> follows::
>
> imp = IJ.getImage()
> IJ.run (imp, getMetadata("Label") or
> subtitle = imp.getMetadata("Label")
>
> Please let me know about the correct way to perform this action or if any
> specific library needs to be downloaded to do so. It works perfect for
> imp.getTitle() command.
> I was not able to find the answer to it please redirect me if the question
> has been solved earlier.
>
> Thanks a lot!
>
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.
> com/Correct-Syntax-to-get-image-subtitle-in-python-
> scripting-language-tp5018489.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



If you reply to this email, your message will be added to the discussion below:
http://imagej.1557.x6.nabble.com/Correct-Syntax-to-get-image-subtitle-in-python-scripting-language-tp5018489p5018493.html
To unsubscribe from Correct Syntax to get image subtitle in python scripting language, click here.
NAML



--
Gunjan Pandey

Loading...