matRad function to interpolate a given Dicom Dose Cube dicom RTDOSE data call [ dose ] = matRad_interpDicomDoseCube( ct, currDose ) input ct: ct imported by the matRad_importDicomCt function currDose: one (of several) dose cubes which should be interpolated output dose: struct with different actual current dose cube and several meta data 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. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [ dose ] = matRad_interpDicomDoseCube( ct, currDose ) 0002 % matRad function to interpolate a given Dicom Dose Cube dicom RTDOSE data 0003 % 0004 % call 0005 % [ dose ] = matRad_interpDicomDoseCube( ct, currDose ) 0006 % 0007 % input 0008 % ct: ct imported by the matRad_importDicomCt function 0009 % currDose: one (of several) dose cubes which should be interpolated 0010 % 0011 % output 0012 % dose: struct with different actual current dose cube and several 0013 % meta data 0014 % 0015 % References 0016 % - 0017 % 0018 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0019 % 0020 % Copyright 2015 the matRad development team. 0021 % 0022 % This file is part of the matRad project. It is subject to the license 0023 % terms in the LICENSE file found in the top-level directory of this 0024 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0025 % of the matRad project, including this file, may be copied, modified, 0026 % propagated, or distributed except according to the terms contained in the 0027 % LICENSE file. 0028 % 0029 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0030 0031 % read information out of the RT file 0032 dosefile = currDose{1}; 0033 if verLessThan('matlab','9') 0034 doseInfo = dicominfo(dosefile); 0035 else 0036 doseInfo = dicominfo(dosefile,'UseDictionaryVR',true); 0037 end 0038 0039 % read the dosefile itself 0040 dosedata = dicomread(dosefile); 0041 dose.cube = double(dosedata); 0042 % dose.cube = single(dosedata); 0043 0044 % give it an internal name 0045 dose.internalName = currDose{12}; 0046 0047 % read out the resolution 0048 dose.resolution.x = doseInfo.PixelSpacing(1); 0049 dose.resolution.y = doseInfo.PixelSpacing(2); 0050 dose.resolution.z = doseInfo.SliceThickness; 0051 0052 % target resolution is ct.resolution 0053 target_resolution = ct.resolution; 0054 0055 % convert dosedata to 3-D cube 0056 dose.cube = squeeze(dose.cube(:,:,1,:)); 0057 0058 % ct resolution is target resolution, now convert to new cube; 0059 0060 % generating grid vectors 0061 x = doseInfo.ImagePositionPatient(1) + doseInfo.ImageOrientationPatient(1) * ... 0062 doseInfo.PixelSpacing(1) * double([0:doseInfo.Columns - 1]); 0063 y = doseInfo.ImagePositionPatient(2) + doseInfo.ImageOrientationPatient(5) * ... 0064 doseInfo.PixelSpacing(2) * double([0:doseInfo.Rows - 1]); 0065 z = [doseInfo.ImagePositionPatient(3) + doseInfo.GridFrameOffsetVector]; 0066 0067 % set up grid matrices - implicit dimension permuation (X Y Z-> Y X Z) 0068 % Matlab represents internally in the first matrix dimension the 0069 % ordinate axis and in the second matrix dimension the abscissas axis 0070 [ X, Y, Z] = meshgrid(x,y,z); 0071 [Xq, Yq, Zq] = meshgrid(ct.x,ct.y,ct.z); 0072 0073 % get GridScalingFactor 0074 gridScale = double(doseInfo.DoseGridScaling); 0075 % rescale dose.cube 0076 dose.cube = gridScale * dose.cube; 0077 0078 % interpolation to ct grid - cube is now stored in Y X Z 0079 dose.cube = interp3(X,Y,Z,dose.cube,Xq,Yq,Zq,'linear',0); 0080 0081 % write new parameters 0082 dose.resolution = ct.resolution; 0083 dose.x = ct.x; 0084 dose.y = ct.y; 0085 dose.z = ct.z; 0086 0087 % write Dicom-Tags 0088 dose.dicomInfo.PixelSpacing = [target_resolution.x; ... 0089 target_resolution.y]; 0090 dose.dicomInfo.ImagePositionPatient = [min(dose.x); min(dose.y); min(dose.z)]; 0091 dose.dicomInfo.SliceThickness = target_resolution.z; 0092 dose.dicomInfo.ImageOrientationPatient = doseInfo.ImageOrientationPatient; 0093 dose.dicomInfo.DoseType = doseInfo.DoseType; 0094 dose.dicomInfo.DoseSummationType = doseInfo.DoseSummationType; 0095 %dose.dicomInfo.InstanceNumber = doseInfo.InstanceNumber; %Not 0096 %always given 0097 dose.dicomInfo.SOPClassUID = doseInfo.SOPClassUID; 0098 dose.dicomInfo.SOPInstanceUID = doseInfo.SOPInstanceUID; 0099 dose.dicomInfo.ReferencedRTPlanSequence = doseInfo.ReferencedRTPlanSequence; 0100 0101 end