% Example: Carbon Ion Treatment Plan %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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: Carbon Ion Treatment Plan 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 carbon ion dose calculation plan including variable RBE optimization 0020 % (iii) how to inversely optimize the pencil beam intensities based on the 0021 % RBE-weighted dose 0022 % (iv) how to inversely optimize the pencil beam intensities based on the 0023 % biological effect 0024 % (v) how to change the tissues' radiobiological characteristics 0025 % (vi) how to recalculated the dose considering the previously optimized pencil beam intensities 0026 % (vii) how to compare the two results 0027 0028 %% Patient Data Import 0029 % Let's begin with a clear Matlab environment and import the liver 0030 % patient into your workspace. 0031 0032 matRad_rc; %If this throws an error, run it from the parent directory first to set the paths 0033 0034 load('LIVER.mat'); 0035 0036 %% Treatment Plan 0037 % The next step is to define your treatment plan labeled as 'pln'. This 0038 % structure requires input from the treatment planner and defines the most 0039 % important cornerstones of your treatment plan. 0040 %% 0041 % First of all, we need to define what kind of radiation modality we would 0042 % like to use. Possible values are photons, protons or carbon. In this 0043 % example we would like to use carbon ions for treatment planning. Next, we 0044 % need to define a treatment machine to correctly load the corresponding 0045 % base data. matRad features generic base data in the file 0046 % 'carbon_Generic.mat'; consequently the machine has to be set accordingly 0047 pln.radiationMode = 'carbon'; 0048 pln.machine = 'Generic'; 0049 0050 %% 0051 % Define the flavor of biological optimization for treatment planning along 0052 % with the quantity that should be used for optimization. Possible values 0053 % are (none: physical optimization; const_RBExD: constant RBE of 1.1; 0054 % LEMIV_effect: effect-based optimization; LEMIV_RBExD: optimization of 0055 % RBE-weighted dose. As we use carbon ions, we decide to use base data from 0056 % the local effect model IV and want to optimize the RBE-weighted dose. 0057 % Therefore we set bioOptimization to LEMIV_RBExD 0058 pln.propOpt.bioOptimization = 'LEMIV_RBExD'; 0059 0060 %% 0061 % The remaining plan parameters are set like in the previous example files 0062 pln.numOfFractions = 30; 0063 pln.propStf.gantryAngles = 315; 0064 pln.propStf.couchAngles = 0; 0065 pln.propStf.bixelWidth = 3; 0066 pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles); 0067 pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0); 0068 pln.propOpt.runDAO = 0; 0069 pln.propOpt.runSequencing = 0; 0070 0071 % dose calculation settings 0072 pln.propDoseCalc.doseGrid.resolution.x = 3; % [mm] 0073 pln.propDoseCalc.doseGrid.resolution.y = 3; % [mm] 0074 pln.propDoseCalc.doseGrid.resolution.z = 3; % [mm] 0075 0076 %% Generate Beam Geometry STF 0077 stf = matRad_generateStf(ct,cst,pln); 0078 0079 %% 0080 % Let's have a closer look on the stf.ray sub-structure which contains the 0081 % actual beam/ray geometry information. For illustration purposes we want 0082 % to show the last ray. Besides geometrical information about the position 0083 % and orientation of the ray, we can also find pencil beam information. If 0084 % the ray coincides with the target, pencil beams were defined along the 0085 % ray from target entry to target exit. 0086 display(stf.ray(end)); 0087 0088 %% 0089 % Here are the energies selected on the last ray: 0090 display(stf.ray(end).energy); 0091 0092 %% Dose Calculation 0093 dij = matRad_calcParticleDose(ct,stf,pln,cst); 0094 0095 %% Inverse Optimization for IMPT based on RBE-weighted dose 0096 % The goal of the fluence optimization is to find a set of bixel/spot 0097 % weights which yield the best possible dose distribution according to the 0098 % clinical objectives and constraints underlying the radiation treatment. 0099 resultGUI = matRad_fluenceOptimization(dij,cst,pln); 0100 0101 %% Plot the Resulting Dose Slice 0102 % Let's plot the transversal iso-center dose slice 0103 slice = round(pln.propStf.isoCenter(3)./ct.resolution.z); 0104 figure, 0105 imagesc(resultGUI.RBExDose (:,:,slice)),colorbar, colormap(jet); 0106 0107 %% Inverse Optimization for IMPT based on biological effect 0108 % To perform a dose optimization for carbon ions we can also use the 0109 % biological effect instead of the RBE-weighted dose. Therefore we have to 0110 % change the optimization mode and restart the optimization 0111 pln.propOpt.bioOptimization = 'LEMIV_effect'; 0112 resultGUI_effect = matRad_fluenceOptimization(dij,cst,pln); 0113 0114 %% Visualize differences 0115 % Through optimzation based on the biological effect we obtain a slightly 0116 % different dose distribution as visualized by the following dose 0117 % difference map 0118 figure; 0119 imagesc(resultGUI.RBExDose (:,:,slice)-resultGUI_effect.RBExDose(:,:,slice)); 0120 colorbar; 0121 colormap(jet); 0122 0123 %% Change Radiosensitivity 0124 % The previous treatment plan was optimized using an photon alpha-beta 0125 % ratio of 2 for all tissues. Now, Let's change the radiosensitivity by 0126 % adapting alphaX. This will change the photon alpha-beta ratio 0127 % from 2 to 10. 0128 for i = 1:size(cst,1) 0129 cst{i,5}.alphaX = 0.5; 0130 cst{i,5}.TissueClass = 2; 0131 end 0132 0133 %% Recalculate Plan 0134 % Let's use the existing optimized pencil beam weights and recalculate the RBE weighted dose 0135 resultGUI_tissue = matRad_calcDoseDirect(ct,stf,pln,cst,resultGUI.w); 0136 0137 %% Result Comparison 0138 % Let's compare the new recalculation against the optimization result. 0139 plane = 3; 0140 doseWindow = [0 max([resultGUI_effect.RBExDose(:); resultGUI_tissue.RBExDose(:)])]; 0141 0142 figure, 0143 matRad_plotSliceWrapper(gca,ct,cst,1,resultGUI_effect.RBExDose,plane,slice,[],[],colorcube,[],doseWindow,[]); 0144 title('original plan') 0145 figure, 0146 matRad_plotSliceWrapper(gca,ct,cst,1,resultGUI_tissue.RBExDose,plane,slice,[],[],colorcube,[],doseWindow,[]); 0147 title('manipulated plan') 0148 %% 0149 % At this point we would like to see the absolute difference of the original optimization and the 0150 % recalculation. 0151 absDiffCube = resultGUI_effect.RBExDose-resultGUI_tissue.RBExDose; 0152 figure, 0153 matRad_plotSliceWrapper(gca,ct,cst,1,absDiffCube,plane,slice,[],[],colorcube); 0154 title('absolute difference') 0155 %% 0156 % Plot both doses with absolute difference and gamma analysis 0157 [gammaCube,gammaPassRate,hfigure]=matRad_compareDose(resultGUI_effect.RBExDose, resultGUI.RBExDose, ct, cst,[1 1 1],'on'); 0158 0159 0160