% Example: Photon Treatment Plan using VMC++ dose calculation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright 2017 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 %% Example: Photon Treatment Plan using VMC++ dose calculation 0002 % 0003 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0004 % 0005 % Copyright 2017 the matRad development team. 0006 % 0007 % This file is part of the matRad project. It is subject to the license 0008 % terms in the LICENSE file found in the top-level directory of this 0009 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0010 % of the matRad project, including this file, may be copied, modified, 0011 % propagated, or distributed except according to the terms contained in the 0012 % LICENSE file. 0013 % 0014 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0015 0016 %% 0017 % In this example we will show 0018 % (i) how to load patient data into matRad 0019 % (ii) how to setup a photon dose calculation based on the VMC++ Monte Carlo algorithm 0020 % (iii) how to inversely optimize the beamlet intensities directly from command window in MATLAB. 0021 % (iv) how to visualize the result 0022 0023 %% Patient Data Import 0024 % Let's begin with a clear Matlab environment and import the boxphantom 0025 % into your workspace. 0026 0027 matRad_rc; %If this throws an error, run it from the parent directory first to set the paths 0028 0029 load('BOXPHANTOM.mat'); 0030 0031 %% Treatment Plan 0032 % The next step is to define your treatment plan labeled as 'pln'. This 0033 % structure requires input from the treatment planner and defines the most 0034 % important cornerstones of your treatment plan. 0035 0036 pln.radiationMode = 'photons'; 0037 pln.machine = 'Generic'; 0038 pln.numOfFractions = 30; 0039 pln.propOpt.bioOptimization = 'none'; 0040 pln.propStf.gantryAngles = [0]; 0041 pln.propStf.couchAngles = [0]; 0042 pln.propStf.bixelWidth = 10; 0043 pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles); 0044 pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0); 0045 pln.propOpt.runSequencing = 0; 0046 pln.propOpt.runDAO = 0; 0047 0048 % dose calculation settings 0049 pln.propDoseCalc.doseGrid.resolution.x = 3; % [mm] 0050 pln.propDoseCalc.doseGrid.resolution.y = 3; % [mm] 0051 pln.propDoseCalc.doseGrid.resolution.z = 3; % [mm] 0052 0053 %% Generate Beam Geometry STF 0054 stf = matRad_generateStf(ct,cst,pln); 0055 0056 %% Dose Calculation 0057 % Calculate dose influence matrix for unit pencil beam intensities using 0058 % a Monte Carlo algorithm 0059 dij = matRad_calcPhotonDoseMC(ct,stf,pln,cst); 0060 0061 %% Inverse Optimization for IMRT 0062 resultGUI = matRad_fluenceOptimization(dij,cst,pln); 0063 0064 %% Plot the Resulting Dose Slice 0065 % Just let's plot the transversal iso-center dose slice 0066 slice = round(pln.propStf.isoCenter(1,3)./ct.resolution.z); 0067 figure, 0068 imagesc(resultGUI.physicalDose(:,:,slice)),colorbar, colormap(jet) 0069 0070 %% 0071 % Exemplary, we show how to obtain the dose in the target and plot the histogram 0072 ixTarget = cst{2,4}{1}; 0073 doseInTarget = resultGUI.physicalDose(ixTarget); 0074 figure 0075 [env, ~] = matRad_getEnvironment(); 0076 hist(doseInTarget); 0077 0078 % use hist for compatibility with GNU Octave 0079 title('dose in target'),xlabel('[Gy]'),ylabel('#'); 0080 0081 %% compute integral energy 0082 matRad_calcIntEnergy(resultGUI.physicalDose,ct,pln);