Best method for importing CT datasets

Hello all,
I am currently writing a geant4 application to calculate the dose imparted to a sample during a CT scan. Until now I had thought the only way to import data into geant for was to first convert it to a surface mesh (such as stl) and then import that using CADMesh or something similar. However, while I’ve made a lot of progress using that method, I have just found there is another way to import data using DICOM files instead. I do not know anything more about it except that it exists and there is a example of it in the extended session, in hope of saving time would anyone be able to share their experiences on the pros vs cons of each method and whether it is worth switching over?

The dataset i want to import is 8Gb in size (1900x2150x500 pixels) and consists of at minimum three different materials. The main thing I am after right now is which is easier to work with and which will produce the most optimised solid for running x-ray scattering with. For using the stl files I have been imported them and then nesting the inner regions into the outer ones by assigning daughter volumes.

Thanks in advance for the help,

Hi James,

I have made efforts in importing dicom images in geant4. I do not know about the dataset you talking. Are they CT images (RT)? If so you can switch dcmtk to turn on (1) and you can make changes in data new file to check your material and geometry. First line in data new file is responsible for size of voxels (pixels).


Thank you drvijayraj,
I ended up looking through the DICOM code and found they typically constructed the dataset using a G4PVParameterised volume which places a cube at each voxel position of the dataset in a memory efficient manner. Running with this parameterisation is much more efficient and I would recommend it to anyone starting out.

Exactly, and I also would like to add a statement if someone wants to speed up the simulation;
one can turn ON the → SetSkipEqualMaterials to TRUE ; This is very helpful when we down compression to 1 else there is an error over the navigation problem.
Best Regards

Hi I hope you’re fine,
@drvijayraj I want to work with the DICOM example, and import CT images but I can’t figure out how to do it I’m really stuck, I’ve already downloaded DCMTK which I think is capable of converting the DICOM image to a 1.g4dcm file but I don’t know how to activate it in the DICOM example, can you help me and share the steps that I should follow and thank you in advance.

Hi @Ihssane98 ,

Please install dcmtk and define its path,
then you can use cmake to built your project

cmake -DDICOM_USE_DCMTK=1 ../ 

dcmtk supports the conversion of dcm images to g4dcm based on materials and calibration curve.

Hi @drvijayraj
Thank you very much for the time you took to answer me.
I have GEANT4 v11.2 and Ubunto 22.04
I installed DCMTK in this path /home/ihssane/DCMTK/dcmtk-3.6.8-install
After I added this line DCMTK_BASE_DIR: = /home/ihssane/DCMTK/dcmtk-3.6.8-install in the GNUmakefile of DICOM after I executed this command: export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${DCMTK_BASE_DIR} /lib and I uncomment this line #DICOM_USE_DCMTK := true, but when I do the make in the DICOM example I get this error and I can’t find the solution
ihssane@ihssane-HP-EliteBook-840-G4:~/Bureau/DICOM$ make
Making dependency for file …
In file included from /home/ihssane/GEANT4/geant4-v11.2.0-install/include/Geant4/G4VisExecutive.hh:141,
** from**
/home/ihssane/GEANT4/geant4-v11.2.0-install/include/Geant4/G4VisExecutive.icc:142:10: fatal error: QtGlobal: Aucun fichier ou dossier de ce nom
** 142 | #include **
** | ^~**
compilation terminated.
Entering dicomReader …
make[1]: rien à faire pour « obj ».
Compiling …
In file included from /home/ihssane/GEANT4/geant4-v11.2.0-install/include/Geant4/G4VisExecutive.hh:141,
** from**
/home/ihssane/GEANT4/geant4-v11.2.0-install/include/Geant4/G4VisExecutive.icc:142:10: fatal error: QtGlobal: Aucun fichier ou dossier de ce nom
** 142 | #include **
** | ^
compilation terminated.
make: *** [/home/ihssane/GEANT4/geant4-v11.2.0-install/share/Geant4/geant4make/config/binmake.gmk:446 : /home/ihssane/geant4_workdir/tmp/Linux-g++/DICOM/exe/DICOM.o] Erreur 1

Dear @Ihssane98 , in my opinion you first give a try without dcmtk.
compile code using

cmake ../

use anyone g4dcm file provided with the example.

Give a try and check if errors still there.
P.S. : do not define any dcmtk path.

Thank you very much @drvijayraj for your answer
I have already compiled the DICOM example with the g4dcm file provided with the example without dcmtk there is no error.
But my goal is to import my phantom as the DICOM images in the example but I don’t know the steps or modifications I need to do in the DICOM example.


You must install directly in linux OS the following libraries. This will help to get rid of defining dcmtk path.

dcmtk -->version3.6.4-2.1build2
libdcmtk-dev → " same "
libdcmtk14 ----> “same”

After settingup, retry as explained above with dcmtk=1 option.


THANKS dear @drvijayraj for your answers.

I have already associated the DCMTK with the DICOM but I don’t know how I can now import my own scanner images into the DICOM example and the modifications that I have to make can you explain to me the steps that I have to follow, and I really appreciate your help.
please if you have no problem please contact me on my email:


Please readme section 4(a) … You must define the path of dicom images in metafile named as data.dat.
:FILE filepath/xyz.dcm