CLIJ Weka segmentation exception

Hi All,

I am trying to use weka in CLIJ to do some machine learning to pull some blobs out of my images.

Pretty sure i have followed everything like i should but i keep getting a java.lang.ClassCastException: [B cannot be cast to [F error when trying to train the classifier.

Below is an example code that generates the feature stack and ground truth images using the blobs demo image. If you then take those images and try to train the classifier on them you get an error.

Any ideas on what is going on?

run("CLIJ2 Macro Extensions");
Ext.CLIJ2_clear();

run("Blobs (25K)");

image1 = "blobs.gif";

Ext.CLIJ2_push(image1);
image2 = "Feature Stack";
feature_definitions = "original gaussianBlur=1 gaussianBlur=2 gaussianBlur=4 gaussianBlur=8 gaussianBlur=16 SobelofGaussian=1 SobelofGaussian=2 SobelofGaussian=4 SobelofGaussian=8 SobelofGaussian=16 LaplacianofGaussian=1 LaplacianofGaussian=2 LaplacianofGaussian=4 LaplacianofGaussian=8 LaplacianofGaussian=16 entropy=1 entropy=2 entropy=4 entropy=8 entropy=16";
Ext.CLIJx_generateFeatureStack(image1, image2, feature_definitions);
Ext.CLIJ2_pull(image2);

Ext.CLIJ2_clear();

newImage("Ground Truth", "8-bit black", 256, 254, 1);
selectWindow("Ground Truth");
makeOval(65, 30, 19, 20);
setColor(1);
fill();
selectWindow("Ground Truth");
makeOval(103, 37, 18, 14);
setColor(2);
fill();
run("Select None");
setMinAndMax(0, 2);
2 Likes

Hi @Cameron.Nowell

How do you train and what’s the full error message? :slightly_smiling_face:

Maybe a link to a (bit old) example script helps: clijx/weka_segmentation.ijm at c6f5ece952acd4384a02ad34317e3a138d1aba06 · clij/clijx · GitHub

Furthermore, you can train those models interactively in the assistant and generate a script to apply them.

Let me know if this helps!

Cheers,
Robert

@haesleinhuepf that old script was exactly what i needed. Looking through it it looked pretty much identical to what i was doing except for one thing. Your ground truth image was 32bit mine was 8.

As soon as i changed it to 32bit it all works. Didn’t realise that would be an issue. I assumed a value of 1 intensity would be the same no matter what…

2 Likes

Ok, that looks like a bug then. I can dive a bit into this. Would you mind sharing the full error log? That helps me reproducing the issue.

1 Like

This is the only error info i get out. Is there something else i can pull out?

java.lang.ClassCastException: [B cannot be cast to [F
at net.haesleinhuepf.clijx.weka.CLIJxWeka.featureStackToInstance(CLIJxWeka.java:214)
at net.haesleinhuepf.clijx.weka.CLIJxWeka.trainClassifier(CLIJxWeka.java:111)
at net.haesleinhuepf.clijx.weka.CLIJxWeka.saveClassifier(CLIJxWeka.java:446)
at net.haesleinhuepf.clijx.weka.CLIJxWeka2.saveClassifier(CLIJxWeka2.java:47)
at net.haesleinhuepf.clijx.weka.TrainWekaModel.trainWekaModel(TrainWekaModel.java:29)
at net.haesleinhuepf.clijx.weka.TrainWekaModel.executeCL(TrainWekaModel.java:23)
at net.haesleinhuepf.clij.macro.AbstractCLIJPlugin.run(AbstractCLIJPlugin.java:478)
at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:265)
at ij.plugin.filter.PlugInFilterRunner.(PlugInFilterRunner.java:114)
at ij.IJ.runUserPlugIn(IJ.java:237)
at ij.IJ.runPlugIn(IJ.java:198)
at ij.Executer.runCommand(Executer.java:150)
at ij.Executer.run(Executer.java:68)
at java.lang.Thread.run(Thread.java:748)

1 Like

Thanks, that’s it what I need to debug efficiently :smiley:

1 Like