Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 29 additions & 77 deletions examples/matRad_example15_DirtyDose.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
%% Welcome to a dirty dose testing script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% What is the script about?
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Welcome to a dirty dose example script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the script will tell you how you can use the dirty dose objectives and
% how the dose distribution will look like if you do that
% follow the steps and you will succeed :)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% open matRad files and delete everything in the workspace
matRad_rc
Expand All @@ -14,7 +23,7 @@
load("TG119.mat")

%% Plan and Geometry
% choose your modality... but seriously choose protons!!

pln.radiationMode = 'protons'; % either photons / protons / helium / carbon
pln.machine = 'Generic';
pln.numOfFractions = 30;
Expand All @@ -34,9 +43,9 @@
pln.propOpt.spatioTemp = 0;

% dose calculation settings
pln.propDoseCalc.doseGrid.resolution.x = 3; % [mm]
pln.propDoseCalc.doseGrid.resolution.y = 3; % [mm]
pln.propDoseCalc.doseGrid.resolution.z = 3; % [mm]
pln.propDoseCalc.doseGrid.resolution.x = 5; % [mm]
pln.propDoseCalc.doseGrid.resolution.y = 5; % [mm]
pln.propDoseCalc.doseGrid.resolution.z = 5; % [mm]
% pln(1).propDoseCalc.doseGrid.resolution = ct.resolution;
quantityOpt = 'RBExD'; % options: physicalDose, effect, RBExD
%=======================================> Model check error in bioModel
Expand All @@ -58,17 +67,13 @@
% Dij Calculation --> only for dose
dij = matRad_calcParticleDose(ct,stf,pln,cst);

% Dirty Dose Calculation --> adding dirty dose. The number describes your
% LET threshold -> that you can change but everything else has to stay like
% this
% Dirty Dose Calculation --> compute dirty dose influence matrix
% arg: LET threshold (keV/um)
dij = matRad_calcDirtyDose(2,dij);

%% Optimization
% yeyy only the optimization has to be done
resultGUI = matRad_fluenceOptimization(dij,cst,pln);

% IMPORTANT: If you want to save your results, rename them! Maybe they will
% get overwritten later

%% Plotting
% Let's see how it looks
Expand All @@ -90,29 +95,12 @@
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]);
title('dirtyDose without DD objective')
zoom(4)
%% Adding dirty dose
% the cst is important!
% for adding a dirty dose objective choose a structure like the Core
%% Adding dirty dose objective
% adding a dirty dose objective to the Core

% REMEMBER: Always set dirty dose objectives as a secondary objective and
% have a dose objective as your first objective
% You can change the penalty and the prescribed dirtydose if you like
cst{1,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredOverdosingDirtyDose(300,0));

%% Generate the Geometry again
stf = matRad_generateStf(ct,cst,pln);

%% Dose calculation
% Dij Calculation --> only for dose
dij = matRad_calcParticleDose(ct,stf,pln,cst);

% Dirty Dose Calculation --> adding dirty dose. The number describes your
% LET threshold -> that you can change but everything else has to stay like
% this
dij = matRad_calcDirtyDose(2,dij);

%% Optimization
% yeyy only the optimization has to be done
resultGUI = matRad_fluenceOptimization(dij,cst,pln);

%% Well done your first dirty dose calculation is ready!
Expand All @@ -137,32 +125,13 @@
zoom(4)

%% Now with the Target
% make sure to delete cst{1,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredOverdosingDirtyDose(300,0));
clear('cst')
load("TG119.mat")
%% Adding dirty dose
% the cst is important!
% for adding a dirty dose objective choose a structure like the OuterTarget

% REMEMBER: Always set dirty dose objectives as a secondary objective and
% have a dose objective as your first objective
% You can change the penalty and the prescribed dirtydose if you like
cst{2,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredUnderdosingDirtyDose(300,4));

%% Generate the Geometry again
stf = matRad_generateStf(ct,cst,pln);

%% Dose calculation
% Dij Calculation --> only for dose
dij = matRad_calcParticleDose(ct,stf,pln,cst);
%% Adding dirty dose
% for adding a dirty dose objective to OuterTarget

% Dirty Dose Calculation --> adding dirty dose. The number describes your
% LET threshold -> that you can change but everything else has to stay like
% this
dij = matRad_calcDirtyDose(2,dij);
cst{2,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredUnderdosingDirtyDose(300,20));

%% Optimization
% yeyy only the optimization has to be done
resultGUI = matRad_fluenceOptimization(dij,cst,pln);

%% Well done your second dirty dose calculation is ready!
Expand All @@ -187,33 +156,16 @@
zoom(4)

%% Now with the Core and Target
% make sure to delete cst{2,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredUnderdosingDirtyDose(300,4));
clear('cst')
load("TG119.mat")

%% Adding dirty dose
% the cst is important!
% for adding a dirty dose objective choose two structures like the Core and OuterTarget
% for adding a dirty dose objective choose two structures: Core and OuterTarget

% REMEMBER: Always set dirty dose objectives as a secondary objective and
% have a dose objective as your first objective
% You can change the penalty and the prescribed dirtydose if you like
cst{1,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredOverdosingDirtyDose(300,0));
cst{2,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredUnderdosingDirtyDose(300,4));

%% Generate the Geometry again
stf = matRad_generateStf(ct,cst,pln);

%% Dose calculation
% Dij Calculation --> only for dose
dij = matRad_calcParticleDose(ct,stf,pln,cst);

% Dirty Dose Calculation --> adding dirty dose. The number describes your
% LET threshold -> that you can change but everything else has to stay like
% this
dij = matRad_calcDirtyDose(2,dij);
cst{2,6}{2} = struct(DirtyDoseObjectives.matRad_SquaredUnderdosingDirtyDose(300,20));

%% Optimization
% yeyy only the optimization has to be done

resultGUI = matRad_fluenceOptimization(dij,cst,pln);

%% Well done your third dirty dose calculation is ready!
Expand Down