Trainable Weka Segmentation macro issue with stack

Hello everyone, I’m trying to get a macro running for the segmentation of a stack using Trainable Weka Segmentation (TWS), but I got an issue when using call("trainableSegmentation.Weka_Segmentation.getProbability");. My problem is that when I run the macro I get a stack of the images combining the three different classes that I used for the training, instead of a stack of three channels (for each class) plus a stack of all my images (a z-stack). For instance, I have a 16-images stack, I will get a 48-images stack with slice No.1 being the probability results for the first class applied on the first image, No.2 the second class on the first image, etc., which I can’t easily separate for further analysis. However, if I push manually the “Get Probability” button on the TWS window, I will get the expected result. Does anyone know how can I fix this? Thanks in advance.

Hello @aibanezf and welcome to the ImageJ forum!

That was indeed a bug. I have fixed it, so please update to the latest release of the plugin and try again.

Thanks for reporting!


Thank you very much! I’m quite a fan of TWS, so thanks a lot for the developing of such a useful tool for Fiji/ImageJ!


1 Like

Hi all,
I found the same problem when I am using the Trainable weka segmentation 3D. The software works nice (really nicely, I am really happy with this. Congrat!) but the probability map is divided in the three classes I used for training. My original stack was 102 pictures and the probability map is 306 layers where the first picture is the first class for training, the first picture is the second class and the third picture is the third class. After that, the 4th picture is again the first class. I updated fiji and it does still the same. Can I update TWS directly?

Thanks in advance,

Hello @anto89,

Are you sure you are using the latest plugin version (3.2.27)? You should be able to see “v3.2.27” in the plugin name when calling it on your image. If so, can you tell me the steps you followed? I made some simple tests and I was not able to reproduce the error.


Hello Ignacio,

Yes, I have the latest pluging version (v3.2.27).

I have an stack compound by two channels. In one of the channels I have cells + some background + the biomaterial where I grow my cells and in the other channel I have again the surface where I grow the cells + background.

I have three class in the trainable weka segmentantation 3D. One for the cells, another for background and the third one for the biomaterial to grow cells. The segmentation works fine but when I obtain the probability map this is composed for 3 sections. Where the first pic of the probability map is the “cells class”, the second picture is the " biomaterial class" and the third picture is the “background class”. The fourth pic is again the “cell class”. So the probability maps is a stack of 306 pictures instead of 103 pictures of the original stack in this order. What I would need is that every class is in a different probability map that I can analyse after if it is possible. If I am not wrong it is similar to the problem that was described before.

Kind regards,

OK, I see the problem now, @anto89. So far, TWS does not support multi-channel images and therefore the weird behavior. I may add that support in the next few weeks, but for now, I recommend you to convert your input image to RGB.

1 Like

Hi Ignacio,

You are right. The problem was the multi-channel. I changed the multi-channel stack to RGB and the probability maps now is a stack with the same number of “channels” as stacks. Really nice pluging, congrat.

Thank a lot for the help,

1 Like