Convert stack with WEKA probability maps to stack with labeled images

Hi , I have a stack of images and use WEKA segmentation to get a stack of labeled images. Each image (slice) contains 4 channels.

I try to obtain better segmentation by combining several models. For each model I let the WEKA tool generate a probability map that will be combined to get the result.

One of the tasks is to take a stack containing the probability maps and convert that to a stack of labeled images. Each pixel will contain a number related to the channel with the max probability. docs (Scripting of WEKA segmentation) I found a link to a beanshell script. This is exactly what I want to do, but I want to do that in a IJ1 macro.

I have been looking in Trainable_Weka_Segmentation docs: and found a link to a beanshell script: Convert-TWS-probabilities-to-segmentation.bsh

This script does exactly what I want to achieve, but I want to do it in a IJ1 macro. Anyone knows an IJ1 script that performs this task.

I have been looking for equivalent commands for e.g. probStack.getVoxel( x, y, c ) but did not find that. I also don’t know which commands I should use from the ImageJ menu and get the command via the macro recorder.


EDIT: I managed to use start the Beanshell script. It actually does NOT do what I want to do. It produces a stack of images with the nr of slices equal to the nr in the input stack. But the images are all the same.

My original question remains. If I can do this in a IJ1 macro, I can embed the code in the rest of my program. Hopefully I can also resolve the second issue with some support by one of you :slight_smile: