Building GATE with ITKImageIO support

Dear ITK users

I work with the Monte Carlo based Code of GATE and work on hyperthermia. So I need to use the ITK for running the program related to the optic and thermal output and take the output with the format of .mhd or .hdr.

Unfortunately, after running the program, I take this error:

terminate called after throwing an instance of 'itk::ImageFileReaderException'

  what():  /home/BuildFiles/ITK/InsightToolkit-5.1.0-Source/Modules/IO/ImageBase/include/itkImageFileReader.hxx:136:
 Could not create IO object for reading file output/Mobydose-AbsorptionMap.mhd
  Tried to create one of the following:
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.

Aborted (core dumped)

I use three versions of ITK (4.13, 5.0.1 and 5.1), I have installed ITK in a correct way and all the packages have been installed. I compiled the Gate with ITK too.

I don’t know how to solve this problem.

Has any person had the same problem or is there any person who knows this error.

Thank you very much for your reading and suggestion.

Somayeh Asadi

You might not be requesting all the IO modules, nor MetaIO specifically. How does your CMakeLists.txt look like?

Dear Zukic
Thank you very much for your reply. I downloaded the ITK from the link in bellow:
I followed this instructor to install the downloaded ITK:

First, download the ITK library sources at this address:
Unzip and tar the downloaded file:
tar -xzf InsightToolkit-4.10.xx.tar.gz
Move into the InsightToolkit-4.10.xx directory:
cd InsightToolkit-4.10.xx
In this directory, create a bin/ sub-directory:
mkdir bin
Move into the bin/ sub-directory:
cd bin
Run ccmake as follows:
You will obtain the following screen and you need to configure the different options as follows:

BUILD_EXAMPLES                   ON
BUILD_TESTING                    ON
ITK_WRAP_PYTHON                  OFF

Press 'c' to configure and 'g' to generate the compilation environment.
After this step you will automatically back to the prompt terminal and then, you can launch the compilation:
make -jN (N is the number of processor(s) in your PC)
make install.

I enclosed send you the CMakeLists.txt CMakeLists.txt (23.2 KB)
I don’t know what else I should do. I would be so grateful if you do me a favor and provide me with your guidance.
Somayeh Asadi

This is ITK’s CMakeLists.txt. I meant GATE’s (your program’s) CMakeLists.txt.

Dear Dzenanz
Hope you are well. If you remember last week I asked about the problem for the error related to ITK for running the Gate program. You asked me about CMakeLists.txt.
Because I sent you for ITK you asked me about the CMakeLists.txt for the Gate.
I don’t know why my response was not sent. Since I have still the problem with running my program with Gate, hereby I wanted to send the file again and ask you if you do me a favor and help me to solve this problem. Enclose please find the CMakeLists.txt for Gate.
CMakeLists.txt (12.3 KB)
I would be so grateful if you kindly guide me on how to solve this problem.


If you are using ccmake, the normal way is to change options, then press c to configure, then g to generate, then maybe q to quit. Then run make or ninja, depending on your chosen generator. Alternatively, you could use cmake (not ccmake) or cmake-gui. See a tutorial on using CMake.

Thank you very much for your reply, I use ccmake and did exactly what you said.

Is there anything else that you think may solve this problem if I do?

Thank you again for you time in advance



You are not enabling ITKIOMeta in the set of ITK_COMPONENTS

Add it:

1 Like

You need to add the ITKImageIO module to automatically register the ImageIO factories.

@somayehasadi You would need to increase the minimun ITK version to 4.13 to add ITKImageIO as @blowekamp suggested, but it is indeed much better than adding individual IO modules.

SET(ITK_COMPONENTS ITKImageIO;ITKThresholding;ITKFFT;ITKImageCompose;ITKSmoothing)

Thank you very very much for your response and time.
I have downloaded the ITK version 4.13 from the link in bellow:
In the folder of the source, there are ITK modules so I don’t know what anything else could be wrong in this regard. Maybe I didn’t understand well because I thought when you download the full package of ITK and install it you will have the modules in the source folder and I should say that I also check in the folder of source and found there is ITKImageIO inside. I would be so grateful if you kindly let me know and guide me if I am making a mistake or misunderstood.
I am eagerly waiting to have your comment.


The problem is in YOUR project CMakeLists.txt (GATE) using ITK, not in ITK itself. Please re-read the answers.

You will need to re-build your project (GATE) with the modification of CMakeLists.txt suggested before:

SET(ITK_COMPONENTS ITKImageIO;ITKThresholding;ITKFFT;ITKImageCompose;ITKSmoothing)

And run again the script reading the .mhd image.

You are doing the build of ITK well, so no worries about it.
But you are using that ITK recently built in other project (GATE), you have to modify GATE CMakeLists.txt to read your mhd image. And re-build GATE after the modification.

1 Like

Dear Pablo
Thank you very very much for your clear explanation. According to the instructor for installing the Gate and ITK that I followed it from the link in bellow:

I installed the Gate then installed the ITK and compile the Gate with that. I checked the CMakeList.txt for Gate and you are right I saw the part related to ITK is set to OFF.
I enclosed send you an image that can show you what I am mean.
Although when I was installing and compiling the Gate, there is an icon in which we can set the part for ITK to ON and I did it, after installing the Gate and then after installing the ITK, when I check the CMakeList of GATE I find it still being set to off.
I wanted to consult with you whether you think it might be because of installing the Gate first then installing the ITK? This order recommends in the instructor but It might be the opposite.
I would be so grateful if you kindly provide me with your suggestion and idea.


Hi @somayehasadi, the CMakeList.txt is fixed, it does not change when you build/install the project.
To see the options enabled for your current build of Gate, go to your build folder of Gate and type ccmake . or open CMakeCache.txt file in an editor, you can find it in the build folder as well.

This question is more about basic usage of CMake now, I would recommend you ask your instructor, or read some docs about CMake usage.

If you decide that GATE uses ITK, you need to build ITK first. It seems you have done it already.

# Build ITK (if not done already)
# Modify CMakeLists.txt in Gate source folder:
# SET(ITK_COMPONENTS ITKImageIO;ITKThresholding;ITKFFT;ITKImageCompose;ITKSmoothing)
cd /path/to/build_gate
cmake -DGATE_USE_ITK:BOOL=ON -DITK_DIR:PATH=/path/to/build_itk /path/to/gate_source_dir
# You can also use ccmake . and choose options with a graphical interface. 

If you have installed ITK in your system, you might not need the ITK_DIR option.

But, again, read about how CMake works and ask your instructor.

A final note, could you please change the title of this post to: Building GATE with ITKImageIO support or similar. Thanks!


Dear Pablo
I really appreciate the time you took to explain by details and it was so good. I will try to follow this guidance and check if I can solve the problem. I will inform you here soon.
For sure I will change the title.
Thank you for your time and consideration.


Dear Pablo
Sorry if I send you message again, according to your last message, you asked me to change the title of this post, when I wanted to edit the title, the icon is not active so if you let me know how to edit and change the title, for sure I will do that.
Thank you

I changed the title. I don’t know whether the time expired for your ability to change the title, or whether only moderators/administrators can do it.

I am not sure, I tried to do myself but I couldn’t, By the way it has been changed now and I should say thank you.

Thank you @dzenanz and @phcerdan for taking the time to look into this. I have reported the discussion to the corresponding Gate issue, hopefully someone will take the time to fix it soon.

1 Like