TissueEngineeringLab / MyoFInDer

Python interface for automatic calculation of the fusion index in muscle cell cultures
https://tissueengineeringlab.github.io/MyoFInDer/
GNU General Public License v3.0
3 stars 1 forks source link

Maximum value of the "Small Objects Threshold" is too small #16

Closed WeisLeDocto closed 9 months ago

WeisLeDocto commented 9 months ago

In the "Settings" window, the "Small Objects Threshold" setting can currently take values ranging from 0 to 100. When processing 20x microscopy images, this maximum value of 100 is still way too small to get rid of all the parasite signals on the nuclei channel. The situation is even worse for 10x images. Below are images demonstrating the problem on 20x images with the setting set to 100.

A simple fix would be to just extend the allowed range for this setting. A maximum value of 1000 should cover most use cases and still allow a fine tuning. This change would be forward-compatible (projects created with anterior versions could run on newer ones), but would break the backward-compatibility.

bitmap

kinelo-san commented 9 months ago

What is this value? Number of pixels per nucleus? Why not making this setting a formula? Average nucleus size +- defined number of standart deviations. In this way it won't matter how heavy the images are. Some people use microscopes that produce have a super high resolution images, then even a 1000 won't be enough I think. Masha

WeisLeDocto commented 9 months ago

Hi Masha,

Explicating the exact effect of each argument in the documentation is also in my ToDo list, precisely in #17. The current effect of the "Small Objects Threshold" setting is to discard any nucleus whose area in pixels (as a surface unit) is less than the given threshold.

Now that I'm giving it more thoughts, I agree that the current implementation of this setting is not optimal. I think so mostly because the area of a nucleus varies like the square of its diameter, which makes the effect of the setting non-linear and therefore unintuitive to tune.

Using the standard deviation might be an option indeed. I think the pros are: it is statistically interpretable, it makes sure that the outliers are removed, it will always work no matter the size of the nuclei, it handles both the upper and lower thresholds. I also see cons though: it might give unexpected results for "exotic" area distributions (e.g. values grouped around two distinct peaks), it is less relevant for images containing few detected objects.

I have another possible solution in mind: exclude nuclei based on the diameter of the circle whose area is the same as the detected nucleus. Rephrased, we would exclude nuclei whose "average" diameter is below the given threshold. Pros: it has a physical meaning (provided that users know the µm/px ratio of their image, which they should), it is more intuitive to tune than the standard deviation (because users are not aware of what the nuclei area distribution looks like), it works the same no matter the number and distribution of detected objects. Cons: might not always exclude outliers depending on the value the user provides, a second setting is necessary for handling the upper threshold, more difficult to explain than the bare area or the standard deviation.

Just for information, here's what the histogram of detected areas looks like for this example image. I guess both of the given implementations are valid, we just need to decide if we want to implement a physics-based or statistics-based criterion.

Weis