matRad_importDicomRTPlan

Purpose ^

matRad function to import dicom RTPLAN data

Synopsis ^

function pln = matRad_importDicomRTPlan(ct, rtPlanFiles, dicomMetaBool)

Description ^

 matRad function to import dicom RTPLAN data
 
 call
   pln = matRad_importDicomRTPlan(ct, rtPlanFiles, dicomMetaBool)

 input
   ct:             ct imported by the matRad_importDicomCt function
   rtPlanFiles:       list of RTPlan Dicom files
   dicomMetaBool:  import whole dicom information

 output
   pln:            matRad pln struct with meta information. Note that
                   bixelWidth is determined via the importSteering function.

 References
   -

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Copyright 2015 the matRad development team. 
 
 This file is part of the matRad project. It is subject to the license 
 terms in the LICENSE file found in the top-level directory of this 
 distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 
 of the matRad project, including this file, may be copied, modified, 
 propagated, or distributed except according to the terms contained in the 
 LICENSE file.

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cross-reference information ^

This function calls: This function is called by:

Source code ^

0001 function pln = matRad_importDicomRTPlan(ct, rtPlanFiles, dicomMetaBool)
0002 % matRad function to import dicom RTPLAN data
0003 %
0004 % call
0005 %   pln = matRad_importDicomRTPlan(ct, rtPlanFiles, dicomMetaBool)
0006 %
0007 % input
0008 %   ct:             ct imported by the matRad_importDicomCt function
0009 %   rtPlanFiles:       list of RTPlan Dicom files
0010 %   dicomMetaBool:  import whole dicom information
0011 %
0012 % output
0013 %   pln:            matRad pln struct with meta information. Note that
0014 %                   bixelWidth is determined via the importSteering function.
0015 %
0016 % References
0017 %   -
0018 %
0019 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 %
0021 % Copyright 2015 the matRad development team.
0022 %
0023 % This file is part of the matRad project. It is subject to the license
0024 % terms in the LICENSE file found in the top-level directory of this
0025 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0026 % of the matRad project, including this file, may be copied, modified,
0027 % propagated, or distributed except according to the terms contained in the
0028 % LICENSE file.
0029 %
0030 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 
0032 %% load plan file
0033 % check size of RT Plan
0034 if size(rtPlanFiles,1) ~= 1
0035    errordlg('Too few or to many RTPlan files')
0036 end
0037 
0038 % read information out of the RT file
0039 if verLessThan('matlab','9')
0040     planInfo = dicominfo(rtPlanFiles{1});
0041 else
0042     planInfo = dicominfo(rtPlanFiles{1},'UseDictionaryVR',true);
0043 end
0044 
0045 % check which type of Radiation is used
0046 if isfield(planInfo, 'BeamSequence')
0047     BeamParam = 'BeamSequence';
0048     ControlParam = 'ControlPointSequence';
0049 elseif isfield(planInfo, 'IonBeamSequence')
0050     BeamParam = 'IonBeamSequence';
0051     ControlParam = 'IonControlPointSequence';
0052 else
0053     errordlg('Not supported kind of DICOM RT plan file.');    
0054 end
0055 
0056 % get beam sequence
0057 BeamSequence = planInfo.(BeamParam);
0058 BeamSeqNames = fieldnames(BeamSequence);
0059 
0060 % use the treatment beams only
0061 if isfield(BeamSequence.(BeamSeqNames{1}),'TreatmentDeliveryType')
0062     for i = 1:length(BeamSeqNames)
0063         currBeamSeq = BeamSequence.(BeamSeqNames{i});
0064         try
0065             treatDelType = currBeamSeq.TreatmentDeliveryType;
0066             if ~strcmpi(treatDelType,'TREATMENT')
0067                 BeamSequence = rmfield(BeamSequence,BeamSeqNames{i});
0068             end
0069         catch
0070             warning('Something went wrong while determining the type of the beam.');
0071         end
0072     end
0073     BeamSeqNames = fieldnames(BeamSequence);
0074 end
0075 
0076 
0077 %% get information may change between beams
0078 % loop over beams
0079 gantryAngles{length(BeamSeqNames)} = [];
0080 PatientSupportAngle{length(BeamSeqNames)} = [];
0081 isoCenter = NaN*ones(length(BeamSeqNames),3);
0082 for i = 1:length(BeamSeqNames)   
0083     currBeamSeq             = BeamSequence.(BeamSeqNames{i});
0084     % parameters not changing are stored in the first ControlPointSequence
0085     gantryAngles{i}         = currBeamSeq.(ControlParam).Item_1.GantryAngle;
0086     PatientSupportAngle{i}  = currBeamSeq.(ControlParam).Item_1.PatientSupportAngle;
0087     isoCenter(i,:)          = currBeamSeq.(ControlParam).Item_1.IsocenterPosition';
0088 end
0089 
0090 % transform iso. At the moment just this way for HFS
0091 if ct.dicomInfo.ImageOrientationPatient == [1;0;0;0;1;0]
0092     isoCenter = isoCenter - ones(length(BeamSeqNames),1) * ...
0093         ([ct.x(1) ct.y(1) ct.z(1)] - [ct.resolution.x ct.resolution.y ct.resolution.z]);
0094 else
0095     error('This Orientation is not yet supported.');
0096 end
0097 
0098 %% read constant parameters
0099 % readout charge and mass to set radiationMode to matRad specific name
0100 radiationMode = planInfo.(BeamParam).Item_1.RadiationType;
0101 if ~strncmpi(radiationMode,'photons',6)
0102     try
0103         radiationMass = planInfo.(BeamParam).Item_1.RadiationMassNumber;
0104         radiationAtomicNumber = planInfo.(BeamParam).Item_1.RadiationAtomicNumber;
0105     catch
0106         warning('Could not determine mass and atomic number of the particle');
0107     end
0108 end
0109 
0110 if strncmpi(radiationMode,'photons',6)
0111     radiationMode = 'photons';
0112 elseif strncmpi(radiationMode,'proton',6)
0113     radiationMode = 'protons';
0114 elseif (strncmpi(radiationMode,'ion',3) && radiationMass == 12 && radiationAtomicNumber == 6)
0115     radiationMode = 'carbon';
0116 else
0117     warning('The given type of radiation is not yet supported');
0118 end
0119 
0120 % extract field shapes
0121 if strcmp(radiationMode, 'photons')
0122            
0123     fractionSequence         = planInfo.FractionGroupSequence.Item_1;
0124     pln.propStf.collimation  = matRad_importFieldShapes(BeamSequence,fractionSequence);
0125     
0126 end
0127 
0128 %% write parameters found to pln variable
0129 pln.radiationMode   = radiationMode; % either photons / protons / carbon
0130 pln.numOfFractions  = planInfo.FractionGroupSequence.Item_1.NumberOfFractionsPlanned;
0131 pln.machine         = planInfo.(BeamParam).Item_1.TreatmentMachineName;
0132 
0133 pln.propStf.isoCenter    = isoCenter;
0134 pln.propStf.bixelWidth   = NaN; % [mm] / also corresponds to lateral spot spacing for particles
0135 pln.propStf.gantryAngles = [gantryAngles{1:length(BeamSeqNames)}];
0136 pln.propStf.couchAngles  = [PatientSupportAngle{1:length(BeamSeqNames)}]; % [°]
0137 pln.propStf.numOfBeams   = length(BeamSeqNames);
0138 
0139 
0140 pln.propOpt.bioOptimization = 'none'; % none: physical optimization;             const_RBExD; constant RBE of 1.1;
0141                                       % LEMIV_effect: effect-based optimization; LEMIV_RBExD: optimization of RBE-weighted dose
0142 pln.propOpt.runSequencing   = false; % 1/true: run sequencing, 0/false: don't / will be ignored for particles and also triggered by runDAO below
0143 pln.propOpt.runDAO          = false; % 1/true: run DAO, 0/false: don't / will be ignored for particles
0144 
0145 % if we imported field shapes then let's trigger field based dose calc by
0146 % setting the bixelWidth to 'field'
0147 if isfield(pln.propStf,'collimation')
0148     pln.propStf.bixelWidth  = 'field'; 
0149 end
0150 
0151 % timestamp
0152 pln.DicomInfo.timeStamp = datestr(clock);
0153 
0154 try
0155    pln.DicomInfo.SOPClassUID = planInfo.SOPClassUID;
0156    pln.DicomInfo.SOPInstanceUID = planInfo.SOPInstanceUID;
0157    pln.DicomInfo.ReferencedDoseSequence = planInfo.ReferencedDoseSequence;
0158 catch
0159 end
0160 
0161 % safe entire dicomInfo
0162 if dicomMetaBool == true
0163     pln.DicomInfo.Meta = planInfo;
0164 end
0165 end

| Generated by m2html © 2005