Jython problem in Fiji

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

Jython problem in Fiji

Kota Miura
I am encountering a problem with Jython scripting with Fiji.
When I try to load a image from file system, IJ.opneImage nor ImagePlus
constructor returns the image, only shows them on desktop. Below is the
test script.

Is anyone seeing similar problem?
Has there been a solution already?

Cheers,
Kota

---

src = '/LSM/dualColor/W001_P001_T001.lsm'
imp = ImagePlus(src)
print "Class:", imp.getClass().getName()
print "Width", imp.getWidth()

imp = IJ.openImage(src)
print "Class:", imp.getClass().getName()
print "Width", imp.getWidth()

----------------


The output is:

Class: ij.ImagePlus
Width 0
Class:
  File "<iostream>", line 8, in <module>
AttributeError: 'NoneType' object has no attribute 'getClass'


--

-------------------------------------------------------------*Dr. Kota Miura*

Scientist & IT Engineer
Centre for Molecular and Cellular Imaging,
European Molecular Biology Laboratory
Meyerhofstr. 1
69117 Heidelberg
GERMANY

Tel +49 6221 387 404

http://cmci.embl.de
-------------------------------------------------------------

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

Re: Jython problem in Fiji

dscho
Hi Kota,

On Tue, 11 Jun 2013, Kota Miura wrote:

> I am encountering a problem with Jython scripting with Fiji.  When I try
> to load a image from file system, IJ.opneImage nor ImagePlus constructor
> returns the image, only shows them on desktop. Below is the test script.

It is most likely due to LSM_Reader not returning an ImagePlus (and .lsm
being handled by HandleExtraFileTypes which hands off to LSM_Reader).

Have you tried Bio-Formats instead?

Ciao,
Dscho

P.S.: Yes, I know, Bio-Formats is still quite slow with .lsm files.
However, there is substantial work going on in SCIFIO (which is basically
a redesign of Bio-Formats), including performance improvements. Stay
tuned.

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

Re: Jython problem in Fiji

Kota Miura
Hi Johannes,

thanks for the tip.
I tried with loci.plugins.BF but there seems to be some other problem.

As BF.openImagePlus(java.lang.String path) did not work, I tired to use
ImporterOptions but failed as well...

Do you have other suggestion, other class that could be usable?

Cheers,
Kota

---
from loci.plugins import BF
from loci.plugins.in import ImporterOptions
src = '/LSM/dualColor/W001_P001_T001.lsm'
io = ImporterOptions()
io.setLocation(src)
imps = BF.openImagePlus(io)
#print len(imps)

-------
Started tests.py at Tue Jun 11 19:53:19 CEST 2013
Traceback (most recent call last):
  File "<iostream>", line 4, in <module>
at loci.plugins.prefs.OptionsList.<init>(OptionsList.java:72)
at loci.plugins.prefs.OptionsList.<init>(OptionsList.java:66)
at loci.plugins.in.ImporterOptions.<init>(ImporterOptions.java:158)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:163)

java.lang.NoSuchMethodError: java.lang.NoSuchMethodError:
loci.common.IniTable.get(Ljava/lang/Object;)Ljava/lang/String;



On Tue, Jun 11, 2013 at 7:07 PM, Johannes Schindelin <
[hidden email]> wrote:

> Hi Kota,
>
> On Tue, 11 Jun 2013, Kota Miura wrote:
>
> > I am encountering a problem with Jython scripting with Fiji.  When I try
> > to load a image from file system, IJ.opneImage nor ImagePlus constructor
> > returns the image, only shows them on desktop. Below is the test script.
>
> It is most likely due to LSM_Reader not returning an ImagePlus (and .lsm
> being handled by HandleExtraFileTypes which hands off to LSM_Reader).
>
> Have you tried Bio-Formats instead?
>
> Ciao,
> Dscho
>
> P.S.: Yes, I know, Bio-Formats is still quite slow with .lsm files.
> However, there is substantial work going on in SCIFIO (which is basically
> a redesign of Bio-Formats), including performance improvements. Stay
> tuned.
>



--

-------------------------------------------------------------*Dr. Kota Miura*

Scientist & IT Engineer
Centre for Molecular and Cellular Imaging,
European Molecular Biology Laboratory
Meyerhofstr. 1
69117 Heidelberg
GERMANY

Tel +49 6221 387 404

Mobile +49 160 95001177

Fax +49 6221 387 512

http://cmci.embl.de
-------------------------------------------------------------

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

Re: Jython problem in Fiji

Kota Miura
In reply to this post by dscho
Hi Johannes + all,

I managed to load .lsm into Jyhton code in a bit lengthy way.

maybe one way of work around during LSM_Reader and SCIFIO being under
intensive upgrades.

the code is based on

https://github.com/openmicroscopy/bioformats/blob/v4.4.8/components/loci-plugins/utils/Read_Image.java

Thanks to Johannes for the tip!

By the way, I also tried using Jython installation in the pure ImageJ, but
somehow

import os

nor

import re

did not work. I have not explored any further.

Cheers,
Kota



----
from loci.plugins.util import ImageProcessorReader as IPR
from loci.formats import ChannelSeparator
from loci.plugins.util import LociPrefs
from ij import ImageStack

def openImp(src):
r = IPR(ChannelSeparator(LociPrefs.makeImageReader()))
r.setId(src)
num = r.getImageCount()
width = r.getSizeX()
height = r.getSizeY()
stack = ImageStack(width, height)
chs = r.getChannelDimLengths()[0]
slices = num / chs
print 'channels:',chs
for i in range(num):
ip = r.openProcessors(i)[0]
stack.addSlice(str(i + 1), ip)
imp =ImagePlus('tt', stack)
imp.setDimensions(chs, slices, 1)
return imp

src = '/LSM/dualColor/W001_P001_T001.lsm'
img = openImp(src)
img.show()





On Tue, Jun 11, 2013 at 7:07 PM, Johannes Schindelin <
[hidden email]> wrote:

> Hi Kota,
>
> On Tue, 11 Jun 2013, Kota Miura wrote:
>
> > I am encountering a problem with Jython scripting with Fiji.  When I try
> > to load a image from file system, IJ.opneImage nor ImagePlus constructor
> > returns the image, only shows them on desktop. Below is the test script.
>
> It is most likely due to LSM_Reader not returning an ImagePlus (and .lsm
> being handled by HandleExtraFileTypes which hands off to LSM_Reader).
>
> Have you tried Bio-Formats instead?
>
> Ciao,
> Dscho
>
> P.S.: Yes, I know, Bio-Formats is still quite slow with .lsm files.
> However, there is substantial work going on in SCIFIO (which is basically
> a redesign of Bio-Formats), including performance improvements. Stay
> tuned.
>



--

-------------------------------------------------------------*Dr. Kota Miura*

Scientist & IT Engineer
Centre for Molecular and Cellular Imaging,
European Molecular Biology Laboratory
Meyerhofstr. 1
69117 Heidelberg
GERMANY

Tel +49 6221 387 404

Mobile +49 160 95001177

Fax +49 6221 387 512

http://cmci.embl.de
-------------------------------------------------------------

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

Re: Jython problem in Fiji

ctrueden
In reply to this post by Kota Miura
Hi Kota,

> java.lang.NoSuchMethodError: java.lang.NoSuchMethodError:
> loci.common.IniTable.get(Ljava/lang/Object;)Ljava/lang/String;

This looks suspiciously similar to other recent Bio-Formats bug reports,
such as:
http://fiji.sc/bugzilla/show_bug.cgi?id=612

Are you sure your Fiji is fully up to date (i.e., Help > Update Fiji says
"Your Fiji is fully up to date!")?

Regards,
Curtis


On Tue, Jun 11, 2013 at 12:58 PM, Kota Miura <[hidden email]> wrote:

> Hi Johannes,
>
> thanks for the tip.
> I tried with loci.plugins.BF but there seems to be some other problem.
>
> As BF.openImagePlus(java.lang.String path) did not work, I tired to use
> ImporterOptions but failed as well...
>
> Do you have other suggestion, other class that could be usable?
>
> Cheers,
> Kota
>
> ---
> from loci.plugins import BF
> from loci.plugins.in import ImporterOptions
> src = '/LSM/dualColor/W001_P001_T001.lsm'
> io = ImporterOptions()
> io.setLocation(src)
> imps = BF.openImagePlus(io)
> #print len(imps)
>
> -------
> Started tests.py at Tue Jun 11 19:53:19 CEST 2013
> Traceback (most recent call last):
>   File "<iostream>", line 4, in <module>
> at loci.plugins.prefs.OptionsList.<init>(OptionsList.java:72)
> at loci.plugins.prefs.OptionsList.<init>(OptionsList.java:66)
> at loci.plugins.in.ImporterOptions.<init>(ImporterOptions.java:158)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
>
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
>
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at
>
> org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:163)
>
> java.lang.NoSuchMethodError: java.lang.NoSuchMethodError:
> loci.common.IniTable.get(Ljava/lang/Object;)Ljava/lang/String;
>
>
>
> On Tue, Jun 11, 2013 at 7:07 PM, Johannes Schindelin <
> [hidden email]> wrote:
>
> > Hi Kota,
> >
> > On Tue, 11 Jun 2013, Kota Miura wrote:
> >
> > > I am encountering a problem with Jython scripting with Fiji.  When I
> try
> > > to load a image from file system, IJ.opneImage nor ImagePlus
> constructor
> > > returns the image, only shows them on desktop. Below is the test
> script.
> >
> > It is most likely due to LSM_Reader not returning an ImagePlus (and .lsm
> > being handled by HandleExtraFileTypes which hands off to LSM_Reader).
> >
> > Have you tried Bio-Formats instead?
> >
> > Ciao,
> > Dscho
> >
> > P.S.: Yes, I know, Bio-Formats is still quite slow with .lsm files.
> > However, there is substantial work going on in SCIFIO (which is basically
> > a redesign of Bio-Formats), including performance improvements. Stay
> > tuned.
> >
>
>
>
> --
>
> -------------------------------------------------------------*Dr. Kota
> Miura*
>
> Scientist & IT Engineer
> Centre for Molecular and Cellular Imaging,
> European Molecular Biology Laboratory
> Meyerhofstr. 1
> 69117 Heidelberg
> GERMANY
>
> Tel +49 6221 387 404
>
> Mobile +49 160 95001177
>
> Fax +49 6221 387 512
>
> http://cmci.embl.de
> -------------------------------------------------------------
>
> --
> ImageJ mailing list: 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: Jython problem in Fiji

Kota Miura
Hi Curtis,

Indeed, the code below works after removing scifio-devel-4.5-SNAPSHOT.jar
and updating.

from loci.plugins import BF
src = '/LSM/dualColor/W001_P001_T001.lsm'
imps = BF.openImagePlus(src)
imps[0].show()

thanks!
Kota


On Tue, Jun 11, 2013 at 9:18 PM, Curtis Rueden <[hidden email]> wrote:

> Hi Kota,
>
> > java.lang.NoSuchMethodError: java.lang.NoSuchMethodError:
> > loci.common.IniTable.get(Ljava/lang/Object;)Ljava/lang/String;
>
> This looks suspiciously similar to other recent Bio-Formats bug reports,
> such as:
> http://fiji.sc/bugzilla/show_bug.cgi?id=612
>
> Are you sure your Fiji is fully up to date (i.e., Help > Update Fiji says
> "Your Fiji is fully up to date!")?
>
> Regards,
> Curtis
>
>
> On Tue, Jun 11, 2013 at 12:58 PM, Kota Miura <[hidden email]> wrote:
>
>> Hi Johannes,
>>
>> thanks for the tip.
>> I tried with loci.plugins.BF but there seems to be some other problem.
>>
>> As BF.openImagePlus(java.lang.String path) did not work, I tired to use
>> ImporterOptions but failed as well...
>>
>> Do you have other suggestion, other class that could be usable?
>>
>> Cheers,
>> Kota
>>
>> ---
>> from loci.plugins import BF
>> from loci.plugins.in import ImporterOptions
>> src = '/LSM/dualColor/W001_P001_T001.lsm'
>> io = ImporterOptions()
>> io.setLocation(src)
>> imps = BF.openImagePlus(io)
>> #print len(imps)
>>
>> -------
>> Started tests.py at Tue Jun 11 19:53:19 CEST 2013
>> Traceback (most recent call last):
>>   File "<iostream>", line 4, in <module>
>> at loci.plugins.prefs.OptionsList.<init>(OptionsList.java:72)
>> at loci.plugins.prefs.OptionsList.<init>(OptionsList.java:66)
>> at loci.plugins.in.ImporterOptions.<init>(ImporterOptions.java:158)
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>> at
>>
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>> at
>>
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>> at
>>
>> org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:163)
>>
>> java.lang.NoSuchMethodError: java.lang.NoSuchMethodError:
>> loci.common.IniTable.get(Ljava/lang/Object;)Ljava/lang/String;
>>
>>
>>
>> On Tue, Jun 11, 2013 at 7:07 PM, Johannes Schindelin <
>> [hidden email]> wrote:
>>
>> > Hi Kota,
>> >
>> > On Tue, 11 Jun 2013, Kota Miura wrote:
>> >
>> > > I am encountering a problem with Jython scripting with Fiji.  When I
>> try
>> > > to load a image from file system, IJ.opneImage nor ImagePlus
>> constructor
>> > > returns the image, only shows them on desktop. Below is the test
>> script.
>> >
>> > It is most likely due to LSM_Reader not returning an ImagePlus (and .lsm
>> > being handled by HandleExtraFileTypes which hands off to LSM_Reader).
>> >
>> > Have you tried Bio-Formats instead?
>> >
>> > Ciao,
>> > Dscho
>> >
>> > P.S.: Yes, I know, Bio-Formats is still quite slow with .lsm files.
>> > However, there is substantial work going on in SCIFIO (which is
>> basically
>> > a redesign of Bio-Formats), including performance improvements. Stay
>> > tuned.
>> >
>>
>>
>>
>> --
>>
>> -------------------------------------------------------------*Dr. Kota
>> Miura*
>>
>>
>> Scientist & IT Engineer
>> Centre for Molecular and Cellular Imaging,
>> European Molecular Biology Laboratory
>> Meyerhofstr. 1
>> 69117 Heidelberg
>> GERMANY
>>
>> Tel +49 6221 387 404
>>
>> Mobile +49 160 95001177
>>
>> Fax +49 6221 387 512
>>
>> http://cmci.embl.de
>> -------------------------------------------------------------
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
>


--

-------------------------------------------------------------*Dr. Kota Miura*

Scientist & IT Engineer
Centre for Molecular and Cellular Imaging,
European Molecular Biology Laboratory
Meyerhofstr. 1
69117 Heidelberg
GERMANY

Tel +49 6221 387 404

Mobile +49 160 95001177

Fax +49 6221 387 512

http://cmci.embl.de
-------------------------------------------------------------

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