Closed AdamDHines closed 1 year ago
@AdamDHines Can you please try sc.fiji:fiji:2.13.1
instead of sc.fiji:fiji:2.5.0
? There is a bug in older versions of ImageJ2, which has since been fixed, relating to detection of open ImagePlus
objects while running headless.
Thanks for the reply, @ctrueden. This worked for me and I can now successfully run plugins. Should this be be updated in the documentation for headless operation since the examples that explain how to initialize Imagej2 all use sc.fiji:fiji:2.5.0
? I'm happy to contribute.
@AdamDHines Glad to hear it worked! Yes, we want to update the docs to reference version 2.13.1 over 2.5.0, since it fixes some issues. Your offer of help is much appreciated. I would take you up on it, but it looks like @elevans already started working on it. We will also remove references to the obsolete "HACK: Work around ImagePlus#show() failure", since that trick is no longer necessary with newer ImageJ2 versions. Do you see other areas where the documentation could be improved?
One area where we could use some help is with improving PyImageJ's support for Java GUI elements on macOS. There are some open issues about it, and unfinished effort to enable ImageJ GUI support for use cases like napari-imagej, but no one on the LOCI team currently has time to dig into it further. I don't suppose you happen to know much about the macOS main thread event loop, and how it interacts with Python and/or Java programs, do you? :laughing:
Great! I don't have any experience with MacOS main thread loops unfortunately, I'm new to Apple myself and everything I did before was on Windows.
An improvement on the documentation I could see is a working script example for writing and running a headless with macros that use plugins. The only one that exists to my knowledge needs Xvfb
to work - blob detection. I don't know if this would be best suited under the 'Use cases' contents or if MacOS development should have its own tutorial notebook.
Again, happy to contribute a basic working script example after I've had a little more time to play around with it.
Hi @AdamDHines I'm planning to create a PR for the 2.5.0
-> 2.13.1
version update in our docs (as well as some other fixes and cleanup) by the end of this week. I totally agree with you in that we need more examples with running headless with macros. If you have the time to whip something up for the PR that would be great. But no worries if you don't, I'd still like to incorporate whatever example you have. We can host your example data as well so that we don't bloat the repo.
The relevant branch is: update-docs-layout-and-content
Sounds good, @elevans. I can have a look at this on the weekend, putting together a minimal code working example wouldn't take me very long. I'll fork the repo and reply here when I've finished something.
I just created PR from my fork that includes a couple of working headless macros scripts into the Headless.md document. Happy for you to host the example .tif stack.
I am writing a Python script that uses a GUI to open and run ImageJ with FIJI plugins to automate some data analysis with some difficulties interacting with the Bio-formats plugin. I am using MacOS Ventura 13.4 with Apple silicon, so hoping to develop all of this headless - particularly for end-user deployment purposes.
Following from issue #97, I was able to get some .tif stacks loaded and set as the current active image successfully and run a macro on it.
I have noticed a difference between .tif stacks loaded using
ij.io().open()
when ImageJ is initialized usingij = imagej.init('sc.fiji:fiji:2.5.0')
. When the Bio-formats plugin is used to load a .tif stack, you lose the ability to callimp.show()
to activate the current image to run macros.Running this;
Results in the following error at
imp.show()
Running the
dumpstate()
function as defined in #97 forij = imagej.init()
afterimp.show()
case andij = imagej.init('sc.fiji:fiji:2.5.0')
withoutimp.show()
returns;This is not ideal, since I would like to access plugins in the Fiji distribution. A workaround mentioned here where we point to a local install of Fiji
ij = imagej.init('/Applications/Fiji.app')
also does not work. It appears to be some fundamental difference in the way files are loaded between Bio-formats and ImageJ2. It would also be very ideal to use Bio-formats so that the user doesn't have to use a specific file type to run the software.Trying the legacy importer
img = ij.IJ.openImage('/data/some_tif.tif')
also does not work withimp.show()
when ImageJ is initialized withij = imagej.init('sc.fiji:fiji:2.5.0')
.Initializing ImageJ with
ij = imagej.init('sc.fiji:fiji')
also yields the same result, so it doesn't appear to be the Fiji version being loaded that's causing the problem.Thanks in advance, would appreciate any help or advice on this.
Package versions