Trainable Weka Segmentation - how to start

Hi everyone,
I’m trying to use the TWS to segment images of retina. What type of image am I supposed to have when loading the TWS? I’ve looked at different documentation including the one from ImageJ but it is still unclear to me. I’ve tried with the original image, a mask, an image with the edges previously detected, but everytime I click on the “Train classifier” button it tells me “Cannot train without at least 2 sets of examples!”. Should I draw the layer edges by hand and do something else before running TWS?
Please advise.

If you haven’t created any ROIs within Weka and added them to a given class, you have nothing to train off of.

You should be using the original image by default, though there may be ways of using masks. I haven’t made enough use of it to know for sure.

1 Like

You might benefit from Ellen Arena’s video on TWS on
Vimeo. She starts the example at approximately 1:11:00 into the video. The slides are here.


Thank you so much John_Minter!!! That is very helpful!! Let me play with it a little and I might come back with more question so I can get the type of result I’m looking for.

Hi John,

So I don’t know if you’ll be able to help me but here is my original image:

I’ve tried using TWS (taking in account what I learned from the video link you sent) and it seems to work pretty well:

What I’d like to get at the end is something where the edges for each layer of the retina is outlined roughly. Kinda like on this picture (I drew the lines by hand but would like them to be made sort of automatically):

Actually it doesn’t even have to be lines, it can be a sort of binary image like what the TWS renders but with the edges of each layer being more smooth and defined.

I’m thinking that if I get to something like that, I might then be able to measure the thickness of each layer.

Thanks for your help.

I think you could use Ilastik to perform a Pixel Classification, just like with WEKA, but then apply an Object Classification taking into account the location of the objects. Please find here some documentation in case you want to give it a try:

Thanks a lot pau for this suggestion. I downloaded it and started playing with it. Unfortunately it keeps closing unexpectedly and so I lose any progress I’ve made… :frowning:
In case I cannot get this to behave, is there a setting in the TWS where I could smoothen the segmentation?


Maybe @ilastik_team can help you with that…

After training the classifier you could use Get probability instead of Create result. It will generate a probability maps: a stack with one image per class (e.g. background, nuclei…) where each pixel value corresponds to the probability of belonging to that class (0-1). Then you could smooth the probability (e.g. using the Mean filter [Process>Filters>Mean...]) before applying a threshold method to perform the segmentation [Image>Adjust>Threshold...].

Hey @riri46, maybe we can help you with your ilastik issues. You could e.g. open up a new thread, specific to the problem.