Instructions/Advice for adding ThresholdMaximumConnectedComponentsImageFilter or AutomaticThresholdImageFilter as a segment editor effect

I’m interested in using this filter since it allows to get the threshold value that maximizes the number of islands in an image. I want to use this value as input for another filter. So I was thinking in adding this filter to Slicer as an effect for those who are interested in using it.

Here is the related publication: https://insight-journal.org/browse/publication/40
Although it is already implemented on itk I don’t know if it lacks some flexibility since the source code of the publication says:

This algorithm optimizes hollow myofibers (ie white doughnuts). If you want to automatically threshold a picture of white islands (ie dapi nuclei, a solid cell) should invert the threshold inside (m_InsideValue) and outside (m_OutsideVaalue) values in the cons

I would want to have an option to switch between both modes: solid-islands and donut-islands.
Also I want the optimal threshold value to be accesible from the effect and performing the segmentation should be optional. Or maybe the user should instantiate the filter and get those values through code

For these reasons I would like to add the filter to vktITK folder. I’m looking for instructions because I’m new to C++. I added the cxx to the source files on cmakefile and also added the itkModules it uses to the list that was on the cmakefile, but probably itkModuleNames have changed after more than 15 years. I don’t expect it to work. I’m building right now.

Some guidance regarding this endeavour would be appreciated. Thank you

In extensions, we usually create a CLI module to make available ITK filters in Slicer. CLI modules have a basic GUI, so it is already accessible for end users, but often a Python scripted module is added that provides a more convenient user interface.

That said, I’m not sure if it is worth spending much time with such ad hoc methods. The main idea of tuning processing parameters to obtain maximum number of islands is questionable, as noise, image texture, artifacts, and irrelevant image parts may influence the results. You can reduce the effect of these by adding pre and post processing steps, but then you end up with a slow, complex, hard-to-control method and you need to optimize it by running it on many data sets. Until about 5 years ago it was pretty standard to do this manually: you could write a masters or PhD thesis out of it, regardless of how well the method worked in practice. Today, you would only need to do the testing data collection and you would let the GPU find a optimal processing method and parameters via deep learning.

Important additional advantages of using deep learning (regardless of performance):

  • you don’t have to defend your decision of investing time into testing and optimizing a classic method when “AI” is the default today
  • you obtain more experience in a marketable skill (using “AI” for medical image computing)
  • achieving the same results using “AI” is often worth more than solving it with a classic method, because investors, companies, funding agencies believe that AI is the future and want to invest into that, while they are anxious if their money is spent on developing classic methods; this is not rational and in a few years this may change but I stillbregularly experience that this bias - hype - towards AI.