it would be nice to have the option to give the snippet text as flow variable. E.g. to open a single file using the Pure Code "open("/Volumes/folder/myFile1.tif");" works, but how can I iterate over many files? Using string manipulations the codes could be given by a flow variable.
I modified the ImageJ1-Macro node such that it is able to run the "open(...)"-macro (which didn't work till now, at least for me ;) ) and it's macro code is now controlable by a flow-variable.
The attached workflow demonstrates how to list files, generate the according "open"-macro code (java snippet-extension required) and then finally looping over the generated macros to open multiple files with the ImageJ1-Macro node. The Image Generator is needed in this workflow, because the IJ1-Macro node requires an image as input and, hence, we just generate a very small one. And please note that the memory policy of the Loop End-node needs to be set to "Write tables to disc" because we have still some problems with some of our nodes (i.e. the image processing nodes) in a loop, if this is not set.
The changes are available with the next nightly build. Please note that the imagej-extension is in a beta stage and, hence, rather experimental.
If you face some problems or have other suggestions, just let us know.
This is a welcome addition to the ImageJ macro node. I have been able to use this to pass a variable to the "Set Scale…" command.
However, I then noticed that (in a separate node) the Subtract Background macro is no longer working.
run("Subtract Background...", "rolling=50"); gives all black images, and
run("Subtract Background...", "rolling=50 light"); gives all white images.
This is for nightly build:
KNIME Image Processing - ImageJ Integration (Beta) 0.6.0.201210121435
On another box with
KNIME Image Processing - ImageJ Integration (Beta) 0.6.0.201210050711
the Subtract Background macro still works OK.
(the other) Simon
I tried to reproduce your problems on my computer but without success. The IJ1-node gives the results as expected (as the standalone ImageJ1 produces). Actually I haven't changed anything in the way how the images are processed within these builds.
Does a normalization of the images after the IJ1-node help? Or have all pixels been set to 0?
If nothing helps, could you please provide the workflow with at least one image?
Because of the size limitation for uploading files, I found a CC-BY image that the workflow can load as a URL (see attached workflow).
I've cut down the workflow so that it's small enough to upload here.
Before I realized that the Image Reader node would also load images from URLs, I constructed a different workflow using the Read PNG Images node and the Image KNIME-KNIP Bridge, by-passing the Image Reader node.
Surprisingly, that works.
So I'm starting to suspect the Image Reader node.
(the other) Simon
thanks for submitting the workflow. Your are right suspecting the Image Reader node causing the problem. But it's rather easy to solve: png-images consist of 4 different channels (RGB and one channel to encode transparency). Our Image Reader reads all 4 channels (whereof the 4th channel usually is filled with all 0's) whereas the "Read PNG Images" node omits the 4th channel (the resulting image only has 3 channels). And this "emtpy" 4th channel causes some troubles in the substract background macro. To make this also work with our Image Reader, just select only the first 3 channels (Subset selection-Tab in the Image Reader-dialog (saves memory, because only the selected channels are read), or by using the Image Cropper node). Actually, as the example image is grayscale (i.e. all three color channels are identical), selecting only the first channel is sufficient.
A little tip: to conveniently check the dimensions of an image (e.g. the number of channels), just click with the right mouse button on an image-column header und choose "Metadata" as renderer.
P.S. I have never tried to load images with the image reader from web-urls. But nice to know that this works as well (thanks to BioFormats ;) ).
That worked, thanks!
Although I'm still surprised that that it wasn't a problem before the latest update.
(the other) Simon
thank you for beeing insistent! I recognized that the changes that I made to get the "open(...)" macro run, were causing problems when n-dimensional images have been processed. Originally, when n-dimensional images (e.g. X,Y,C) are used as input, you can select "X,Y" and the macro will be applied plane-wise for each plane (i.e. iterating over the non-selected dimensions). That didn't work anymore.
But I resolved it and it should work now with the next nightly build as desired again (i.e. than your workflow works without selecting the C-dimensions and an (X,Y,C=4)-image will result in an (X,Y,C=4) image where each X,Y-plane (4 planes) are background-corrected).
Sorry for beeing inattentive and thanks for your help.
thanks a lot for the quick implementation of flow variables to ImageJ macro node! I also got it up running, however experienced a weird behavior.
It only works (I tested now only open() command) if the input contains already an image of the same type. Then replace and append column works. If I have a table without IMG+ column (e.g. my list of path and string column with macro code to be opened) or even a IMG+ column from Image Generator (even same dimension) then neither append, replace nor new works.
My workaround is to use a single image loaded from the bulk of data to be open with ImageJ macro and use it as its input.
Anyways, thank a lot for making flow variables available for that node!!!
the input image needed in the ij-macro node is used in conjunction with the "open()"-macro actually only to determine the size of the dimensions which are NOT selected. Maybe something is wrong there. Anyway, I suppose, the ImageJ-Macro node is not best suited to open images. What keeps you from using the Image Reader node with the optional inport? There is also an IJ-Image Reader available if the ImageJ-plugin is installed. Would it help to extend it with an optional port to be able to feed the node with other urls?