Using SimpleItk in loadable modules

Hi everyone,

I would like to use SimpleItk while writting a loadable module.
My problem is about including the necessary files:
#include <sitkCenteredTransformInitializerFilter.h> for example doesn’t work, I get the error “file not found”

I know that Slicer’s architecture is complex and I’m not sure how to include SimpleItk/the necessary files in a loadable module. I tried the different ways I could find in SimpleItk examples (in the official documentation, so not using Slicer) but I didn’t succeed.

(I did build Slicer with SimpleItk).

Thanks for your help,

Sandra.

Hi Sandra,

I think SimpleITK has wrappers for Python, C#, Java and R, but for C++ you should use ITK directly.

You mean that in general it isn’t possible to use simpleItk with C++ or it isn’t possible in Slicer particularly ?

In general:

I saw this page where there are examples of simpleItk used in C++

https://itk.org/SimpleITKDoxygen/html/examples.html

I didn’t know about those, sorry.

In general, it is indeed possible to use SimpleITK from C++, but I don’t know of any examples in Slicer. @blowekamp would know for sure!

While possible, the build system currently do not enable this.

In a nutshell, the SimpleITK targets (available through SimpleITKConfig.cmake) are not exposed to extensions. Only ITK is.

To keep things simple, I suggest we stick to ITK when dealing with C++ and image processing.

I have a module, which is still compiling, that uses SimpleITK in this way. The NucleusClosing module uses the c++ interface for SimpleITK. It still seems to work.

HTH
Brad

1 Like

Indeed :smile: , we are marking SimpleITK as FIND_PACKAGE … and the targets end up being exposed.

So @blowekamp what did you do to have simpleItk working in your loadable module ?

@jcfr : do I have to write these 4 lines somewhere or are they already present in the slicer’s architecture ?

Hi @sandra,

You only need to “link” against the SimpleITK targets as it is done here:

In the case of loadable modules, you would add ${SimpleITK_LIBRARIES} to the TARGET_LIBRARIES parameter of the logic:

The first step is to find the SimpleITK package in CMake:

Then as JC said you need to link against the SimpleITK libraries.

Ok and those lines about find the SimpleITK package, where should I write them (for a loadable module) ? (In which CMakeLists.txt)