Performing ABAS and MBS segmentations by ITK

Hi every one,
I want to start a project which is contouring CT images using Atlas Based Auto Segmentation (ABAS) and Model Based Segmentation (MBS). As you probably know most of the state of the art contouring softwares have these options. I want to know:
Does ITK have the capability to develop ABAS or MBS??? Or I should develop those algorithms from scratch? If ITK has this capability, how effective is its performance?
Any suggestion would be welcomed,
Thank you in advance for your response

ITK has components for such methods. But as these methods need to be tuned to modality and sometimes anatomy, ITK doesn’t have a built-in method for that.

One existing implementation which heavily uses ITK is MABMIS. I did code maintenance and made some improvements to it about a year ago. You can get it from my fork. You can take this as a starting point and improve it. There are others, e.g. PICSL.

Of course, you can start from scratch. But be warned - that is very time-consuming.

3 Likes

Thank you in advance @dzenanz. Your response is so helpful and I think this could be a good start for me.

@dzenanz, I take a look at links you sent me. Thank you again, You aware me about a world of works done in this field by NITRC and IDEAgroup.
Now I have some questions:
Is it possible that I modify MABMIS to match with my project which is contouring structures in CT images?
To do that, I tried to make your fork by CMake but I faced with this error:

Could not find a package configuration file provided by "Slicer" with any
of the following names:

SlicerConfig.cmake
slicer-config.cmake

There was not such a file in slicer install directory. I think I should make slicer by CMake to correct this error. Am I right?
And another general question:
Is there any free access to source codes contained in https://www.nitrc.org? Or just developers have access? I did some tries but I couldn’t download MABMIS source code by SVN.

I don’t know. I downloaded some releases from NITRC, but the access control to SVN might be on a per-project basis.

To build MABMIS in its current form, you need to have a build of Slicer from source. Then point to Slicer’s inner build directory when configuring MABMIS. For start, use the 4.8.1 version, and if when you get that working properly you could try the latest master version of Slicer.

Slicer is not overly important for the core of MABMIS. It is used for specifying inputs/outputs and auto-generated GUI. Turning MABMIS executables into regular command-line applications would not be hard, if you want to get rid of Slicer as a dependency.

MABMIS was such a project you downloaded from NITRC? It seems that there is no access to its sources…

I got MABMIS from GitHub. But e.g. some of PICSL’s stuff can be downloaded from NITRC.

Hi again @dzenanz,
I have some questions about this sentence, Sorry if these are beginner one;
How I can turning it to cmd app? Does turning MABMIS to cmd app need building it with CMAKE? I do not know what does really occur after building source code. Does it make some libs which we can use them in other projects?
After turning the code into cmd form, Does it allow me to debug the code and make some changes to it, or it could be just use in cmd form?
I know I am asking lots of questions! So if there is a link that describes how I could use these types of codes and what really does building a source code gives us for working, I would be so thankful …

When you build MABMIS as a Slicer extension, you get both DLLs which can be invoked by Slicer, and command-line executables which can be run from Slicer’s command prompt.

Right now, the executables are using Slicer Execution Model (SEM) to define and parse command line parameters. That means you need to come of with your own way of passing parameters, e.g. using positional method (argv[1] … argv[n]) or using another library instead of SEM. But that would allow you not to have Slicer as a dependency, it does nothing for debugging. But MABMIS can be used in other projects too. It depends on ITK and SEM, both of which are CMake-configured libraries.

You can debug MABMIS code right now too. Also modify it and see the effects of modifications. These instructions are for debugging Slicer’s code. Debugging an extension which just points to a build of Slicer might be even easier. Either way, when you build both Slicer and MABMIS, you need to turn on debug symbols, i.e. build both in Debug mode. Put a breakpoint somewhere in the code and run one of the executables under debugging.

2 Likes

Thanks for your comprehensive and even exemplary answer. I will work on all topics you mentioned.

Hi @dzenanz. I had an eye surgery and I wasn’t able to work for these weeks. I built MABMIS and I have two questions:
First how I can add MABMIS to slicer? You know there is no extension for MABMIS in slicer extension manager.
And second for debugging MABMIS functions What I am doing now is right clicking on projects and setting them as StartUp project. Am I right? It has errors in this way. It says Some dlls are missing from your computer (ITK-statistics-4.13.dll and IGR3D_MABMIS_TrainingLib.dll)
Once again I thank you…

To add it to Slicer, put MultiAtlas in Slicer-source\Modules\CLI\MultiAtlas, add it to the list of cli_modules, then do a clean build.

Setting MABMIS executables as startup projects is fine. What you apparently didn’t do is follow the debugging instructions, i.e. start VS via command Slicer.exe --VisualStudio

Probably an easier way is to follow the extension documentation.

1 Like

I add the folder MultiAtlas to the modules directory and also its name to the cli_modules but Slicer did not built in this mode.

Hi @dzenanz and thanks for your helps.
As you know I built slicer with MABMIS. I tested it in slicer GUI with its provided data successfully.
I have two questions:
1- I expected the program to wait before my breakpoints but it did not do so. Have I forgot something?
2- I have a set of dicom images in which I want to test and develop MABMIS. How I can prepare my data to feed it into MABMIS? I mean for example creating label maps or converting inputs into .nii format, just like what MABMIS expected.
Any other suggestion would be welcomed…

1 - Follow Slicer’s debugging instructions. They are less inconvenient than alternative. The alternative: modify the executables to wait for a key to be pressed at the start, while the program waits use “attach to process” option in the compiler, then press a key in the program and your breakpoints should be hit.

2 - Open your DICOM data in Slicer using DICOM module and save it in a single-file file format such as .mha, .nrrd, .nii, .nii.gz etc.

Creating label maps is done by segmentation, which is usually quite a task in itself. You can use manual segmentation, or some automated method.

Thanks @dzenanz a lot for your helps, steps I am doing for debugging are as follows (coresponding to the debugging instructions):
1- Starting visuall stadio using Slicer.exe --VisualStudio command.
2- As debugging instructions said I Set SlicerApp as StartUp Project.
3- Running Local windows debugger.

I expected the program wait before breakpoints in Training.cxx but it did not do so. I also Set IGR3D_MABMIS_Training progect as sturtup project. This time it went to the SEMCommandLineLibraryWrapper.cxx but it didn’t go to source .cpp files(I mean for example training.cpp and testing.cpp).

Both of those scenarios should have worked, even if you didn’t build Slicer in Debug or RelWithDebInfo mode. Especially setting the command line app as startup project should have worked. If it did enter the executable but not the main, maybe you need proper command line arguments. You can look at the Slicer’s log to see what command line parameters are passed to IGR3D_MABMIS_Training. Then add those parameters for debugging IGR3D_MABMIS_Training.

You can also try invoking IGR3D_MABMIS_Training from the command line. To get a command line with paths set to all the required DLLs, start it via Slicer.exe --cmd command.

And what does the command line program output the the console or Slicer’s log (Menu->View->Error log, shortcut Ctrl+0)?