bioformats plugins form Python

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

bioformats plugins form Python

Aryeh Weiss
I am trying to "step up" from doing all of my work with the macro
language to writing my scripts in Python. In part this is because I
think it is easier to learn, in part because I have some exposure
already to it, and in part because I found Albert Cardona's excellent
tutorial. My approach is to take some macro code which I already have,
and translate it to Python.

Problem is, I started with a macro which requires the use Bioformats
macro extensions, in order to determine the number of series (ie,
fields) in a multifield image file (nd2 in my case).
The relevant macro command is:
Ext.getSeriesCount(seriesCount);

I also need to be able to set options for the bioformats file opener.

I found some sample Java code that doe this, and I naively tried to do
something similar in my Python script (ie, import the same libraries and
use the same classes). No go.
I found a similar question asked previously on the Omero list, but I did
not understand how to implement the suggestions given there.

So, my questions are:

1. Is there a simple way (ok, simple for a non-developer) to call
bioformats from the Python interpreter, and to set the arguments for the
openImage function?

2. Is there a way to open images which openImage sends to the bioformats
importer without getting the interactive dialog?
I tried:
IJ.run(imp, "Bio-Formats Importer", "--argument string---"), but it did
not like whatever I put in for imp (some imagePlus)
(Sorry if that seems silly -- I tried all sorts of things so that I
might understand it better before I posted my question.)

3. Can someone tell me how to find the number of series (fields)  in the
metadata  of an nd2 file. I can get other parameters from the imagePlus
methods. I had asked this previously, when I wrote the macro

If bioformats can work with the Python interpreter, then I would greatly
appreciate an simple example (like that image read example that I found
for Java).

I should add that I am working with the Fiji distribution, and the
script editor in that distribution.

Thank in advance
--aryeh
--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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

Re: bioformats plugins form Python

ctrueden
Hi Aryeh,

> I am trying to "step up" from doing all of my work with the macro
> language to writing my scripts in Python.

Here is an example script which I hope can get you started with Bio-Formats
in Jython:

https://gist.github.com/ctrueden/6282856

Please write back if you have more questions on how to accomplish specific
tasks.

Regards,
Curtis


On Tue, Aug 20, 2013 at 9:17 AM, Aryeh Weiss <[hidden email]> wrote:

> I am trying to "step up" from doing all of my work with the macro language
> to writing my scripts in Python. In part this is because I think it is
> easier to learn, in part because I have some exposure already to it, and in
> part because I found Albert Cardona's excellent tutorial. My approach is to
> take some macro code which I already have, and translate it to Python.
>
> Problem is, I started with a macro which requires the use Bioformats macro
> extensions, in order to determine the number of series (ie, fields) in a
> multifield image file (nd2 in my case).
> The relevant macro command is:
> Ext.getSeriesCount(**seriesCount);
>
> I also need to be able to set options for the bioformats file opener.
>
> I found some sample Java code that doe this, and I naively tried to do
> something similar in my Python script (ie, import the same libraries and
> use the same classes). No go.
> I found a similar question asked previously on the Omero list, but I did
> not understand how to implement the suggestions given there.
>
> So, my questions are:
>
> 1. Is there a simple way (ok, simple for a non-developer) to call
> bioformats from the Python interpreter, and to set the arguments for the
> openImage function?
>
> 2. Is there a way to open images which openImage sends to the bioformats
> importer without getting the interactive dialog?
> I tried:
> IJ.run(imp, "Bio-Formats Importer", "--argument string---"), but it did
> not like whatever I put in for imp (some imagePlus)
> (Sorry if that seems silly -- I tried all sorts of things so that I might
> understand it better before I posted my question.)
>
> 3. Can someone tell me how to find the number of series (fields)  in the
> metadata  of an nd2 file. I can get other parameters from the imagePlus
> methods. I had asked this previously, when I wrote the macro
>
> If bioformats can work with the Python interpreter, then I would greatly
> appreciate an simple example (like that image read example that I found for
> Java).
>
> I should add that I am working with the Fiji distribution, and the script
> editor in that distribution.
>
> Thank in advance
> --aryeh
> --
> Aryeh Weiss
> Faculty of Engineering
> Bar Ilan University
> Ramat Gan 52900 Israel
>
> Ph:  972-3-5317638
> FAX: 972-3-7384051
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.**html<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: bioformats plugins form Python

Aryeh Weiss
Hi Curtis,

Thank you for your quick reply.

On 8/20/13 6:19 PM, Curtis Rueden wrote:

> Hi Aryeh,
>
>  > I am trying to "step up" from doing all of my work with the macro
>  > language to writing my scripts in Python.
>
> Here is an example script which I hope can get you started with
> Bio-Formats in Jython:
>
> https://gist.github.com/ctrueden/6282856
>
> Please write back if you have more questions on how to accomplish
> specific tasks.
>

This works, and exactly solves my problem.
Is there API documentation that lists all of the classes and methods in
options, reader, etc? When I was looking for how to set the option for
reading all series, I found it in the source

http://dev.loci.wisc.edu/trac/software/browser/trunk/loci/plugins/ImporterOptions.java?rev=3960

but I wonder if there is something like what we have for the ImageJ API.

Best regards,
--aryeh


>
> On Tue, Aug 20, 2013 at 9:17 AM, Aryeh Weiss <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     I am trying to "step up" from doing all of my work with the macro
>     language to writing my scripts in Python. In part this is because I
>     think it is easier to learn, in part because I have some exposure
>     already to it, and in part because I found Albert Cardona's
>     excellent tutorial. My approach is to take some macro code which I
>     already have, and translate it to Python.
>
>     Problem is, I started with a macro which requires the use Bioformats
>     macro extensions, in order to determine the number of series (ie,
>     fields) in a multifield image file (nd2 in my case).
>     The relevant macro command is:
>     Ext.getSeriesCount(__seriesCount);
>
>     I also need to be able to set options for the bioformats file opener.
>
>     I found some sample Java code that doe this, and I naively tried to
>     do something similar in my Python script (ie, import the same
>     libraries and use the same classes). No go.
>     I found a similar question asked previously on the Omero list, but I
>     did not understand how to implement the suggestions given there.
>
>     So, my questions are:
>
>     1. Is there a simple way (ok, simple for a non-developer) to call
>     bioformats from the Python interpreter, and to set the arguments for
>     the openImage function?
>
>     2. Is there a way to open images which openImage sends to the
>     bioformats importer without getting the interactive dialog?
>     I tried:
>     IJ.run(imp, "Bio-Formats Importer", "--argument string---"), but it
>     did not like whatever I put in for imp (some imagePlus)
>     (Sorry if that seems silly -- I tried all sorts of things so that I
>     might understand it better before I posted my question.)
>
>     3. Can someone tell me how to find the number of series (fields)  in
>     the metadata  of an nd2 file. I can get other parameters from the
>     imagePlus methods. I had asked this previously, when I wrote the macro
>
>     If bioformats can work with the Python interpreter, then I would
>     greatly appreciate an simple example (like that image read example
>     that I found for Java).
>
>     I should add that I am working with the Fiji distribution, and the
>     script editor in that distribution.
>
>     Thank in advance
>     --aryeh
>     --
>     Aryeh Weiss
>     Faculty of Engineering
>     Bar Ilan University
>     Ramat Gan 52900 Israel
>
>     Ph:  972-3-5317638
>     FAX: 972-3-7384051
>
>     --
>     ImageJ mailing list: http://imagej.nih.gov/ij/list.__html
>     <http://imagej.nih.gov/ij/list.html>
>
>


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

Ph:  972-3-5317638
FAX: 972-3-7384051

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

Re: bioformats plugins form Python

ctrueden
Hi Aryeh,

> Is there API documentation that lists all of the classes and methods
> in options, reader, etc?

Bio-Formats Javadoc is available at:
http://hudson.openmicroscopy.org.uk/job/BIOFORMATS-stable/javadoc/

There is are "Examples of Usage" for developers available at:
http://openmicroscopy.org/site/support/bio-formats4/developers/java-library.html#examples-of-usage

And the Bio-Formats ImageJ page is somewhat informative:
http://openmicroscopy.org/site/support/bio-formats4/users/imagej/

But overall, it is unfortunately not as thorough or well laid out as the
core ImageJ documentation.

Suggestions for improvement welcome! (Please send to ome-users [1].)

Regards,
Curtis

[1] http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users/


On Tue, Aug 20, 2013 at 12:19 PM, Aryeh Weiss <[hidden email]> wrote:

> Hi Curtis,
>
> Thank you for your quick reply.
>
>
> On 8/20/13 6:19 PM, Curtis Rueden wrote:
>
>> Hi Aryeh,
>>
>>  > I am trying to "step up" from doing all of my work with the macro
>>  > language to writing my scripts in Python.
>>
>> Here is an example script which I hope can get you started with
>> Bio-Formats in Jython:
>>
>> https://gist.github.com/**ctrueden/6282856<https://gist.github.com/ctrueden/6282856>
>>
>> Please write back if you have more questions on how to accomplish
>> specific tasks.
>>
>>
> This works, and exactly solves my problem.
> Is there API documentation that lists all of the classes and methods in
> options, reader, etc? When I was looking for how to set the option for
> reading all series, I found it in the source
>
> http://dev.loci.wisc.edu/trac/**software/browser/trunk/loci/**
> plugins/ImporterOptions.java?**rev=3960<http://dev.loci.wisc.edu/trac/software/browser/trunk/loci/plugins/ImporterOptions.java?rev=3960>
>
> but I wonder if there is something like what we have for the ImageJ API.
>
> Best regards,
> --aryeh
>
>
>
>> On Tue, Aug 20, 2013 at 9:17 AM, Aryeh Weiss <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     I am trying to "step up" from doing all of my work with the macro
>>     language to writing my scripts in Python. In part this is because I
>>     think it is easier to learn, in part because I have some exposure
>>     already to it, and in part because I found Albert Cardona's
>>     excellent tutorial. My approach is to take some macro code which I
>>     already have, and translate it to Python.
>>
>>     Problem is, I started with a macro which requires the use Bioformats
>>     macro extensions, in order to determine the number of series (ie,
>>     fields) in a multifield image file (nd2 in my case).
>>     The relevant macro command is:
>>     Ext.getSeriesCount(__**seriesCount);
>>
>>
>>     I also need to be able to set options for the bioformats file opener.
>>
>>     I found some sample Java code that doe this, and I naively tried to
>>     do something similar in my Python script (ie, import the same
>>     libraries and use the same classes). No go.
>>     I found a similar question asked previously on the Omero list, but I
>>     did not understand how to implement the suggestions given there.
>>
>>     So, my questions are:
>>
>>     1. Is there a simple way (ok, simple for a non-developer) to call
>>     bioformats from the Python interpreter, and to set the arguments for
>>     the openImage function?
>>
>>     2. Is there a way to open images which openImage sends to the
>>     bioformats importer without getting the interactive dialog?
>>     I tried:
>>     IJ.run(imp, "Bio-Formats Importer", "--argument string---"), but it
>>     did not like whatever I put in for imp (some imagePlus)
>>     (Sorry if that seems silly -- I tried all sorts of things so that I
>>     might understand it better before I posted my question.)
>>
>>     3. Can someone tell me how to find the number of series (fields)  in
>>     the metadata  of an nd2 file. I can get other parameters from the
>>     imagePlus methods. I had asked this previously, when I wrote the macro
>>
>>     If bioformats can work with the Python interpreter, then I would
>>     greatly appreciate an simple example (like that image read example
>>     that I found for Java).
>>
>>     I should add that I am working with the Fiji distribution, and the
>>     script editor in that distribution.
>>
>>     Thank in advance
>>     --aryeh
>>     --
>>     Aryeh Weiss
>>     Faculty of Engineering
>>     Bar Ilan University
>>     Ramat Gan 52900 Israel
>>
>>     Ph:  972-3-5317638
>>     FAX: 972-3-7384051
>>
>>     --
>>     ImageJ mailing list: http://imagej.nih.gov/ij/list.**__html<http://imagej.nih.gov/ij/list.__html>
>>     <http://imagej.nih.gov/ij/**list.html<http://imagej.nih.gov/ij/list.html>
>> >
>>
>>
>>
>
> --
> Aryeh Weiss
> Faculty of Engineering
> Bar Ilan University
> Ramat Gan 52900 Israel
>
> Ph:  972-3-5317638
> FAX: 972-3-7384051
>
>

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

Re: bioformats plugins form Python

Aryeh Weiss
On 8/20/13 8:27 PM, Curtis Rueden wrote:

> Hi Aryeh,
>
>  > Is there API documentation that lists all of the classes and methods
>  > in options, reader, etc?
>
> Bio-Formats Javadoc is available at:
> http://hudson.openmicroscopy.org.uk/job/BIOFORMATS-stable/javadoc/
>
> There is are "Examples of Usage" for developers available at:
> http://openmicroscopy.org/site/support/bio-formats4/developers/java-library.html#examples-of-usage
>
> And the Bio-Formats ImageJ page is somewhat informative:
> http://openmicroscopy.org/site/support/bio-formats4/users/imagej/
>
> But overall, it is unfortunately not as thorough or well laid out as the
> core ImageJ documentation.
>
> Suggestions for improvement welcome! (Please send to ome-users [1].)
>
> Regards,
> Curtis
>
> [1] http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users/
>


Thank you -- the javadoc link is very useful, now that I know what to
look for.

I find examples (like the example whose link you sent) to be the single
most effect tool in getting started on this sort of adventure.

Best regards,
--aryeh


>
> On Tue, Aug 20, 2013 at 12:19 PM, Aryeh Weiss <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi Curtis,
>
>     Thank you for your quick reply.
>
>
>     On 8/20/13 6:19 PM, Curtis Rueden wrote:
>
>         Hi Aryeh,
>
>           > I am trying to "step up" from doing all of my work with the
>         macro
>           > language to writing my scripts in Python.
>
>         Here is an example script which I hope can get you started with
>         Bio-Formats in Jython:
>
>         https://gist.github.com/__ctrueden/6282856
>         <https://gist.github.com/ctrueden/6282856>
>
>         Please write back if you have more questions on how to accomplish
>         specific tasks.
>
>
>     This works, and exactly solves my problem.
>     Is there API documentation that lists all of the classes and methods
>     in options, reader, etc? When I was looking for how to set the
>     option for reading all series, I found it in the source
>
>     http://dev.loci.wisc.edu/trac/__software/browser/trunk/loci/__plugins/ImporterOptions.java?__rev=3960
>     <http://dev.loci.wisc.edu/trac/software/browser/trunk/loci/plugins/ImporterOptions.java?rev=3960>
>
>     but I wonder if there is something like what we have for the ImageJ API.
>
>     Best regards,
>     --aryeh
>
>
>
>         On Tue, Aug 20, 2013 at 9:17 AM, Aryeh Weiss
>         <[hidden email] <mailto:[hidden email]>
>         <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>
>              I am trying to "step up" from doing all of my work with the
>         macro
>              language to writing my scripts in Python. In part this is
>         because I
>              think it is easier to learn, in part because I have some
>         exposure
>              already to it, and in part because I found Albert Cardona's
>              excellent tutorial. My approach is to take some macro code
>         which I
>              already have, and translate it to Python.
>
>              Problem is, I started with a macro which requires the use
>         Bioformats
>              macro extensions, in order to determine the number of
>         series (ie,
>              fields) in a multifield image file (nd2 in my case).
>              The relevant macro command is:
>              Ext.getSeriesCount(____seriesCount);
>
>
>              I also need to be able to set options for the bioformats
>         file opener.
>
>              I found some sample Java code that doe this, and I naively
>         tried to
>              do something similar in my Python script (ie, import the same
>              libraries and use the same classes). No go.
>              I found a similar question asked previously on the Omero
>         list, but I
>              did not understand how to implement the suggestions given
>         there.
>
>              So, my questions are:
>
>              1. Is there a simple way (ok, simple for a non-developer)
>         to call
>              bioformats from the Python interpreter, and to set the
>         arguments for
>              the openImage function?
>
>              2. Is there a way to open images which openImage sends to the
>              bioformats importer without getting the interactive dialog?
>              I tried:
>              IJ.run(imp, "Bio-Formats Importer", "--argument
>         string---"), but it
>              did not like whatever I put in for imp (some imagePlus)
>              (Sorry if that seems silly -- I tried all sorts of things
>         so that I
>              might understand it better before I posted my question.)
>
>              3. Can someone tell me how to find the number of series
>         (fields)  in
>              the metadata  of an nd2 file. I can get other parameters
>         from the
>              imagePlus methods. I had asked this previously, when I
>         wrote the macro
>
>              If bioformats can work with the Python interpreter, then I
>         would
>              greatly appreciate an simple example (like that image read
>         example
>              that I found for Java).
>
>              I should add that I am working with the Fiji distribution,
>         and the
>              script editor in that distribution.
>
>              Thank in advance
>              --aryeh
>              --
>

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

Ph:  972-3-5317638
FAX: 972-3-7384051

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