imagej / pyimagej

Use ImageJ from Python
https://pyimagej.readthedocs.io/
Other
467 stars 81 forks source link

Using Plugins #67

Closed bhavaygg closed 4 years ago

bhavaygg commented 4 years ago

Hello,

I am trying to use XitoSBML plugin using the following code.

import imagej
ij = imagej.init('sc.fiji:fiji')
ij.getVersion()
from skimage import io
import numpy as np
from jnius import autoclass
WindowManager = autoclass('ij.XitoSBML')
img = io.imread('image1.jpg')
img = np.mean(img[500:1000,300:850], axis=2)
ij.py.show(img, cmap = 'gray')
Traceback (most recent call last):
  File "testnew2.py", line 2, in <module>
    ij = imagej.init('sc.fiji:fiji')
  File "C:\Users\Bhavay\Anaconda3\envs\imagej\lib\site-packages\imagej\imagej.py", line 126, in init
    import imglyb
  File "C:\Users\Bhavay\Anaconda3\envs\imagej\lib\site-packages\imglyb\__init__.py", line 41, in <module>
    from .ndarray_like_as_img import \
  File "C:\Users\Bhavay\Anaconda3\envs\imagej\lib\site-packages\imglyb\ndarray_like_as_img.py", line 5, in <module>
    from . import accesses
  File "C:\Users\Bhavay\Anaconda3\envs\imagej\lib\site-packages\imglyb\accesses.py", line 5, in <module>
    Accesses            = autoclass('net.imglib2.img.basictypeaccess.Accesses')
  File "C:\Users\Bhavay\Anaconda3\envs\imagej\lib\site-packages\jnius\reflect.py", line 208, in autoclass
    c = find_javaclass(clsname)
  File "jnius\jnius_export_func.pxi", line 28, in jnius.find_javaclass
jnius.JavaException: Class not found b'net/imglib2/img/basictypeaccess/Accesses'

Can someone please tell me what am i doing wrong?

ctrueden commented 4 years ago

Sorry for the trouble, @Chokerino. Try pinning imglyb to 0.3.5. See also https://github.com/imagej/pyimagej/issues/65#issuecomment-592936874.

bhavaygg commented 4 years ago

Hi I changed the version but still, I get the following error

Error in `C:\Users\Bhavay\Anaconda3\envs\imagej\Library\bin\mvn.CMD -B -f C:\Users\Bhavay.jgo\sc.fiji\fiji\RELEASE+net.imglib2-imglib2-imglyb-0.3.5\pom.xml dependency:resolve': 1

ctrueden commented 4 years ago

@Chokerino Did you use:

conda install imglyb=0.3.5

?

If that's what you did, and it's not working, I'll dig more. It might be as easy as releasing a new pyimagej from the master branch, thanks to #64.

bhavaygg commented 4 years ago

Hi,

I deleted and redownloaded the imglyb library and it seems to work now. Could you please help me on how I could use the XitoSBML plugin in python? I am using the code mentioned above, jnius.JavaException: Class not found b'ij/XitoSBML'

imagejan commented 4 years ago

ij.XitoSBML is not a class that exists.

You could try using the command that the recorder records when running the plugin interactively. I guess it would be something like:

IJ.run("run Spatial Image SBML Plugin")

which would have to be prefixed with:

IJ = autoclass('ij.IJ')

As this is more a usage question and not an issue of pyimagej, I suggest asking (and discussing) this on https://forum.image.sc

ctrueden commented 4 years ago

@Chokerino Glad you got pyimagej working! 🎉

I agree with @imagejan about the usage question: please post on forum.image.sc about it in the Usage & Issues category, tagging with imagej and pyimagej and python and perhaps sbml. Feel free to mention @ctrueden to get my attention, as well as follow up here in this issue with a link to the new topic.

bhavaygg commented 4 years ago

Hi, Link to the post - https://forum.image.sc/t/external-plugins-in-pyimagej/34802

FengZhiheng commented 4 years ago

Hi I changed the version but still, I get the following error

Error in `C:\Users\Bhavay\Anaconda3\envs\imagej\Library\bin\mvn.CMD -B -f C:\Users\Bhavay.jgo\sc.fiji\fiji\RELEASE+net.imglib2-imglib2-imglyb-0.3.5\pom.xml dependency:resolve': 1

I have the same trouble