pyimagej
pyimagej copied to clipboard
java.lang.RuntimeException: Macro canceled with DiameterJ Segment
Hi
I am trying to run the DiameterJ Segment plugin using pyimagej. After initialising the object, opening an image and converting the image to imageplus:
image = ij.io().open(PATH_1)
imp = ij.py.to_imageplus(image)
I run the following command:
ij.IJ.run(imp, "DiameterJ Segment", "do=Yes image=1024 image_0=768 top=0 top_0=0 bottom=1024 bottom_0=650 stat. do_0=No choose=/home/marilin/Documents/ESP/diameterJ_test/sem_test")
I get a Java exception about the Macro being canceled with the following output:
Traceback (most recent call last):
File "IJ.java", line 409, in ij.IJ.run
File "IJ.java", line 322, in ij.IJ.run
File "IJ.java", line 423, in ij.IJ.testAbort
File "IJ.java", line 2484, in ij.IJ.abort
Exception: Java Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/marilin/Documents/ESP/master_thesis/scripts/pyimagej_test.py", line 69, in <module>
ij.IJ.run(imp, "DiameterJ Segment", "do=Yes image=1024 image_0=768 top=0 top_0=0 bottom=1024 bottom_0=650 stat. do_0=No choose=/home/marilin/Documents/ESP/diameterJ_test/sem_test")
java.lang.RuntimeException: java.lang.RuntimeException: Macro canceled
Additionally, I have tried to add the custom plugins directory to sj config and use the run_plugin()
, alas received the same error about the macro being canceled.
I also tried using the run_macro()
but ended with a similar result of an unrecognized command "DiameterJ Segment".
I know the error is pretty verbose, but is there any way to successfully run this plugin in pyimagej?
EDIT:
added some more .jim files to the custom plugin folder, and now have received an import error with run_macro()
-
ImportError: The original ImageJ is not available in this environment. Use of original ImageJ macros is not possible. See: https://github.com/imagej/pyimagej/blob/main/doc/Initialization.md
is there a way around this?
Hi @marilin99. Sorry for the late reply. I took a look at DiameterJ and I also have issues running it. After searching around it seems that DiameterJ has some incompatibilities with ImageJ/Fiji (see this post for more details). A couple of questions:
- What version of DiameterJ and Fiji are you using with PyImageJ?
- Are you using a single image or a directory of images?
- If you're using a single image, have you tried Nathan's (NHotaling)'s quick fix (i.e. deleting the
var
references in the DiameterJ macro)?
My current guess is that the plugin is failing due to the incompatibilities with ImageJ/Fiji and is throwing a macro cancelled error.
@marilin99 One other question: are you able to use DiameterJ successfully from within the regular Fiji application? I.e. is it only in PyImageJ that it fails? Or does it fail in Fiji, too?
Hey, this is just a message to say that I have seen your comments but have not had the time to look into this issue again. Thank you for your responses and questions - will get around this again once my thesis is done :))
Hey, Sorry for any disturbance, btw, I was wondering if there is any notebook showing DiameterJ use with pyimagej ? It may be helpful to disentangle such issues, and actually, many people asking such questions on several other forum topics.
Thanks for your time :)
Hi @IssaMBarl, we do not have a specific section on using DiameterJ with PyImageJ. While I think some people would find that helpful, I'm hesitant to create new documentation for a specific plugin. DiameterJ hasn't been maintained for ~9 years (see the repository) making compatibility with current/future versions of PyImageJ unknown. For example this issue that you opened could be from the incompatibility with modern Fiji linked in the post. Creating specific documentation for DiameterJ would also create an expectation that it works in the future, which we cannot guarantee. A better place to put this kind of content might be on the ImageJ wiki. Here's an example of ImgLib2 examples with snippets of code on the wiki.
But thats only if DiameterJ works with Fiji. Have you gotten DiameterJ to work for you with regular Fiji? Did try deleting the var
references as suggested by the imagesc forum post?