Login  Register

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

Posted by ctrueden on Apr 10, 2017; 6:06pm
URL: http://imagej.273.s1.nabble.com/Correct-Syntax-to-get-image-subtitle-in-python-scripting-language-tp5018489p5018493.html

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