Skip to content
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

Adapt dose engine concept to dev_varRBErobOpt #683

Closed
wants to merge 109 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
dd9e332
First commit, init dose calc engines (+ branch goal explanation)
NathanKunz Jun 10, 2021
fe8a398
Merge pull request #1 from e0404/master
NathanKunz Jun 29, 2021
7c46d5f
Edited engine names annd some internal logic
NathanKunz Jul 7, 2021
3c91301
Create matRad_calcDose funktion
NathanKunz Jul 7, 2021
2cf266e
Small changes to matRad_calcDose
NathanKunz Aug 2, 2021
5364b23
Added documentation to the dose engines
NathanKunz Aug 2, 2021
ecdab4b
Changed calcDose and moved getAvailable dose from Engine to separate …
NathanKunz Aug 9, 2021
d943897
Minor changes to engines manly because bugs in example runs
NathanKunz Aug 9, 2021
80f66c4
Comments cleanup and fix of some typos
NathanKunz Aug 9, 2021
2072ca1
Moved dijSampling method to PencilBeam Superclass
NathanKunz Aug 9, 2021
9303289
Removed depricated functions
NathanKunz Aug 9, 2021
6319a3d
Added default engines to MatRad_Config
NathanKunz Aug 11, 2021
bbfa634
Move or removed functions which are either used in the dose calculati…
NathanKunz Aug 11, 2021
fb67a2b
Merge pull request #2 from e0404/master
NathanKunz Aug 11, 2021
00fc419
Moved the last files to the doseCalc folder
NathanKunz Aug 11, 2021
ede0986
Merge branch 'dev' into dev_refactorDoseCalc
wahln Aug 11, 2021
985c950
Merge branch 'dev' into pr/519
wahln Nov 17, 2021
b5ae2b4
fix kernel convolution with interpn for octave
wahln Nov 17, 2021
1c7b2ab
Merge branch 'dev' of https://github.com/e0404/matRad into pr/519
wahln Nov 19, 2021
95d669e
some restructuring of the photon engine
wahln Dec 1, 2021
70a2a27
doc change
wahln Jan 20, 2022
5d3af45
Changes to engine properties
NathanKunz Feb 1, 2022
d7d7d37
Turn off visualization for Lateral Cut Off (octave fix)
NathanKunz Feb 1, 2022
3ccf68e
Merge branch 'dev' into pr/519
wahln Mar 10, 2022
f85d9e3
Merge branch 'dev' of https://github.com/e0404/matRad into pr/519
wahln Mar 10, 2022
6e0a19b
Merge branch 'dev_refactorDoseCalc' of https://github.com/NathanKunz/…
wahln Mar 10, 2022
5153bee
Merge branch 'dev' of https://github.com/e0404/matRad into pr/519
wahln Aug 2, 2022
478009b
Merge branch 'dev' of https://github.com/e0404/matRad into pr/519
wahln Aug 2, 2022
412756a
Merge branch 'dev_refactorDoseCalc' of https://github.com/NathanKunz/…
wahln Aug 2, 2022
d0fc5df
Update on dose engine variable naming and function structure
wahln Aug 3, 2022
35180c9
fix function name
wahln Aug 3, 2022
10599c3
fix for class folders
wahln Aug 4, 2022
9822ce9
some cleanup of the dose calculation function
wahln Aug 10, 2022
ac563db
add helper function to find subclasses in folders / packages
wahln Aug 10, 2022
ea5c2f4
streamlined available machine check and loading
wahln Aug 10, 2022
9599ee9
some streamlining and name changes
wahln Aug 10, 2022
41a045e
fix missing new load machine file
wahln Aug 10, 2022
a8eb56f
fix in class availability check
wahln Aug 10, 2022
f125e8f
Extended availability check by call to isAvailable function
wahln Aug 11, 2022
70d3862
Octave Fix for calling availability function
wahln Aug 12, 2022
3209e66
Update interfaces and property assignment in dose engines
wahln Sep 15, 2022
e380901
Merge branch 'master' into pr/519
wahln Oct 5, 2022
bd45bae
update to dij sampling (only photons), slightly adapt sampling radius
wahln Oct 5, 2022
3bd4090
Merge branch 'dev' into pr/519
wahln Oct 5, 2022
134050e
Merge branch 'dev_DVHcolor' into pr/519
wahln Oct 21, 2022
86547fc
changes to SSD computation so the propDoseCalc value is set in the en…
wahln Oct 21, 2022
b855c1c
stf now contains machine as well
wahln Oct 21, 2022
c2566f4
some parameter checking and using in dose engine initialization
wahln Jan 24, 2023
be82cac
remove pln requirement from dose calculation initialization
wahln Jan 27, 2023
1b66bb4
fix radialogical depth interpolation
wahln Jan 28, 2023
530ea7c
fix anisotropic dose grid check for MCsquare
wahln Jan 28, 2023
cb70d1f
pln cleanup in dose engine constructors
wahln Jan 28, 2023
a949f92
further fixes for pln argument management, offset fix, superclass cal…
wahln Jan 28, 2023
75b4657
defaults setter and addition of the struct assignment to constructor
wahln Jan 29, 2023
bdb95e9
Update tests.yml
wahln Jan 29, 2023
7d788f7
ompMC interface and MCsquare interface - fix eval function for obtain…
wahln Jan 30, 2023
b353948
Recompiled Octave 6.4.0 mex files for windows and linux, updated scri…
wahln Feb 1, 2023
5eff06f
updated optimizer compilation scripts
wahln Feb 1, 2023
73d6097
update compiled optimizers with static linking
wahln Feb 1, 2023
ffced04
update compiled linux optimizer
wahln Feb 3, 2023
46445b2
option to disable function plot in optimization
wahln Feb 3, 2023
c509e82
include rehash of file directory after linking the optimizer and adde…
wahln Feb 3, 2023
5be97cf
Merge branch 'dev_refactorDoseCalc' of https://github.com/NathanKunz/…
wahln Feb 3, 2023
bf5f4b9
update workflow actions
wahln Feb 3, 2023
735976d
move scripts used during testing to github folder
wahln Feb 4, 2023
ec4e8b2
update scripts for github folder
wahln Feb 4, 2023
075402c
adjust xvfb call in testing
wahln Feb 4, 2023
78c7b3d
Revert "adjust xvfb call in testing"
wahln Feb 4, 2023
cee9df6
use preinstallex xvfb in linux test
wahln Feb 6, 2023
ec57365
fix path
wahln Feb 6, 2023
ad4b416
incorperate multiple weighted Latteral Gaussian Profiles
JenHardt Feb 24, 2023
280f38d
Update matRad_DoseEngineParticlePB.m
JenHardt Feb 24, 2023
d5a79ba
Update matRad_DoseEngineParticlePB.m
JenHardt Apr 3, 2023
22b4b6d
Implementation of the analytical dose engine with the Bragg peak from…
SimonaFa Jun 30, 2023
9fc45c3
Preliminary Separation of Subsampling and Standard pencil-beam dose c…
wahln Oct 20, 2023
e5ba5a8
Additional modularization (move preparations into calcDoseInit
wahln Oct 20, 2023
00fe5a5
Merge branch 'dev' of https://github.com/e0404/matRad into pr/519
wahln Oct 20, 2023
2020602
change of the naming scheme
wahln Oct 23, 2023
cdcd1c0
refine documentation
wahln Oct 23, 2023
efa2f41
Small Update in Dose Engine management
wahln Oct 26, 2023
597e0ab
Fix Availability Checks
wahln Oct 27, 2023
659a2d8
fix function arguments
wahln Oct 27, 2023
114213c
add missing function
wahln Oct 27, 2023
53fc9bb
Changes to the engine selection logic and fixing of compatibility wit…
wahln Oct 27, 2023
f271adf
Update matRad_DoseEngineAnalytical.m
SimonaFa Oct 27, 2023
34dffdf
enable selection of Dose Engine in GUI
wahln Oct 27, 2023
6a6195c
Make sure default engines are prioritized
wahln Oct 27, 2023
9e96ff1
Merge branch 'refactor/doseEngines' into pr/640
wahln Oct 27, 2023
f012589
adapt to chagnes in dose engine logic
wahln Oct 27, 2023
ee57e9a
Merge branch 'dev' of https://github.com/e0404/matRad into pr/519
wahln Oct 30, 2023
bb261b3
improve reusability of code in dose engine structure
wahln Oct 30, 2023
9943bf7
streamline DIJ filling for pencil-beam algorithms
wahln Oct 30, 2023
5f0a234
available classes now given as row vector
wahln Oct 30, 2023
3607af6
unified progress initialization and finalization
wahln Oct 30, 2023
4f8eb7b
streamline progress update
wahln Oct 30, 2023
c854a41
small fix / cosmetic change in indexing
wahln Oct 31, 2023
c2280a8
rename ray initialization
wahln Oct 31, 2023
a78b31d
improve separation of engines and fix fine-sampling engine
wahln Nov 10, 2023
c697862
Merge branch 'pr/519' into pr/640
wahln Nov 10, 2023
1a5a237
Merge pull request #640 from SimonaFa/refactor/AnalyticalDoseEngines
wahln Nov 14, 2023
c1aa5fe
clean-up of the bortfeld engine
wahln Nov 14, 2023
441d2f5
fix missing check in the Widget
wahln Nov 14, 2023
0277a50
optimize geometric distance calculation part I
wahln Nov 14, 2023
912187f
name change calcDoseInitBeam to initBeam for consistency
wahln Nov 14, 2023
b3822c3
update all names to call calcDose, and some trivial reoranization in …
wahln Nov 14, 2023
10f209d
Fix new Analytical Bortfeld Engine
wahln Nov 14, 2023
6e6481b
Catch the if statement if cutOff is only one value
wahln Nov 14, 2023
556717d
Merge branch 'refactor/doseEngines' into pr/600
wahln Nov 15, 2023
851053e
Merge pull request #600 from JenHardt/refactor/doseEngines
wahln Nov 15, 2023
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

sudo chmod +x .travis/runtests.sh
sudo chmod +x .github/runtests.sh
sudo chmod +x MCsquare/bin/MCsquare_linux

mv optimization/optimizer/ipopt.m optimization/optimizer/ipopt.m.bak
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion .travis/runtests.sh → .github/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
## Make sure some failures are detected by the CI runners
function exitIfError {
# pass "$?" as argument: i.e. the exit status of the last call
if [ "$1" -ne 0 ]; then
# currently octave 6 can finish with a segfault when the program is closed due to some bug, for now we try to ignore it
if [ "$1" -ne 0 ] && [ "$1" -ne 139 ]; then
exit $1;
fi
}
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test-matlab: #Matlab test Job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # Checks-out repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v3 # Checks-out repository under $GITHUB_WORKSPACE
# Install MATLAB
- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
Expand All @@ -16,23 +16,24 @@ jobs:
with:
command: cd unitTest; matRad_runTests
test-octave: #Octave test Job
runs-on: ubuntu-20.04 # We use Ubuntu-20.04 because it has Octave 5.2
runs-on: ubuntu-22.04 # We use Ubuntu-22.04 because it has Octave 6.4
steps:
- uses: actions/checkout@v2 # Checks-out repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v3 # Checks-out repository under $GITHUB_WORKSPACE
- name: Install OCTAVE
run: |
sudo apt-get update
sudo apt-get install -y gdb gfortran fonts-freefont-otf gnuplot-x11 libgdcm-dev octave liboctave-dev
- name: Prepare Test Environment
run: |
sudo chmod +x .travis/before_install_linux.sh
sudo .travis/before_install_linux.sh
- name: Run Tests
uses: GabrielBB/xvfb-action@v1 #For Headless tests
with:
run: .travis/runtests.sh octave-cli
- name: Upload Logs if failure
uses: actions/upload-artifact@v2
sudo chmod +x .github/before_install_linux.sh
sudo .github/before_install_linux.sh
- name: Run Tests
run: xvfb-run -a .github/runtests.sh octave-cli
# uses: GabrielBB/xvfb-action@v1 #For Headless tests
# with:
# run: .github/runtests.sh octave-cli
- name: Upload logs if test fails
uses: actions/upload-artifact@v3
if: failure()
with:
name: Test Log
Expand Down
2 changes: 1 addition & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ List of all matRad developers that contributed code (alphabetical)
* Jona Welsch
* Hans-Peter Wieser
* Johanna Winter
* Tong Xu
* Tong Xu
2 changes: 1 addition & 1 deletion MCsquare/matRad_compileMCsquareSparseReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function matRad_compileMCsquareSparseReader(dest,sourceFolder)
end

if exist ('OCTAVE_VERSION', 'builtin')
ccName = eval('mkoctfile -p CXX');
ccName = evalc('mkoctfile -p CXX');
else
myCCompiler = mex.getCompilerConfigurations('C','Selected');
ccName = myCCompiler.ShortName;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
38 changes: 28 additions & 10 deletions MatRad_Config.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
properties

%Logging
logLevel = 3; %1 = only Errors, 2 = with Warnings, 3 = Info output, 4 = deprecation warnings, 5 = debug information
logLevel = 4; %1 = only Errors, 2 = with Warnings, 3 = Info output, 4 = deprecation warnings, 5 = debug information
keepLog = false; %Stores the full log in memory
writeLog = false; %Writes the log to a file on-the-fly

%Default Properties
propDoseCalc;
propOpt;
Expand All @@ -34,6 +34,7 @@

%Disable GUI
disableGUI = false;

devMode = false;
eduMode = false;

Expand All @@ -50,10 +51,12 @@
isOctave; %Helper bool to check for Octave
isMatlab; %Helper bool to check for Matlab
matRad_version; %MatRad version string

matRadRoot; %Path to matRadRoot
end

properties (SetAccess = private)
matRadRoot;

end

methods (Access = private)
Expand All @@ -63,7 +66,7 @@
% Therefore its constructor is private
% For instantiation, use the static MatRad_Config.instance();

obj.matRadRoot = fileparts(mfilename('fullpath'))
obj.matRadRoot = fileparts(mfilename('fullpath'));
addpath(genpath(obj.matRadRoot));

%Set Version
Expand Down Expand Up @@ -167,22 +170,30 @@ function setDefaultProperties(obj)
obj.propStf.defaultAddMargin = true; %expand target for beamlet finding
obj.propStf.defaultBixelWidth = 5;

%Dose Calculation Options
obj.propDoseCalc.defaultResolution = struct('x',3,'y',3,'z',3); %[mm]
obj.propDoseCalc.defaultLateralCutOff = 0.995; %[rel.]
obj.propDoseCalc.defaultGeometricCutOff = 50; %[mm]
obj.propDoseCalc.defaultDosimetricLateralCutOff = 0.995; %[rel.]
obj.propDoseCalc.defaultGeometricLateralCutOff = 50; %[mm]
obj.propDoseCalc.defaultKernelCutOff = Inf; %[mm]
obj.propDoseCalc.defaultSsdDensityThreshold = 0.05; %[rel.]
obj.propDoseCalc.defaultUseGivenEqDensityCube = false; %Use the given density cube ct.cube and omit conversion from cubeHU.
obj.propDoseCalc.defaultIgnoreOutsideDensities = true; %Ignore densities outside of cst contours
obj.propDoseCalc.defaultUseCustomPrimaryPhotonFluence = false; %Use a custom primary photon fluence

obj.propDoseCalc.defaultDoseEngines = {'SVD Pencil Beam','Particle Pencil-Beam'}; %Names for default engines used when no other is given

% default properties for fine sampling calculation
obj.propDoseCalc.defaultFineSamplingProperties.sigmaSub = 1;
obj.propDoseCalc.defaultFineSamplingProperties.N = 21;
obj.propDoseCalc.defaultFineSamplingProperties.method = 'russo';


%Monte Carlo options
obj.propDoseCalc.defaultNumHistoriesPerBeamlet = 2e4;
obj.propDoseCalc.defaultNumHistoriesDirect = 1e6;
obj.propDoseCalc.defaultOutputMCvariance = true;

obj.propOpt.defaultMaxIter = 500;

%deprecated monte carlo options
obj.propMC.ompMC_defaultHistories = 1e6;
obj.propMC.ompMC_defaultOutputVariance = false;
obj.propMC.MCsquare_defaultHistories = 1e6;
Expand All @@ -206,21 +217,28 @@ function setDefaultPropertiesForTesting(obj)
obj.propStf.defaultBixelWidth = 20;

obj.propDoseCalc.defaultResolution = struct('x',5,'y',6,'z',7); %[mm]
obj.propDoseCalc.defaultGeometricCutOff = 20;
obj.propDoseCalc.defaultLateralCutOff = 0.8;
obj.propDoseCalc.defaultGeometricLateralCutOff = 20;
obj.propDoseCalc.defaultDosimetricLateralCutOff = 0.8;
obj.propDoseCalc.defaultKernelCutOff = 20; %[mm]
obj.propDoseCalc.defaultSsdDensityThreshold = 0.05;
obj.propDoseCalc.defaultUseGivenEqDensityCube = false; %Use the given density cube ct.cube and omit conversion from cubeHU.
obj.propDoseCalc.defaultIgnoreOutsideDensities = true;
obj.propDoseCalc.defaultUseCustomPrimaryPhotonFluence = false; %Use a custom primary photon fluence
obj.propDoseCalc.defaultDoseEngines = {'SVD Pencil Beam','Particle Pencil-Beam'}; %Names for default engines used when no other is given

% default properties for fine sampling calculation
obj.propDoseCalc.defaultFineSamplingProperties.sigmaSub = 2;
obj.propDoseCalc.defaultFineSamplingProperties.N = 5;
obj.propDoseCalc.defaultFineSamplingProperties.method = 'russo';

%Monte Carlo options
obj.propDoseCalc.defaultNumHistoriesPerBeamlet = 100;
obj.propDoseCalc.defaultNumHistoriesDirect = 100;
obj.propDoseCalc.defaultOutputMCvariance = true;

obj.propOpt.defaultMaxIter = 10;

%Deprecated Monte Carlo options
obj.propMC.ompMC_defaultHistories = 100;
obj.propMC.ompMC_defaultOutputVariance = true;
obj.propMC.MCsquare_defaultHistories = 100;
Expand Down
55 changes: 55 additions & 0 deletions basedata/matRad_loadMachine.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function machine = matRad_loadMachine(pln,filepath)
% matRad_loadMachine load a machine base data file from pln struct
%
% call
% machine = matRad_loadMachine(pln,filepath)
% machine = matRad_loadMachine(pln)
%
% input
% pln: matRad plan meta information struct
% filepath: (optional) filepath where to look for machine. default
% is basedata in the matRad root folder
%
% output
% machine: matRad machine struct
%
% References
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2022 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/LICENSE.md. 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.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

matRad_cfg = MatRad_Config.instance();
if isfield(pln, 'radiationMode')
if isfield(pln, 'machine')
fileName = [pln.radiationMode '_' pln.machine];
else
fileName = [pln.radiationMode '_Generic'];
matRad_cfg.dispWarning('No machine name given, loading generic machine');
end
else
matRad_cfg.dispError('No radiation mode given in pln');
end

if ~exist('filepath','var')
filepath = [matRad_cfg.matRadRoot filesep 'basedata' filesep fileName];
end

try
m = load(filepath, 'machine');
machine = m.machine; % strip first layer of loaded struct for convenience
catch
matRad_cfg.dispError('Could not find the following machine file: %s\n',fileName);
end
end

17 changes: 8 additions & 9 deletions dicom/matRad_calcWaterEqD.m
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
function ct = matRad_calcWaterEqD(ct, pln)
function ct = matRad_calcWaterEqD(ct, radiationMode)
% matRad function to calculate the equivalent densities from a dicom ct
% that originally uses intensity values
%
% call
% ct = matRad_calcWaterEqD(ct, pln)
% ct = matRad_calcWaterEqD(ct, radiationMode)
%
% input
% ct: unprocessed dicom ct data which are stored as intensity values (IV)
%
% HU = IV * slope + intercept
%
% pln: matRad plan struct
% ct: ct containing a cubeHU to compute rED/rSP values from
% radiationMode: radiationMode as character array (e.g. 'photons') since matRad 3.
% Can also be a pln-struct for downwards compatibility
%
% output
% ct: ct struct with cube with relative _electron_ densities
% ct: ct struct with cube with relative _electron_ densities stored in
% ct.cube
%
% References
% -
Expand All @@ -32,7 +31,7 @@
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% load hlut
hlut = matRad_loadHLUT(ct, pln);
hlut = matRad_loadHLUT(ct, radiationMode);

for i = 1:ct.numOfCtScen

Expand Down
18 changes: 14 additions & 4 deletions dicom/matRad_loadHLUT.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function hlut = matRad_loadHLUT(ct, pln)
function hlut = matRad_loadHLUT(ct, radiationMode)
% matRad function to load HLUT file based on the provided ct
%
% call
% hlut = matRad_loadHLUT(ct, pln)
%
% input
% ct: unprocessed dicom ct data
% pln: matRad pln struct
% ct: ct with dicom information
% radiationMode: radiationMode as character array (e.g. 'photons') since matRad 3.
% Can also be a pln-struct for downwards compatibility
%
% output
% hlut: lookup table
Expand Down Expand Up @@ -36,11 +37,20 @@
hlutDir = [];
end

%Old version - takes radiation mode from pln
if isstruct(radiationMode) && isfield(radiationMode,'radiationMode')
particle = radiationMode.radiationMode;
elseif ischar(radiationMode)
particle = radiationMode;
else
matRad_cfg.dispError('Invalid radiation mode!');
end


% if possible -> file standard out of dicom tags
try

hlutFileName = '';
particle = pln.radiationMode;
manufacturer = ct.dicomInfo.Manufacturer;
model = ct.dicomInfo.ManufacturerModelName;
convKernel = ct.dicomInfo.ConvolutionKernel;
Expand Down
Loading