Closed JeBiUKD closed 1 year ago
Hi @JeBiUKD,
It sounds like you are running in headless
mode when instead you want interactive
. How are you initializing PyImageJ? By default you get headless
mode when you initialize PyImageJ like this:
import imagej
ij = imagej.init()
To get interactive
mode initialize PyImageJ like this:
import imagej
ij = imagej.init(mode='interactive')
Once in interactive
mode you can call the ImageJ/Fiji GUI and view images. This only works with jupyter notebook locally.
For more info on initializing PyImageJ, check out the docs here.
Hi,
thank you very much for the response. I used this to initilize PyImageJ:
ij = imagej.init('sc.fiji:fiji',headless=False)
I also tried your method (ij = imagej.init(mode='interactive')
) and it gives me actually a different error message:
Unrecognized command: "KymographBuilder" in line 13
run("KymographBuilder",input=stack_0_100.tif"<)>;
It looks like it cannot find the plug-in. The same happens when calling the previous plug-in which worked before in ij = imagej.init('sc.fiji:fiji',headless=False)
. So it seems I cannot call plug-in at al by run("xxxx");
Any ideas?
Best, Jessica
Hi @JeBiUKD,
Sorry for the delayed response, I was out of town teaching.
What version of PyImageJ are you using? The headless
flag has been deprecated and replaced with mode
. So if you want the latest a interactive Fiji you'd initialize ImageJ with ij = imagej.init('sc.fiji:fiji', mode='interactive')
. When you initialized ImageJ with ij = imagej.init(mode='interactive')
you only get ImageJ2 and not Fiji, which is why you get an error indicating the KymographBuilder
plugin is missing.
Here's a minimal example that uses the KymographBuilder
plugin on some sample images in Fiji.
import imagej
import code
# initialize Fiji in interactive mode
ij = imagej.init('sc.fiji:fiji', mode='interactive')
# display ImageJ GUI
ij.ui().showUI()
# open sample data and run KymographBuilder
ij.IJ.run("Confocal Series")
ij.IJ.makeLine(136, 125, 267, 236)
ij.IJ.run("KymographBuilder", "input=confocal-series.tif")
# return REPL
code.interact(local=locals())
Can you also try just adding ij.ui().showUI()
to your original workflow? When I was playing around with this I noticed that the output from the plugin didn't display until I showed the ImageJ UI. There might be a bug in the plugin that ties it's output to some other display elements associated with the main UI.
Hi @elevans,
Adding ij.ui().showUI() did the job.
Thanks so much for your time and the easy solution.
Best, Jessica
Hi,
I am currently working on a skript in phython where I integrated a ImageJ macro using PyImageJ. I have been able to work with previous plug-ins like the Multi Kymograph plug-in (https://github.com/fiji/Multi_Kymograph). However, for my analysis I get a better output if using the KymographBuilder plug-in (https://github.com/fiji/KymographBuilder).
The problem which I am facing is that it successfully runs the KymographBuilder plug-in (see below) however does not show an output image/window at the end, which I need in order to save the generated kymograph.
Also when I am running the macro in Fiji/ImageJ it works without any problem and shows me the desired output image. So it hast something to do with the PyImageJ integration.
I am not sure if its relevant but I am working with Jupyter notebook.
[java.lang.Enum.toString] [WARNING] Ignoring line width >1. [java.lang.Enum.toString] [INFO] Running KymographBuilder version 3.0.0 [java.lang.Enum.toString] [INFO] Dataset : stack_all.tif Width = 2532 Height = 2132 Depth = 1 Timepoints = 118 Number of channels = 1
[java.lang.Enum.toString] [INFO] 1 lines with a width of 100 will be used for the kymograph 0. [java.lang.Enum.toString] [INFO] Creating kymograph for the channel. [java.lang.Enum.toString] [INFO] Kymograph "stack_all.tif (Projected Kymograph)" has been correctly generated.
I hope you can help me find a solution with this specific issue.
Thank you in advance!
BTW I submitted the issue here as well, as I am not sure who can adress it (https://github.com/fiji/KymographBuilder).