Computed tomography

From UCL HEP PBT Wiki

Jump to: navigation, search
m
 
Line 1: Line 1:
== <span style="color:#000080"> Introduction </span> ==
== <span style="color:#000080"> Introduction </span> ==
-
This tutorial will based on the DICOM GEANT4 example originally developed by Louis Archambault, Luc Beaulieu and Vincent Hubert-Tremblay. In this example a list of DICOM files (.dcm) are converted to ASCII files (.g4dcm) and binary (.g4bin) that can be read by GEANT4. Each of these files corresponds to a Z slice. Then, the .g4dcm (.g4bin) files are merged into one unique volume and used by GEANT4 to construct the patient geometry and materials.
+
This tutorial is based on the GEANT4 DICOM example originally developed by Louis Archambault, Luc Beaulieu and Vincent Hubert-Tremblay. In this example a list of DICOM files (.dcm) are converted to ASCII files (.g4dcm) and binary files (.g4bin) that can be read by GEANT4. Each of these files corresponds to a Z Computed tomography (CT) slice. Then, the .g4dcm (.g4bin) files are merged into one volume.  
-
The geometry is constructed by voxelizing the volume. There are four navigation algorithms used to create the voxel geometry: '''G4SmartVoxel''', '''G4VNestedParameterisation''', '''G4RegularNavigation''' and '''G4PVReplica'''. In this tutorial we investigate the different geometry implementations. 
+
The geometry is constructed by voxelizing this volume. There are four navigation algorithms used to create the voxel geometry: '''G4RegularNavigation''', '''G4VNestedParameterisation''', '''G4SmartVoxel'''/'''G4VoxelNavigation''' and '''G4PVReplica'''.  
-
The material is constructed by converting the pixel values (Hounsfield numbers) from the DICOM images to densities using  
+
The material for this volume is constructed by converting the pixel values (Hounsfield numbers) from the DICOM images to densities using the [http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/CT2Density.dat Hounsfield scale]. Then, the densities are converted to material types according to this [http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/Materials.txt table].
-
the [http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/CT2Density.dat Hounsfield scale]. Then, the densities are converted to material type according to this [http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/Materials.txt table].
+
-
A simple monenergetic electron beam is simulated using '''G4ParticleGun''' class. The output of the tutorial is a text file with dose deposition in several voxels.
+
A simple monenergetic electron beam is simulated using '''G4ParticleGun''' class. The output of the tutorial is a text file with dose deposition in several voxels. The dose is scored using classes '''G4MutiFunctionalDetector''', '''G4VPrimitiveScorer''', '''G4PSDoseDeposit3D''' and '''G4THitsMap'''.  
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/dicom.png
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/dicom.png
-
This is one of the DICOM files that is used in the tutorial.
+
This is one of the DICOM files used in the tutorial.
-
== <span style="color:#000080"> Setting up the environment </span> ==
+
== <span style="color:#000080"> How to run the tutorial </span> ==
-
; Connect to HEP cluster and create folder DICOMFolder in your area
+
; Connect to the HEP cluster and create folder DICOMFolder in your area
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
ssh -X username@plus1.hep.ucl.ac.uk  
ssh -X username@plus1.hep.ucl.ac.uk  
-
password: type your password here
+
username@plus1.hep.ucl.ac.uk's password: type your password here
-
cd /home/username/
+
[username@plus1 ~]$ mkdir DICOMFolder
-
mkdir DICOMFolder
+
[username@plus1 ~]$ cd DICOMFolder   
-
 
+
-
cd DICOMFolder   
+
</pre>
</pre>
Line 33: Line 30:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
source /unix/pbt/software/dev/bin/pbt-dev.sh   
+
[username@plus1 DICOMFolder]$ source /unix/pbt/software/dev/bin/pbt-dev.sh   
</pre>
</pre>
-
 
-
== <span style="color:#000080"> How to get the code </span> ==
 
; Copy the code to your working directory and rename it
; Copy the code to your working directory and rename it
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cp -r /unix/pbt/tutorials/basic/DICOM .
+
[username@plus1 DICOMFolder]$ cp -r /unix/pbt/tutorials/advanced/DICOM .
    
    
-
mv DICOM DICOM_source
+
[username@plus1 DICOMFolder]$ mv DICOM DICOM_source
</pre>
</pre>
-
 
-
== <span style="color:#000080"> How to run the code </span> ==
 
; Inside /home/username/DICOMFolder/ create a directory
; Inside /home/username/DICOMFolder/ create a directory
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
mkdir DICOM_build   
+
[username@plus1 DICOMFolder]$ mkdir DICOM_build   
</pre>
</pre>
Line 57: Line 50:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
cd DICOM_build  
+
[username@plus1 DICOMFolder]$ cd DICOM_build  
-
cmake -DGeant4_DIR=/unix/pbt/software/dev /home/username/DICOMFolder/DICOM_source  
+
[username@plus1 DICOM_build]$ cmake -DGeant4_DIR=/unix/pbt/software/dev /home/username/DICOMFolder/DICOM_source  
-
make   
+
[username@plus1 DICOM_build]$ make   
</pre>
</pre>
-
; Before running the code you can chose among several voxelisation algorithms. 
+
; Run macro run.mac
-
 
+
-
* Using '''G4RegularNavigation'''
+
-
 
+
-
Special algorithm to navigate in regular voxelised geometries. It includes an option to skip frontiers between voxels when they have the same material i.e. replacing group of voxels with a smaller number of larger voxels. '''G4RegularNavigation''' is the default version of this tutorial. To run with the default settings simply run macro run.mac.
+
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
./DICOM run.mac
+
[username@plus1 DICOM_build]$ ./DICOM run.mac
</pre>
</pre>
-
* Using '''G4NestedParameterization'''
+
== <span style="color:#000080"> How to analyze data </span> ==
 +
 
 +
This is a [http://geant4.web.cern.ch/geant4/UserDocumentation/Doxygen/examples_doc/html/ExampleDICOM.html link] to the official DICOM tutorial explanation notes. We recommend to read it before proceeding with this tutorial.
 +
 
 +
=== <span style="color:#000080"> Text files </span> ===
 +
 
 +
The macro run.mac produces a text file '''dicom.out''' which includes the dose deposition in several voxels.
 +
 
 +
=== <span style="color:#000080"> Run with different settings </span> ===
 +
 
 +
; Chose among several voxelization algorithms
 +
 
 +
* <span style="color:#ff0000"> G4RegularNavigation </span>:
 +
 
 +
'''G4RegularNavigation''' class is the default class for this tutorial. This algorithm skips frontiers between voxels when they have the same material i.e. "replacing group of voxels with a smaller number of larger voxels". 
 +
 
 +
* <span style="color:#ff0000"> G4NestedParameterization </span>:
 +
 
 +
To run with this voxelization algorithm you need to set the variable '''DICOM_NESTED_PARAM'''
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
export DICOM_NESTED_PARAM=1
+
[username@plus1 DICOM_build]$ export DICOM_NESTED_PARAM=1
</pre>
</pre>
-
You can check if you set this environment variable correctly by typing in the command line
+
You can check if it is set correctly by typing in the command line
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
env
+
[username@plus1 DICOM_build]$ env
</pre>
</pre>
-
Then, run the code:
+
Then, compile and run the code:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
./DICOM run.mac
+
[username@plus1 DICOM_build]$ make
 +
 
 +
[username@plus1 DICOM_build]$ ./DICOM run.mac
</pre>
</pre>
-
* Usinging '''G4VoxelNavigation'''
+
* <span style="color:#ff0000"> G4SmartVoxel / G4VoxelNavigation </span>:
Using smart voxels required a huge amount of memory. At /home/username/DICOMFolder/DICOM_source/src/DicomRegularDetectorConstruction.cc set
Using smart voxels required a huge amount of memory. At /home/username/DICOMFolder/DICOM_source/src/DicomRegularDetectorConstruction.cc set
Line 103: Line 112:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
make
+
[username@plus1 DICOM_build]$ make
-
./DICOM run.mac
+
[username@plus1 DICOM_build]$ ./DICOM run.mac
</pre>
</pre>
-
== <span style="color:#000080"> How to analyze data </span> ==
+
; Change the type, energy and position of the incident particle
-
This is a [http://geant4.web.cern.ch/geant4/UserDocumentation/Doxygen/examples_doc/html/ExampleDICOM.html link] to the official DICOM explanation notes. We recommend to read it before proceeding with this tutorial.
+
At /home/username/DICOMFolder/DICOM_source/src/DicomPrimaryGeneratorAction.cc change the following lines:
-
=== <span style="color:#000080"> Text files </span> ===
+
<pre style="color: #800000; background-color: #dcdcdc">
 +
G4ParticleDefinition* particle = particleTable->FindParticle(particleName="e-");
-
The macro run.mac produces a text file which includes the dose deposition in several voxels.
+
fParticleGun->SetParticleEnergy(100.*MeV);
 +
 
 +
fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,0.));
 +
</pre> 
 +
 
 +
You can chose among several particles like "gamma", "e+", "alpha" and "He3". Then, compile and run the code
 +
 
 +
<pre style="color: #800000; background-color: #dcdcdc">
 +
[username@plus1 DICOM_build]$ make
 +
 
 +
[username@plus1 DICOM_build]$ ./DICOM run.mac
 +
</pre>
=== <span style="color:#000080"> Visualisation </span> ===
=== <span style="color:#000080"> Visualisation </span> ===
Line 121: Line 142:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
./DICOM vis.mac
+
[username@plus1 DICOM_build]$ ./DICOM vis.mac
</pre>
</pre>
Line 127: Line 148:
<pre style="color: #800000; background-color: #dcdcdc">
<pre style="color: #800000; background-color: #dcdcdc">
-
dawn g4_00.prim
+
[username@plus1 DICOM_build]$ dawn g4_00.prim
</pre>  
</pre>  
-
This will create 3D image showing the patient geometry and the incident electron beam:
+
This will create 3D image showing the patient geometry and the incident electron beam. The image is big and it takes time to open:
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/g4_03.eps
http://www.hep.ucl.ac.uk/pbt/RadiotherapyWorkbook/skins/common/images/DICOM/g4_03.eps
 +
 +
== <span style="color:#000080"> Files </span> ==
 +
 +
[[List of computed tomography files with brief description]]

Latest revision as of 15:40, 2 September 2014

Personal tools