-
Notifications
You must be signed in to change notification settings - Fork 3
Worked Example
In this example we will demonstrate how to perform a simple head deformation and a structure shift with the CTHeadDeformation code. This code assumes the CTHeadDeformation code is correctly installed.
The data that we will be using from this example comes from the HNSCC database from The Cancer Imaging Archive. Note that this dataset (like most Head and Neck imaging datasets) are not freely available to the public but require a login and for you to request access to the dataset.
Then, download the required data for Patient HNSCC-01-0001. Specifically in the CT and RTStruct data under the 'RT Simulation'.
For this example we are assuming that the data is stored in a directory 'HNSCCData' on an external drive 'J:/', such that the location of the CT and Structures files are:
CTDirectory = "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/28768"
StructureFile = "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/1.000000-78710/1-1.dcm"
The Json file contains all of the information needed to create the required deformation. We have included examples of json files that can be used to create different deformations. For a simple head rotation, the Json file should be of the format:
{
"name": "",
"InputDirectory": "",
"OutputDirectory": "",
"axes": [1, 0, 0],
"angles": [0],
"coordinates_cutoff": [[0, 0, 0], [0, 0, 0]],
"Oc-C1": [0, 0, 0],
"C1-C2": [0, 0, 0],
"C2-C3": [0, 0, 0]
}
To save our deformed CT Volume to the directory "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/DeformedDicom", we can alter the Json file as such:
{
"name": "HNSCC-01-0001",
"InputDirectory": "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/28768",
"OutputDirectory": "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/DeformedDicom",
"axes": [1, 0, 0],
"angles": [0],
"coordinates_cutoff": [[0, 0, 0], [0, 0, 0]],
"Oc-C1": [0, 0, 0],
"C1-C2": [0, 0, 0],
"C2-C3": [0, 0, 0]
}
Then we can load the dicom data from the InputDirectory into a 3D visual software such as Slicer to view the original CT volume. Using this software we can get the voxel values for the required anatomical landmarks. More information on how to locate the anatomical landmarks required is provided here The Json file then becomes:
{
"name": "HNSCC-01-0001",
"InputDirectory": "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/28768",
"OutputDirectory": "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/DeformedDicom",
"axes": [1, 0, 0],
"angles": [0],
"coordinates_cutoff": [[69,282,259],[51,170,259]],
"Oc-C1": [80,222,252],
"C1-C2": [74,217,252],
"C2-C3": [66,214,252]
}
To rotate the head by an angle of 2.5 degrees to the right the Json file then becomes:
{
"name": "HNSCC-01-0001",
"InputDirectory": "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/28768",
"OutputDirectory": "J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/DeformedDicom",
"axes": [1, 0, 0],
"angles": [2.5],
"coordinates_cutoff": [[69,282,259],[51,170,259]],
"Oc-C1": [80,222,252],
"C1-C2": [74,217,252],
"C2-C3": [66,214,252]
}
To shift the GTV without performing a head rotation the json file would look like:
{
"name":"HNSCC-01-0001",
"InputDirectory":"J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/28768",
"StructureFile":"J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/1.000000-78710/1-1.dcm",
"OutputDirectory":"J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/DeformedDicom",
"Structure_Names":"GTV_66",
"Structure_Shift":[3.8,2.2,0]
}
To create a deformation that rotates the head and does a GTV shift the json file would look like:
{
"name":"HNSCC-01-0001",
"InputDirectory":"J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/28768",
"StructureFile":"J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/1.000000-78710/1-1.dcm",
"OutputDirectory":"J://HNSCCData/HNSCC-01-0001/12-05-1998-RT SIMULATION-43582/DeformedDicom",
"axes":[1,0,0],
"angles":[2.5],
"coordinates_cutoff":[[69,282,259],[51,170,259]],
"Oc-C1": [80,222,252],
"C1-C2": [74,217,252],
"C2-C3": [66,214,252]
"Structure_Names":"GTV_66",
"Structure_Shift":[3.8,2.2,0]
}
An example of how to use the CTHeadDeformation code to deform the dicom CT data using any of the json files we created earlier is shown below:
from DeformHeadCT.DeformVolume import DeformationScript
InputJsonFile = DeformationInfo.json #Change to match the file path for the json files created earlier.
#Pathway to the elastix parameter file in the examples directory
elastixParamFile = 'CTHeadDeformation/examples/Elastix_BSpline_OpenCL_RigidPenalty.txt'
DeformationScript(InputJsonFile,RegParamFile=elastixParamFile)