clij / clijpy

GPU-accelerated image processing using CLIJ via pyimagej in python
https://clij.github.io/clijpy
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

Issues with Demo / Autoclass import #8

Open jimzers opened 4 years ago

jimzers commented 4 years ago

Hey @haesleinhuepf -

Thanks for all your work so far on this repo - I appreciate you taking the time to make this port. I've been trying to make the demo work properly - I've setup a conda environment following the per-usual pyimagej setup instructions on their repo page. Unfortunately, I seem to be hitting a wall with jnius' autoclass function. Here is some of my code:

import sys 
print(sys.version)
import imagej
ij = imagej.init('sc.fiji:fiji:2.0.0-pre-10');
from skimage.io import imread, imsave
from jnius import autoclass
import numpy as np

CLIJx = autoclass("net.haesleinhuepf.clijx.CLIJx") 
clijx = CLIJx.getInstance();

When I run this, I get an issue with finding the correct class for CLIJx: Traceback (most recent call last): File "clijpy-test.py", line 10, in <module> CLIJx = autoclass("net.haesleinhuepf.clijx.CLIJx") File "/home/ubadmin/anaconda3/envs/mac-pyimage-test/lib/python3.7/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/haesleinhuepf/clijx/CLIJx'

I've seen other tutorials on using autoclass, but to be honest I don't know too much of the mechanics. I've seen autoclass('ij.WindowManager') and similar things use the ij prefix, but not sure how to load the CLIJx class.

Curious to see where I went wrong - Hoping it's something simple I missed!

haesleinhuepf commented 4 years ago

Hey @jimzers ,

glad you like CLIJ. The issue is that the FIJI you specified "sc.fiji:fiji:2.0.0-pre-10" doesn't include CLIJ since CLIJ is an optional Fiji plugin. If you check the examples you'll see that I tend to specify a defined FIJI installation, which I can keep up-to-date using Fijis build-in updater functionality. The installation instructions on Fiji tell you how to do this. After setting up your local Fiji, try this:

ij = imagej.init('C:/programs/fiji-win64/Fiji.app/')

Alternatively, it should be possible to specify something like, the following, but I'm not sure about the exact syntax. Idea is to specify an additonal maven dependeny, such as clijx_:

ij = imagej.init('sc.fiji:fiji:2.0.0-pre-10,net.haesleinhuepf:clijx_:0.28.0.5');

Please also note, that the python-pyimagej-clijpy-bridge is a bit volatile. Many people struggled with installation and running it on some systems. That's why an alternate approach is in the making: pyclesperanto. It'll take some time until it's up and functional (at least half a year likely), but maybe worth waiting for: https://github.com/clEsperanto/pyclesperanto_prototype

Let me know if the suggested fix above worked!

Cheers, Robert