Is there any way I can mix and match collection cells (i.e. […], such as those created by the List or Set aggregation functions) with Double[] cells (i.e. [D], such as those created by the ImageJ2 integration when using double[] as an output @Parameter)?
I tried the following code in an ImageJ2/SciJava Command:
@Plugin(type = Command.class, headless = true,
menuPath = "FMI>Testing>Input Double Collection")
public class InputDoubleCollection implements Command {
@Parameter(label = "Some doubles")
private Collection<Double>[] m;
@Parameter
private LogService log;
@Override
public void run() {
log.error("Double Array input running...");
}
}
… and while it does auto-generate a node, I get the following error when trying to add it to a workflow:
ERROR Input Double Collection 2:3 Error while creating node dialog for 'Input Double Collection': Can not set [Ljava.util.Collection; field ch.fmi.test.InputDoubleCollection.m to org.scijava.Context
If it doesn’t work this way, is there maybe a way to create the [D] column type using a Java Snippet node?
My specific use case: I’d like to dynamically generate the input to one of my plugins (e.g. TrackMateCollectionTracker) from an arbitrary number of rows in a KNIME table at runtime (without knowing the number of rows beforehand, of course).
There are no converters from KNIME collection cells to raw java types for the ImageJ2 integration. So if you have such a cell, you can currently not consume it with the ImageJ2 integration.
You can create Collection cells containing double[][] arrays using the Create Collection Column node, see the attached workflow for an example. create double-array.knwf (9.7 KB)
Yes, that’s what I was trying, but as the type of the cells is still just a “Collection” (as indicated by the […] column header) and not a Double[] (which shows up as [D] column header), there’s no way to use this in the ImageJ2 integration at all, right?
The other thing I was trying was adding a column of type Double and selecting the Is array option in the Java Snippet node:
… but this also just generates a […] collection cell instead of the [D] that I’d have expected.
The column type with the header [D] is a Double Vector (Collection Of Number (double)), which is only used by the Wide Data Extension. The […] collection cell are core KNIME.
Thanks for pointing me to the Wide Data Extension. I noticed they provide an Expand Vector node (that essentially does the same as the Split Collection Column node, no?), but what I’d require here is rather the opposite: a “combine/merge columns into vector” node.
Here’s a small workflow (making use of nodes from the FMI KNIME Plugins update site) that illustrates what I was trying to achieve:
Thanks to your hint to the Wide Data Extension, I was able to find a workaround by saving my values to a temporary CSV file and reading them with the CSV Array Reader node provided by that extension, but it’s a bit complicated:
Thanks, I hadn’t looked at the Line Chopper yet, that’s indeed much better!
I think it would be useful if the Wide Data Extension (or any other component) provided a new aggregation function Vector similar to the currently available List (in the GroupBy and Pivoting nodes) that would create vector columns instead of collections.