ilastik / ilastik4ij

ImageJ plugins to run ilastik workflows
MIT License
22 stars 17 forks source link

Allow optional prediction mask for pixel classification #7

Open imagejan opened 6 years ago

imagejan commented 6 years ago

I suggest adding an optional input to the Run Pixel Classification Prediction node, allowing to choose an image column that contains a prediction mask.

See https://github.com/knime-ip/knip-ilastik/issues/17 for the previous issue opened on knip-ilastik.

k-dominik commented 4 years ago

Question: is it possible to have "optional" arguments in plugins? :)

imagejan commented 4 years ago

@k-dominik yes:

@Parameter(required = false)
private Img maskImage;

You'll have to check for null yourself though. And while I would expect this to work in KNIME, I am not sure how this will be handled in the SciJava Swing UI, as it probably will show a drop-down, but this won't contain a None option. Might be something to improve over there in scijava-common and scijava-ui-swing ...

Tomaz-Vieira commented 4 years ago

I've submitted a draft PR implementing this, and it works fine. Still, I could not find any way to add an optional parameter to the Command.

The problem is that the old macro calls should still work, and to achieve that, the command must have a default value for the new parameter. The only way I found that would actually make the command run without the extra parameter is by setting the new input to "resolved" (which apparently means that it already has a value and is ready to be used). Doing that, though, makes the input not show up in the UI in interactive mode.