ImageJ macros and Knime

Hi,
Just started investigating Knime functionality, and as far as I can see, the programming for nodes are done with JavaScript which I am not familiar. I already have written some imageJ macro scripts but they are asking for parameters with ‘# @parameter1’ syntax. I know that execution of imageJ macro from Knime appears possible (not tested yet). My question is, if theres any way to feed these parameters to imageJ macro (some are path, and some are fixed numbers) from Knime?

Hi @rogerwilco,

have you taken a look at https://www.knime.com/community/imagej yet? It allows you to run ImageJ macros and commands as long as they are headless (they do not require any gui interaction). You can also create imagej2 plugins that are turned into KNIME nodes by our imblib2 integration, take a look at https://github.com/fmi-faim/fmi-ij2-plugins for inspiration.
If you encounter any issues with any of these approaches, please feel free to ask more questions here, we are happy to help you.

best,
Gabriel

2 Likes

Since you are specifically asking about the #@ script parameters: no, unfortunately there’s currently no way to use script parameters in the KNIME Image Processing integration. The ImageJ Macro node works with ImageJ1-compatible macros only (while the script parameters are an ImageJ2/SciJava feature), and the automatic node generation of the ImageJ2 integration that @gab1one mentions requires Java plugins, but doesn’t currently work for scripts (i.e. IJ1 Macro, Groovy, Python, etc.). That is the reason why I resorted to create IJ2 plugins for the fmi-ij2-plugins site that Gabriel linked in his post.

(@gab1one please correct me if I’m wrong.)

2 Likes

Nothing to correct there :slight_smile:

@imagejan @gab1one thanks for the inputs, but there’s one thing I do not clearly understand, as far as I remember, it’s possible to use scripts in headless mode with imageJ, here is link.


Command line Parameters are supported in above link examples.

Ok it might not be possible to transfer these parameters to bash script, but can’t we think an alternative way to feed parameters to a python script first, which executes the bash script using this prm.?
(If I am not wrong, there are two languages for custom scripting in Knime, Java and python).

There’s Groovy and R as well.

Sure, you can always start an executable from the operating system and hand over a string with options on the command line. For images, you’ll have to resort to files saved to disk and provide their paths as inputs to your ImageJ macro/script.

The advantage of the integrations is that you don’t have to go via the file system, you can simply define and Img column as your input. That’s not possible when you start ImageJ headless via the command line. But otherwise that’s a perfectly sensible solution, applicable to anything that you can start from the command line.

1 Like

Thanks for the clarification, now I understand the difference (and advantages) better, but since I don’t know Java, I will take the longer path for the moment.
Yesterday, I have happily managed to create cropped images on disk, with image reader>tile loop start>image writer trio.
In Knime, I am seeing filepaths are (or can be?) stored in tables, now I need an example on how to feed path of cropped images into above scenario since my imageJ macro able to process all images in given folder, and create text outputs in same folder.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.