Counting one class object (number, area, major and minor axis) with ilastik

Hello,

I’m trying to count one class object (as the “Analyze Particle” in Fiji) using ilastik. I’m working on a set of seed images.

Firstly, the pixel classification works well and i got my set of prediction images.
Could I process the image analysis on Ilastik using the object classification? My aim is to the get number of seeds on images and some characteristics as the area, the minor and major axis (like Fit Ellipse on Fiji).
When I try the Object Classification tool of Ilastik, I can’t define one objet as seed on my thresholded image…
Should I process the prediction image on Fiji? I’d like to do all the process on Ilastik and get the same results as Analyze Particle with Fit Ellipse option on Fiji…

If I had to move on Fiji after the pixel classification, can I use my prediction images files (.h5)?

Thanks,

Pierre

Hi @PierreBouillon,

do I understand correctly, that you have (at least) two images:

  1. some image where the seeds are visible (is it one seed per object?)
  2. some image containing where the objects are visible

in order to analyze this kind of data in ilastik efficiently I would recommend to:

  1. Do pixel classification, using both channels stacked with 3 classes: background, seed, object, export the probability map to h5
  2. Go to object classification and do hysteresis thresholding with your prediction image; seed as core, object channel as final. If you have one seed per object you can tick the “Don’t merge objects” checkbox.

You can then train the object classifier, (do you have different kinds of objects?). In any case, you can export a table with all the features that were used in object classification, including the radii of an ellipse fit to each object There is one row for each object in the table, so counting them is trivial.

Here is a quick video for object classification that might help (make sure to enable subtitles):

Thanks for your answer, @k-dominik .

This is an example of image i have to analyze. Sorry if I was not clear enough.

I have one type of objects to analyze: seeds of one species. There are smaller debris and overlapped seeds on some pictures.
I’d like to count the number of seeds in images and calculate measures for every seeds.

ah :slight_smile: okay, so the term seed was clearly misleading here.

In this case you can even go for Pixel Classification first, then Object Classification using the probability map. Just make sure to select the right channel.
Since there might be overlapping objects, you could add classes accordingly:

  • 1 Seed
  • 2 Seeds

as many as you need. The count could then be calculated using the table and checking for the predicted class.

Measures are calculated per object. In case of overlapping objects, these do not characterize single seeds anymore, I’m afraid.

Is this enough to get you started?

I did that and it’s work, thank you @k-dominik :slight_smile:

I have one more question about my first set of results.
What’s the difference between Bounding box max/min 0 and 1. I have two set of results for Center of the object too (0 and 1). I don’t understand why there are two set of measurements…
I suppose that Bounding box max/min correspond to the fitted ellipse minor/major axis and Center of the object are the radii of the seeds?

Hi @PierreBouillon,

you touched upon a matter where we absolutely need to improve our documentation, and we will.

But for now:

  • the _0, _1 (and _2) indices indicate x, y, z. So four the center you have an x, and an y value for each of your seeds.
  • the bounding box is really just an axis aligned box that is just large enough to hold the object. So it gives you the extent of the object in x and y direction, respectively.
  • the Center of the object is defined accordingly

In order to get the data for the fitted ellipse you have to look at

  • the Principal components of the object_... column, with:
    • Principal components of the object_0, Principal components of the object_1 being the x and y value of the vector pointing in the direction of the first radius, and
    • Principal components of the object_2, and Principal components of the object_3 being the x and y value of the second radius that define the ellipse. Note that these are unit vectors and only give you the direction
  • the Radii of the object_..., with:
    • Radii of the object_0 length of the first principle axis
    • Radii of the object_1 length of the second principle axis

Putting it all together, you can construct the whole ellipse for each object by

  1. using the centerpoint,
  2. the Principle Components to get the direction of the axes,
  3. the Radii to get the length of the respective axis

Hope that helps

Cheers
Dominik

Thank you for all these information but I’m not sure to understand what are the radii calculated by Ilastik… Are they the minor (Radii of the object_1) and major (Radii of the object 2) axis of the fitted ellipse?

yes that’s it. As the principle components only give you the direction of the axes.

Ok thank you a lot for your help! :slight_smile: