I don'n know what's this? But I want to know what's this lol
by Mark Geurts mark.w.geurts@gmail.com
Copyright © 2016, University of Wisconsin Board of Regents
The DICOM Manipulation Tools for MATLAB are a compilation of functions that read and write DICOM RT files. These tools are used in various applications, including exit_detector, systematic_error and mvct_dose. MATLAB is a registered trademark of MathWorks Inc.
To install the DICOM Manipulation Tools, copy all MATLAB .m files from this repository into your MATLAB path. If installing as a submodule into another git repository, execute git submodule add https://github.com/mwgeurts/dicom_tools
.
The DICOM Manipulation Tools have been validated for MATLAB versions 8.3 through 8.5 on Macintosh OSX 10.8 (Mountain Lion) through 10.10 (Yosemite). These tools use the Image Processing Toolbox MATLAB functions dicominfo()
, dicomread()
, and dicomwrite()
to read and write to the provided DICOM destination files.
The following subsections describe what inputs and return variables are used, and provides examples for basic operation of each tool. For more information, refer to the documentation within the source code.
LoadDICOMImages()
loads a series of single-frame DICOM CT images and returns a formatted structure for dose calculation. See below for more information on the structure format. This function will display a progress bar while it loads (unless MATLAB was executed with the -nodisplay
, -nodesktop
, or -noFigureWindows
flags).
Note, non-HFS and multi-frame datasets have not currently been tested, so their compatibility with this function is unknown.
The following variables are required for proper execution:
The following variables are returned upon succesful completion:
Below is an example of how this function is used:
path = '/path/to/files/';
names = {
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.1.dcm'
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.2.dcm'
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.3.dcm'
};
image = LoadDICOMImages(path, names);
LoadDICOMStructures()
loads a DICOM RT Structure Set (RTSS) file andextracts the structure information into a MATLAB cell array. See below for more information on the structure format. This function mayoptionally also be passed with an atlas, whereby only structures matchingthe atlas include/exclude statements are returned. This function will display a progress bar while it loads (unless MATLAB was executed with the -nodisplay
, -nodesktop
, or -noFigureWindows
flags).
The following variables are required for proper execution:
LoadDICOMImages()
for more information. The following variable is returned upon succesful completion:
Below are examples of how this function is used:
% Load DICOM images
path = '/path/to/files/';
names = {
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.1.dcm'
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.2.dcm'
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.3.dcm'
};
image = LoadDICOMImages(path, names);
% Load DICOM structure set
name = '2.16.840.1.114362.1.5.1.0.101218.5981035325.299641579.747.dcm';
structures = LoadDICOMStructures(path, name, image);
% Load structure set again, this time with atlas
atlas = LoadAtlas('atlas.xml');
structures = LoadDICOMStructures(path, name, image, atlas);
LoadDICOMDose()
loads a DICOM RTDose object into a MATLAB structure that can be used for manipulation with other functions in this library.
The following variables are required for proper execution:
The following variables are returned upon succesful completion:
Below is an example of how this function is used:
path = '/path/to/files/';
name = '1.2.826.0.1.3680043.2.200.1679117636.903.83681.339.dcm';
dose = LoadDICOMDose(path, name);
WriteDICOMImage()
saves the provided image array to a series of DICOM CT files. If DICOM header information is provided in the third input argument, it will be used to populate the DICOM header for associating the image set with a DICOM RTDOSE file.
The following variables are required for proper execution:
LoadDICOMImages()
for more information on the format of this object. Start and widths are in cm. The following variables are returned upon successful completion:
Below is an example of how this function is used:
% Create a random array of dose values with 120 slices
image.data = rand(512, 512, 120);
% Specify start coordinates of array (in cm)
image.start = [-25, -25, -15];
% Specify voxel size (in cm)
image.width = [0.098, 0.098, 0.25];
% Declare file name prefix and path to write dose to
dest = '/path_to_file/images';
% Declare DICOM Header information
info.patientName = 'DOE,JANE';
info.patientID = '12345678';
info.frameRefUID = ...
'2.16.840.1.114362.1.6.4.3.141209.9459257770.378448688.100.4';
% Execute WriteDICOMImage
WriteDICOMImage(image, dest, info);
WriteDICOMStructures()
saves the provided structure set to a DICOM file.
The following variables are required for proper execution:
LoadDICOMStructures()
for more information on the format of this object. Point positions are in cm.The following variables are returned upon successful completion:
WriteDICOMDose()
saves the provided dose array to a DICOM RTDOSE file. If DICOM header information is provided in the third input argument, it will be used to populate the DICOM header for associating the DICOM RTDOSE file with an image set.
The following variables are required for proper execution:
LoadDICOMDose()
for more information on the format of this object. Start and widths are in cm.Below is an example of how this function is used:
% Create a random array of dose values with 120 slices
dose.data = rand(512, 512, 120);
% Specify start coordinates of array (in cm)
dose.start = [-25, -25, -15];
% Specify voxel size (in cm)
dose.width = [0.098, 0.098, 0.25];
% Declare file name and path to write dose to
dest = '/path_to_file/dose.dcm';
% Declare DICOM Header information
info.patientName = 'DOE,JANE';
info.patientID = '12345678';
info.frameRefUID = ...
'2.16.840.1.114362.1.6.4.3.141209.9459257770.378448688.100.4';
% Execute WriteDICOMDose
WriteDICOMDose(dose, dest, info);
WriteDICOMTomoPlan()
saves the provided tomotherapy plan structure to a DICOM RTPlan file. If the patient demographics (name, ID, etc) are not included in the plan structure, the user will be prompted to provide them.
The following variables are required for proper execution:
The following variables are returned upon successful completion:
Below is an example of how this function is used (the functions FindPlans()
and LoadPlan()
are from the tomo_extract repository:
% Look for plans within a patient archive
plans = FindPlans('/path/to/archive', 'name_patient.xml');
% Load the first plan
plan = LoadPlan('/path/to/archive', 'name_patient.xml', plans{1});
% Execute WriteDICOMTomoPlan
dest = '/file/to/write/plan/to/info.dcm';
WriteDICOMTomoPlan(plan, dest);
WriteDVH()
computes the DVH for each structure included in the image input variable given the dose input variable and writes the resulting DVHs to a comma-separated value file. The DVHs can also be optionally returned as an array. Note, if a DVH filename is not provided in the third input argument, WriteDVH will simply compute the DVH from the image, structures, and dose and optionally return the array.
The first row contains the file name, the second row contains column headers for each structure set (including the volume in cc in parentheses), with each subsequent row containing the percent volume of each structure at or above the dose specified in the first column (in Gy). The resolution is determined by dividing the maximum dose by 1001.
The following variables are required for proper execution:
LoadDICOMImages()
and LoadDICOMStructures()
for more information on the format of this object.The following variables are returned upon succesful completion:
Below are examples of how this function is used:
% Load DICOM images
path = '/path/to/files/';
names = {
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.1.dcm'
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.2.dcm'
'2.16.840.1.114362.1.5.1.0.101218.5981035325.299641582.274.3.dcm'
};
image = LoadDICOMImages(path, names);
% Load DICOM structure set into image structure
name = '2.16.840.1.114362.1.5.1.0.101218.5981035325.299641579.747.dcm';
image.structures = LoadDICOMStructures(path, name, image);
% Create dose array with same dimensions and coordinates as image
dose.data = rand(size(image.data));
dose.width = image.width;
dose.start = image.start;
% Declare file name and path to write DVH to
dest = '/path_to_file/dvh.csv';
% Execute WriteDVH
WriteDVH(image, dose, dest);
% Execute WriteDVH again, this time returning the DVH as an array
dvh = WriteDVH(image, dose, dest);
% Compute but do not save the DVH to a file
dvh = WriteDVH(image, dose);
These functions optionally return execution status and error information to an Event()
function. If available in the MATLAB path, Event()
will be called with one or two variables: the first variable is a string containing the status information, while the second is the status classification (WARN or ERROR). If the status information is only informative, the second argument is not included. Finally, if no Event()
function is available errors will still be thrown via the standard error()
MATLAB function.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.