I started using Fiji through Jupyter notebooks which worked great so far. Big thanks to everyone who was involved in the integration.
Unfortunately I got stuck with a wired problem with converting an image composite to an RGB stack. I tested a macro first with the local Fiji where it works as expected, but as soon as I transfer it to jupyter it does not.
I import imageJ the following way:
import imagej ij = imagej.init('C:\\Fiji.app') ij.getVersion() '2.0.0-rc-69/1.52p'
After importing three image stacks (1-3) I merge the channels and get a composite:
ij.py.run_macro("""run("Merge Channels...", "c4=stack1 c5=stack2 c6=stack3 create keep");""") print(WindowManager.getImageTitles()) ['stack1', 'stack1', 'stack1', 'Composite']
Trying to convert the Composite stack with the Channels Tool to an RGB stack seams not to work:
ij.py.run_macro("""run("Channels Tool...");""") ij.py.run_macro("""run("Stack to RGB", "slices keep");""") print(WindowManager.getImageTitles()) # I would expect a new stack, however there is only the 'Composite' ['stack1', 'stack1', 'stack1', 'Composite']
Trying to save the RGB stack results in saving each channel individually, indicating that I do not have a RGB stack:
ij.py.run_macro("""run("Image Sequence... ", "format=PNG name=res start=1 save=/res0001.png");""") % Saves NOT the RGB stack but each Channel separately.
I’m a bit puzzled by this result and I can’t find the mistake. Maybe there is an alternative way to achieve the RGB stack? or someone can point out the mistake I have in the script. Note running the code as a macro in the normal Fiji app works well.