-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of LET modifying objectives #706
Open
lisaseckler
wants to merge
49
commits into
e0404:dev_varRBErobOpt
Choose a base branch
from
lisaseckler:dev_varRBErobOpt
base: dev_varRBErobOpt
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 42 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
a2f3241
Dirty dose calculation and objectives
lisaseckler a3b1f91
LET Objectives
lisaseckler 4d2c215
Merge branch 'dev_varRBErobOpt' of https://github.com/e0404/matRad in…
lisaseckler 56b4ac4
Test change
lisaseckler 249054b
LETd Objective
lisaseckler 6a202f8
Objective Variance Implementation
lisaseckler 90c3be3
LET experiments for PTCOG
lisaseckler 593443a
Cleaning branch
lisaseckler b2ea438
Function Test
lisaseckler 7e8fee4
Test DD
lisaseckler b3a3e12
test change
lisaseckler cf03bab
Delete matRad_Beam2DirtyDose.asv
lisaseckler 0a15bfc
Delete matRad_DoseComparison.asv
lisaseckler 4a7fec9
Delete optimization/+DoseObjectives/matRad_LETDirtyDose.asv
lisaseckler fab2177
Delete optimization/@matRad_OptimizationProblem/matRad_objectiveFunct…
lisaseckler 1359231
Delete optimization/@matRad_OptimizationProblem/matRad_objectiveGradi…
lisaseckler c09e74f
Delete optimization/projections/matRad_DirtyDoseProjection.asv
lisaseckler 57d5495
Delete optimization/projections/matRad_LETdProjection.asv
lisaseckler f5b4266
Update matRad_Beam2DirtyDose.m
lisaseckler c11d27a
Delete matRad_Beam2DirtyDoseMCN_WED.m
lisaseckler 18f2aff
Delete matRad_Beam2mLETDoseMCN.m
lisaseckler d7537b4
Update matRad_Beam2DirtyDose.m
lisaseckler e5c083a
Delete matRad_UnderdosingTesting.asv
lisaseckler d01e7c0
Update and rename matRad_UnderdosingTesting.m to matRad_DirtyDoseUnde…
lisaseckler 6047145
Delete matRad_calcLETmask.asv
lisaseckler 5f71dc0
Delete matRad_fluenceOptimization.asv
lisaseckler c15485f
Cleaning LET Optimization
lisaseckler fe7a317
Merge branch 'dev_varRBErobOpt' of https://github.com/lisaseckler/mat…
lisaseckler c5cb8b4
Clean up
lisaseckler 143ac52
Testing examples and deleting scripts
lisaseckler 621e7db
renaming file
lisaseckler a97197d
changing variable names
lisaseckler 0516c2e
Merge branch 'e0404:dev_varRBErobOpt' into dev_varRBErobOpt
lisaseckler 627c2b6
Merge branch 'dev_varRBErobOpt' of https://github.com/lisaseckler/mat…
lisaseckler 3a88bec
deleting comments
lisaseckler c489f32
deleting dicom
lisaseckler a6d4eba
delete
lisaseckler 44eedec
delete
lisaseckler f120062
delete
lisaseckler 54516f1
delete
lisaseckler c9c77dd
delete
lisaseckler d6e1040
name
lisaseckler 969aebc
Examples
lisaseckler c3b26c1
Description of LETmask
lisaseckler 3a3efe9
Merge branch 'dev' into pr/706
wahln 2d05c9b
some streamlining of the calculation of dirty dose and the LET masks
wahln 57eea22
Merge branch 'dev_varRBErobOpt' into pr/706
wahln 1b9251b
remove the tempfile
wahln 32a31c3
Merge branch 'dev_varRBErobOpt' into pr/706
wahln File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
%% Welcome to a dirty dose testing script | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% What is the script about? | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% 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 | ||
|
||
%% load an easy phantom like the TG119.mat | ||
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; | ||
|
||
|
||
% beam geometry settings | ||
pln.propStf.bixelWidth = 5; % [mm] / also corresponds to lateral spot spacing for particles | ||
pln.propStf.gantryAngles = [45 0 -45]; | ||
pln.propStf.couchAngles = zeros(numel(pln.propStf.gantryAngles),1); | ||
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles); | ||
pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0); | ||
% optimization settings | ||
pln.propDoseCalc.calcLET = 1; % very important, don't forget that one! | ||
|
||
pln.propOpt.runDAO = false; % 1/true: run DAO, 0/false: don't / will be ignored for particles | ||
pln.propOpt.runSequencing = false; % 1/true: run sequencing, 0/false: don't / will be ignored for particles and also triggered by runDAO below | ||
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(1).propDoseCalc.doseGrid.resolution = ct.resolution; | ||
quantityOpt = 'RBExD'; % options: physicalDose, effect, RBExD | ||
%=======================================> Model check error in bioModel | ||
modelName = 'constRBE'; % none: for photons, protons, carbon % constRBE: constant RBE for photons and protons | ||
% MCN: McNamara-variable RBE model for protons % WED: Wedenberg-variable RBE model for protons | ||
% LEM: Local Effect Model for carbon ions | ||
|
||
|
||
scenGenType = 'nomScen'; % scenario creation type 'nomScen' 'wcScen' 'impScen' 'rndScen' | ||
|
||
% retrieve bio model parameters | ||
pln.bioParam = matRad_bioModel(pln.radiationMode,quantityOpt, modelName); | ||
|
||
% retrieve scenarios for dose calculation and optimziation | ||
pln.multScen = matRad_multScen(ct,scenGenType); | ||
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); | ||
|
||
% IMPORTANT: If you want to save your results, rename them! Maybe they will | ||
% get overwritten later | ||
|
||
%% Plotting | ||
% Let's see how it looks | ||
cube = resultGUI.physicalDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
figure | ||
subplot(2,1,1) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('physicalDose') | ||
zoom(4) | ||
|
||
cube = resultGUI.dirtyDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
subplot(2,1,2) | ||
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 | ||
|
||
% 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! | ||
% Let's see how it looks | ||
cube = resultGUI.physicalDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
figure | ||
subplot(2,1,1) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('physicalDose') | ||
zoom(4) | ||
|
||
cube = resultGUI.dirtyDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
subplot(2,1,2) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('dirtyDose with DD objective in Core') | ||
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); | ||
|
||
% 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 second dirty dose calculation is ready! | ||
% Let's see how it looks | ||
cube = resultGUI.physicalDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
figure | ||
subplot(2,1,1) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('physicalDose') | ||
zoom(4) | ||
|
||
cube = resultGUI.dirtyDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
subplot(2,1,2) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('dirtyDose with DD objective in Target') | ||
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 | ||
|
||
% 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); | ||
|
||
%% Optimization | ||
% yeyy only the optimization has to be done | ||
resultGUI = matRad_fluenceOptimization(dij,cst,pln); | ||
|
||
%% Well done your third dirty dose calculation is ready! | ||
% Let's see how it looks | ||
cube = resultGUI.physicalDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
figure | ||
subplot(2,1,1) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('physicalDose') | ||
zoom(4) | ||
|
||
cube = resultGUI.dirtyDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
subplot(2,1,2) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('dirtyDose with DD objective in Core and Target') | ||
zoom(4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
%% Welcome to a LETd testing script | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% What is the script about? | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% the script will tell you how you can use the LETd SquaredUnderdosing objective 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 | ||
|
||
%% load an easy phantom like the TG119.mat | ||
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; | ||
|
||
|
||
% beam geometry settings | ||
pln.propStf.bixelWidth = 5; % [mm] / also corresponds to lateral spot spacing for particles | ||
pln.propStf.gantryAngles = [45 0 -45]; | ||
pln.propStf.couchAngles = zeros(numel(pln.propStf.gantryAngles),1); | ||
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles); | ||
pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0); | ||
% optimization settings | ||
pln.propDoseCalc.calcLET = 1; % very important, don't forget that one! | ||
|
||
pln.propOpt.runDAO = false; % 1/true: run DAO, 0/false: don't / will be ignored for particles | ||
pln.propOpt.runSequencing = false; % 1/true: run sequencing, 0/false: don't / will be ignored for particles and also triggered by runDAO below | ||
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(1).propDoseCalc.doseGrid.resolution = ct.resolution; | ||
quantityOpt = 'RBExD'; % options: physicalDose, effect, RBExD | ||
%=======================================> Model check error in bioModel | ||
modelName = 'constRBE'; % none: for photons, protons, carbon % constRBE: constant RBE for photons and protons | ||
% MCN: McNamara-variable RBE model for protons % WED: Wedenberg-variable RBE model for protons | ||
% LEM: Local Effect Model for carbon ions | ||
|
||
|
||
scenGenType = 'nomScen'; % scenario creation type 'nomScen' 'wcScen' 'impScen' 'rndScen' | ||
|
||
% retrieve bio model parameters | ||
pln.bioParam = matRad_bioModel(pln.radiationMode,quantityOpt, modelName); | ||
|
||
% retrieve scenarios for dose calculation and optimziation | ||
pln.multScen = matRad_multScen(ct,scenGenType); | ||
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); | ||
|
||
% IMPORTANT: If you want to save your results, rename them! Maybe they will | ||
% get overwritten later | ||
|
||
%% Plotting | ||
% Let's see how it looks | ||
cube = resultGUI.physicalDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
figure | ||
subplot(2,1,1) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('physicalDose') | ||
zoom(4) | ||
|
||
cube = resultGUI.LETd; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
subplot(2,1,2) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('LETd without Ld objective') | ||
zoom(4) | ||
%% Adding LETd | ||
% the cst is important! | ||
% for adding a LETd objective choose a structure like the OuterTarget | ||
|
||
% REMEMBER: Always set LETd objectives as a secondary objective and | ||
% have a dose objective as your first objective | ||
% You can change the penalty and the prescribed LETd if you like | ||
cst{2,6}{2} = struct(LETdObjectives.matRad_SquaredUnderdosingLETd(100,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 LETd calculation is ready! | ||
% Let's see how it looks | ||
cube = resultGUI.physicalDose; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
figure | ||
subplot(2,1,1) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('physicalDose') | ||
zoom(4) | ||
|
||
cube = resultGUI.LETd; | ||
plane = 3; | ||
slice = 80; | ||
doseWindow = [min(cube(:)) max(cube(:))]; | ||
subplot(2,1,2) | ||
matRad_plotSliceWrapper(gca,ct,cst,1,cube,plane,slice,[],[],colorcube,[],doseWindow,[],[]); | ||
title('LETd with Ld in Target') | ||
zoom(4) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we merge examples 16,17,18 into one example comparing the different objectives?