Pixel classification in ilastik

Hello,

I’ve been trying to perform image segmentation using pixel classification in ilastik. After loading the input file which is a z-stack with ~1200 slices, all 37 features have been selected.

In the training step, labels have been added to define the pixel class (please refer to the snapshot below with annonations drawn on slice 626 in the z-stack).

I’m a beginner here, I’d like to know if it’s ok to proceed with the prediction export step after adding annotation on one slice alone.

I tried to continue with the prediction export step.
Unfortunately, I didn’t get the segmentation right.

The volume reconstructed from the tiff files exported in the prediction export step is shared in the above snapshot. I was expecting the volume to consist only blood vessels and not any tissue mass.

Any suggestion on how to improve the annotation labels to retain only blood vessels will
be really helpful.

For links to the input, please refer here

Hi @Deepa,

it is good practice to first look at your results in live update mode. Only you know what kind of structures you want to highlight. If you want only blood vessels, go to live prediction and give examples for non-vessel pixels, as well as vessels. Try to be very accurate, consider the 1 pixel wide brush. Correct the classifier until you are satisfied.

Hope this get’s you closer to a nice vessel segmentation.

i gave it a really quick go (not really knowing what I do, since I don’t know the data) and I end up more with something like this using a relatively small amount of annotations.

I’m sorry , I am new here and I tried to follow the examples available in the documentation to understand how annotations should be added. I might have gone wrong here. Could you please share a snapshot of the annotations that you have added? I am really looking for an end result like the one shared by you in the above snapshot. Is the annotation added on a single slice in the z-stack?

I had a chance to check the results in the live update mode. But I wasn’t sure how to check the 3D
volume within ilastik. I could only check this after importing the segmentation results obtained from ilastik in an external software. I would like to know if there is an option to visualize the 3D volume within ilastik.

Thank you very much for your time and kind attention

Hi @Deepa,

first, there is no way to look at the segmentation in 3D in ilastik directly. You’ll have to check

first, I have maximized a single view, as I am on a tiny laptop and 3D processing is always a challenge on this. ilastik only predicts what you look at, so maximizing one view hides the others and hence it will be faster. You can maximize any view by clicking on the icon (you can check documentation for more information on how to interact with the views).

So my annotation strategy for your data was the following:

  • annotate very little (brush size 1)
  • annotate a little on a vessel with the vessel class
  • annotate a little in the vicinity
  • turn on live update and inspect the result a little.
  • add more annotations where I think the segmentation is not good enough yet.

Here my initial labels:

with the first predictions:

when inspecting I added the following annotations:

Thank you so much for the detailed illustration.

From the snapshots shared above, I understand the annotations can be added in multiple slices. I would
like to ask for a clarification in this regard. Since the intensity of coloring might vary from slice to slice, would it be required to normalize prior to calculating features?

i would even formulate it stronger. Annotations should be added in different slices. In general, in order to train a robust classifier you have to supply examples (= annotations) for the different appearances.

If you have physical reason to apply some kind of correction to your grey values (eg. b-field correction in mri) then I would say yes, but this is usually done by the acquisition system itself.
But in the other instances i’d suggest adding labels in those different regions of your image (if necessary -> if you see the prediction is not good enough yet). You have to visually inspect your data with the prediction to be sure it does a decent job.

1 Like

@k-dominik Thanks a lot for the explanations. This clarifies my doubt!
Could you please let me know if you have downsampled the input data?

While trying to locate slice 267 in z-stack , I observed the total number of slices in the z-stack displayed in that snapshots posted above is 533. In the original data, I find 1294 slices.

May be you have used a different input file from the same link? this file ?

Could you please offer some advice on the export options?

I’m trying to save the output as a simple segmentation in prediction export for reconstructing ta 3D volume (like this) .

I’m referring to the documentation available here, it is mentioned

If you choose to save a simple segmentation, the result will be a label image, where pixels are assigned the value of the most probable class.

Could you please suggest how to check which is the most probable class?

I have also checked the renormalize and converted the data type to uint8 to view the output in other software. I want to save all slices in the z-stack in a single file. I found tif sequence, tiff sequence,
multipage tiff and multipage tiff sequence options available. May I know which format has to be selected?

Hi @Deepa,

all this depends a bit on how you intend to use the data afterwards. May I ask which tool you are using to do the 3D rendering?

Cheers
Dominik

Hi @k-dominik

Definitely, I am using 3D Slicer for volume rendering.

I knew it looked familiar.

Unfortunately the slicer download doesn’t work for me at the moment, so I couldn’t try this out.

I’m pretty sure slicer should be able to load a multipage tiff file, so maybe export to that.
I would suggest not to export the simple segmentation, but rather the probability map and change the following export settings in ilastik:

  • in the table where it says cutout subregion uncheck c and select the channel/label you have predictions for the vessels. E.g. would you have them as the first label (yellow per default) you’d set this to 0, 1 (this selects channel 0 to be exported (lower value is inclusive, upper value is exclusive). If you have you vessels marked in the second label you’d set it to 1, 2, if its in the third label 2, 3. The goal is to have only one channel in the exported image.
  • convert to datatype: unsigned 8-bit. This will save you quite some disk space and in this data type slicer is more likely to open the image
  • renormalize: 0.00, 1.00 to 0, 255. This is a consequence of changing the data type.

This will export that somewhat smooth probability map. In slicer in the volume rendering you should be able to adjust some kind of thresholds in the volume rendering panels to adjust the transfer function. That way you have more flexibility (volume properties, scalar opacity mapping).

Are you set on slicer for a particular reason? If not I’d probably suggest to use napari (which would probably involve some minimal coding).

1 Like

Yes, I could load multipage tiff in Slicer.

Yes :slight_smile: I use some of the extensions available in Slicer for further analysis of the 3D volume.

Adjusting the transfer function might be a bit challenging for me since my knowledge on this is limited. I will definitely give this a try ad update my progress here.

Thanks a lot for the tremendous support

Cheers
Deepa

@k-dominik

I just wanted to keep you posted that the I could successfully import the probability map
in Slicer.’

Thank you very much for all your adivce. ilastik is wonderful.

1 Like

Awesome, thank you very much for staying with it until it worked :slight_smile: and also for this update! Have a great weekend

1 Like

Hi @k-dominik

This time I tried with a different image stack ( data)

But I couldn’t obtain a clear classification of the blood vessels and the tissue region. I used labels like mentioned in the example posted above.

I’m sharing the project file generated in ilastik, could you please have a look?
ref : dataset

The following is the snapshot of the output tiff generated. The output from ilastik has been loaded in Slicer.
Untitled

Hi @k-dominik
This is a kind reminder

Hi @Deepa,

I remember trying, but couldn’t open the project you have uploaded for some reason. Could you please verify that you can open it (or re-upload) if it is not the case?
Cheers
Dominik

Hi @k-dominik

Thanks a lot for the response.
Could you please check this project file again? I’ve re-uploaded the file.