Failing Slicer Extension Test - ITK cannot load test image

System: Win 10 64 Bit Visual Studio 2013

Dear all,

I’m trying to debug a test executable of a Slicer Extension (PkModeling). The problem is that running the test, which processes an image, fails in itkImageFileReader.hxx with this error:

File: d:\sd\itkv4\modules\io\imagebase\include\itkImageFileReader.hxx
Line: 143
Description:  Could not create IO object for reading file 
  Tried to create one of the following:
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.

The project is set up as superbuild and can be build Standalone and as Slicer Extension. The test works fine in standalone but fails when build as extension (build against the ITK in Slicer). I have no idea what’s going on, and why ITK thinks it cannot load a nrrd file.

Debugging into it confirmed that in ImageIOFactory::CreateImageIO the call to ObjectFactoryBase::CreateAllInstance(“itkImageIOBase”) doesn’t return any ImageIOBase object that could handle an “nrrd” file.

I’m suspecting I am missing smth in my cmake configuration, since other extensions (e.g. DCMQI) built as Slicer Extension against the same ITK doesn’t have this problem :confused:

MRMLIDImageIO is a special IO class that allows passing images between Slicer and CLI modules without writing them to file. One way of disabling it is to only create executable CLI by adding EXECUTABLE_ONLY in your CMakeLists.txt file:

  LOGO_HEADER ${Slicer_SOURCE_DIR}/Resources/NAMICLogo.h

You may also temporarily disable the mechanism by enabling Prefer executable CLIs option in Application settings / Modules.

Hi Andras,

Both options are already active (EXECUTABLE_ONLY in SEMMacroBuildCLI and “Prefer executable CLIs” in Slicer itslef).

If you don’t use MRMLIDImageIO then it means that standard ITK image IO factory classes are not registered. Compare CMakeLists.txt and source code of your CLI to other CLIs that can read images, there are probably 1-2 lines missing from your code.

Thx, I think I found it Apparently these lines in the cmake for the test did the trick:

if(TARGET ITKFactoryRegistration)
  target_compile_definitions(${CLP}Test PUBLIC HAS_ITK_FACTORY_REGISTRATION)

However I don’t completely understand why this didn’t cause an issue for the standalone build (i.e. not as slicer extension)?

Hi @mschwier,

The ITKFactoryRegistration is a library specific to Slicer that was used to workaround a limitation of ITK. For some background info, read here

That said, when building Slicer against Slicer, these extra lines should not be needed. The variable ITK_LIBRARIES is automatically updated …

Also, a specific command line wrapper is used:

Thanks for the explanation @jcfr

But does this

mean, that there must be something else fishy about my setup, since I needed to add these lines to make it work? :confused: