0001 function [ct, cst, pln, resultGUI] = matRad_importDicom( files, dicomMetaBool )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 [env, ~] = matRad_getEnvironment();
0038
0039
0040 if ~exist('dicomMetaBool','var')
0041 dicomMetaBool = true;
0042 end
0043
0044
0045 h = waitbar(0,'Please wait...');
0046
0047 steps = 2;
0048
0049
0050 waitbar(1 / steps)
0051 resolution.x = files.resx;
0052 resolution.y = files.resy;
0053 resolution.z = files.resz;
0054 if files.useDoseGrid && isfield(files,'rtdose')
0055
0056 if verLessThan('matlab','9')
0057 doseInfo = dicominfo(files.rtdose{1,1});
0058 else
0059 doseInfo = dicominfo(files.rtdose{1,1},'UseDictionaryVR',true);
0060 end
0061 doseGrid{1} = doseInfo.ImagePositionPatient(1) + doseInfo.ImageOrientationPatient(1) * ...
0062 doseInfo.PixelSpacing(1) * double(0:doseInfo.Columns - 1);
0063 doseGrid{2} = doseInfo.ImagePositionPatient(2) + doseInfo.ImageOrientationPatient(5) * ...
0064 doseInfo.PixelSpacing(2) * double(0:doseInfo.Rows - 1);
0065 doseGrid{3} = doseInfo.ImagePositionPatient(3) + doseInfo.GridFrameOffsetVector(:)';
0066
0067
0068 ct = matRad_importDicomCt(files.ct, resolution, dicomMetaBool,doseGrid);
0069
0070 else
0071 ct = matRad_importDicomCt(files.ct, resolution, dicomMetaBool);
0072 end
0073
0074 if ~isempty(files.rtss)
0075
0076
0077 waitbar(2 / steps)
0078 structures = matRad_importDicomRtss(files.rtss{1},ct.dicomInfo);
0079 close(h)
0080
0081
0082 h = waitbar(0,'Please wait...');
0083
0084 steps = numel(structures);
0085 for i = 1:numel(structures)
0086
0087 waitbar(i / steps)
0088 fprintf('creating cube for %s volume...\n', structures(i).structName);
0089 structures(i).indices = matRad_convRtssContours2Indices(structures(i),ct);
0090 end
0091 fprintf('finished!\n');
0092 close(h)
0093
0094
0095 cst = matRad_createCst(structures);
0096
0097 else
0098
0099 cst = matRad_dummyCst(ct);
0100
0101 end
0102
0103
0104 if isfield(files,'rtplan')
0105 if ~(cellfun(@isempty,files.rtplan(1,:)))
0106 pln = matRad_importDicomRTPlan(ct, files.rtplan, dicomMetaBool);
0107 end
0108 end
0109
0110
0111 if isfield(files,'rtplan')
0112 if ~(cellfun(@isempty,files.rtplan(1,:)))
0113 if (strcmp(pln.radiationMode,'protons') || strcmp(pln.radiationMode,'carbon'))
0114
0115
0116 [stf, pln] = matRad_importDicomSteeringParticles(ct, pln, files.rtplan);
0117 elseif strcmp(pln.radiationMode, 'photons') && isfield(pln.propStf,'collimation')
0118
0119 [stf, pln] = matRad_importDicomSteeringPhotons(pln);
0120 else
0121 warning('No support for DICOM import of steering information for this modality.');
0122 end
0123 end
0124 end
0125
0126
0127 if isfield(files,'rtdose')
0128
0129
0130 if ~(cellfun(@isempty,files.rtdose(1,1:2)))
0131 fprintf('loading Dose files \n', structures(i).structName);
0132
0133 if exist('pln','var')
0134 if isfield(pln,'numOfFractions')
0135 resultGUI = matRad_importDicomRTDose(ct, files.rtdose, pln);
0136 end
0137 else
0138 resultGUI = matRad_importDicomRTDose(ct, files.rtdose);
0139 end
0140 if size(resultGUI) == 0
0141 clear resultGUI;
0142 end
0143 end
0144 end
0145
0146
0147 if exist('stf','var') && exist('resultGUI','var')
0148 resultGUI.w = [];
0149 for i = 1:size(stf,2)
0150 resultGUI.w = [resultGUI.w; [stf(i).ray.weight]'];
0151 end
0152 end
0153
0154
0155 matRadFileName = [files.ct{1,3} '.mat'];
0156 [FileName,PathName] = uiputfile('*','Save as...',matRadFileName);
0157 if ischar(FileName)
0158
0159 switch env
0160 case 'MATLAB'
0161 clearvars -except ct cst pln stf resultGUI FileName PathName;
0162 case 'OCTAVE'
0163 clear -x ct cst pln stf resultGUI FileName PathName;
0164 end
0165
0166 save([PathName, FileName], '-regexp', '^(?!(FileName|PathName)$).','-v7.3');
0167 end