-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrating pyImagej with ImJoy website #147
Comments
@giovanniani Do you have a minimal example somewhere we can look at, to better understand what you are trying to do? CC @oeway |
Hi @giovanniani I think what you are looking for is something like this: import scyjava as sj
WindowManager = sj.jimport('ij.WindowManager')
# ...run your macro with your image
# Get the image of your current window
current_image = WindowManager.getCurrentImage()
# Convert your image to a numpy array
current_image_ndarray = ij.py.from_java(current_image)
# Display the ndarray in ImJoy e.g. using Kaibu: https://kaibu.org/docs/#/api?id=view_imageimage-options |
@giovanniani Please close if @oeway's code will work for you, or give more details if not. Thanks! |
So I tried running the code above but I keep geeting the next issue |
@giovanniani How are you initializing your ImageJ2 gateway? Try this: import imagej
ij = imagej.init() It should spin up an ImageJ2+ImageJ environment, which will include Double check you are running the latest pyimagej. It should be 1.0.2. ( In the next release of pyimagej (1.1.0), you will also have direct access to the from scyjava import jimport
WindowManager = jimport('ij.WindowManager') |
I was using a local version of Fiji I believe that's why it didn't work for me on the first time. Do you think we can solve this with any workarounds or I should stick to the normal init? |
@giovanniani A local version of Fiji should certainly work; you should have As I said above: if you could please post a minimal example demonstrating the problem, that would be very helpful in trying to reproduce and troubleshoot. |
This is the code that I've been running The data is mounted on a separate drive I can send the data as well if needed. I've been running the code inside a virtual machine with ubuntu 20.04 import imagej
import scyjava as sj
ij = imagej.init('/home/giovanni/Documents/Fiji.app')
scyjava.config.add_option('-Xmx6g')
WindowManager = sj.jimport('ij.WindowManager')
macro = """
open("/run/user/1001/gvfs/smb-share:server=truenas.local,share=data_storage/giovanni/test/a.tif");
run("3D Objects Counter", "threshold=407 slice=151 min.=10 max.=19857408 exclude_objects_on_edges objects surfaces centroids centres_of_masses statistics summary");
selectWindow("Surface map of a.tif");
selectWindow("Centroids map of a.tif");
selectWindow("Centres of mass map of a.tif");
selectWindow("a.tif");
"""
result = ij.py.run_macro(macro)
ij.window().getOpenWindows()
ij.window().clear() |
I'm looking to integrate pyImagej with a website we are working on with ImJoy, and would like to see how we can send the data from the results back to the website, we already can call macro functions from the website but we still haven't been able to get the results back.
Thanks
The text was updated successfully, but these errors were encountered: