Skip to content

Commit e61674f

Browse files
committed
updates to use propSeq with numLevels as level property
1 parent 21233f2 commit e61674f

10 files changed

+55
-27
lines changed

matRad/MatRad_Config.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ function setDefaultProperties(obj)
246246

247247
%Sequencing Options
248248
obj.defaults.propSeq.sequencer = 'siochi';
249+
obj.defaults.propSeq.numLevels = 5;
249250

250251

251252

matRad/matRad_fluenceOptimization.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@
387387
matRad_cfg.dispInfo('Using standard MU bounds of [0,Inf]!\n')
388388
end
389389

390-
if pln.propOpt.runVMAT
390+
if isfield(pln.propOpt,'runVMAT') && pln.propOpt.runVMAT
391391
% Only the bixels belonging to FMO gantry angles should have their
392392
% weights optimized. The rest should be initialized and bounded to
393393
% zero.

matRad/matRad_sequencing.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@
4848
matRad_cfg.dispWarning ('pln.propSeq.sequencer not specified. Using siochi leaf sequencing (default).')
4949
end
5050

51-
% Is this used? Is it the same as numLevels? Should standardize, across
52-
% all leaf sequencing algorithms.
53-
if ~isfield(pln.propSeq, 'sequencingLevel')
54-
pln.propSeq.sequencingLevel = 5;
55-
matRad_cfg.dispWarning ('pln.propSeq.sequencingLevel not specified. Using 5 sequencing levels (default).')
51+
52+
if ~any(isfield(pln.propSeq, {'numLevels','sequencingLevel'}))
53+
pln.propSeq.numLevels = 5;
54+
matRad_cfg.dispWarning ('pln.propSeq.sequencingLevel not specified. Using 5 sequencing levels (default).')
55+
elseif isfield(pln.propSeq,'sequencingLevel')
56+
matRad_cfg.dispDeprecationWarning('The pln.propSeq.sequencingLevel property is deprecated. Use pln.propSeq.numLevels instead!');
57+
pln.propSeq.numLevels = pln.propSeq.sequencingLevel;
5658
end
5759

5860
% Could probably consolidate a lot of the code in the following

matRad/sequencing/matRad_engelLeafSequencing.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
% this field is empty resultGUI struct will be created
1212
% stf: matRad steering information struct
1313
% dij: matRad's dij matrix
14-
% pln.propOpt.numLevels: number of stratification levels
14+
% pln: pln struct
1515
% visBool: toggle on/off visualization (optional)
1616
%
1717
% output
@@ -34,6 +34,8 @@
3434
%
3535
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3636

37+
matRad_cfg = MatRad_Config.instance();
38+
3739
% if visBool not set toogle off visualization
3840
if nargin < 5
3941
visBool = 0;
@@ -50,6 +52,10 @@
5052
seqFig = figure('position',[xpos,ypos,sz(2),sz(1)]);
5153
end
5254

55+
if ~isfield(pln,'propSeq') || ~isfield(pln.propSeq,'numLevels')
56+
pln.propSeq.numLevels = matRad_cfg.defaults.propSeq.numLevels;
57+
end
58+
5359
offset = 0;
5460

5561
for i = 1:numOfBeams
@@ -92,7 +98,7 @@
9298

9399
% Stratification
94100
calFac = max(fluenceMx(:));
95-
D_k = round(fluenceMx/calFac*pln.propOpt.numLevels);
101+
D_k = round(fluenceMx/calFac*pln.propSeq.numLevels);
96102

97103
% Save the stratification in the initial intensity matrix D_0.
98104
D_0 = D_k;
@@ -108,7 +114,7 @@
108114

109115
seqSubPlots(1) = subplot(2,2,1,'parent',seqFig);
110116
imagesc(D_k,'parent',seqSubPlots(1));
111-
set(seqSubPlots(1),'CLim',[0 pln.propOpt.numLevels],'YDir','normal');
117+
set(seqSubPlots(1),'CLim',[0 pln.propSeq.numLevels],'YDir','normal');
112118
title(seqSubPlots(1),['Beam # ' num2str(i) ': max(D_0) = ' num2str(max(D_0(:))) ' - ' num2str(numel(unique(D_0))) ' intensity levels']);
113119
xlabel(seqSubPlots(1),'x - direction parallel to leaf motion ')
114120
ylabel(seqSubPlots(1),'z - direction perpendicular to leaf motion ')
@@ -136,7 +142,7 @@
136142
if visBool
137143
seqSubPlots(2) = subplot(2,2,2,'parent',seqFig);
138144
imagesc(D_k,'parent',seqSubPlots(2));
139-
set(seqSubPlots(2),'CLim',[0 pln.propOpt.numLevels],'YDir','normal');
145+
set(seqSubPlots(2),'CLim',[0 pln.propSeq.numLevels],'YDir','normal');
140146
title(seqSubPlots(2),['k = ' num2str(k)]);
141147
colorbar
142148
drawnow
@@ -355,11 +361,11 @@
355361

356362
sequencing.beam(i).numOfShapes = k;
357363
sequencing.beam(i).shapes = shapes(:,:,1:k);
358-
sequencing.beam(i).shapesWeight = shapesWeight(1:k)/pln.propOpt.numLevels*calFac;
364+
sequencing.beam(i).shapesWeight = shapesWeight(1:k)/pln.propSeq.numLevels*calFac;
359365
sequencing.beam(i).bixelIx = 1+offset:numOfRaysPerBeam+offset;
360366
sequencing.beam(i).fluence = D_0;
361367

362-
sequencing.w(1+offset:numOfRaysPerBeam+offset,1) = D_0(indInFluenceMx)/pln.propOpt.numLevels*calFac;
368+
sequencing.w(1+offset:numOfRaysPerBeam+offset,1) = D_0(indInFluenceMx)/pln.propSeq.numLevels*calFac;
363369

364370
offset = offset + numOfRaysPerBeam;
365371

matRad/sequencing/matRad_sequencing2ApertureInfo.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@
4545
bixOffset = 1; %used for gradient calculations
4646
interpGetsTransition = false; % boolean to determine if an interpolated beam is responsible for a leaf speed constraint check
4747

48+
if ~isfield(pln, 'propOpt') || ~isfield(pln.propOpt,'runVMAT')
49+
pln.propOpt.runVMAT = false;
50+
end
51+
4852
if pln.propOpt.runVMAT
4953
totalNumOfOptBixels = 0;
50-
totalNumOfLeafPairs = 0;
51-
54+
totalNumOfLeafPairs = 0;
5255
apertureInfo.propVMAT.jacobT = zeros(sum([sequencing.beam.numOfShapes]),numel(sequencing.beam));
5356
end
5457

matRad/sequencing/matRad_siochiLeafSequencing.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464

6565
offset = 0;
6666

67+
if ~isfield(pln,'propSeq') || ~isfield(pln.propSeq,'numLevels')
68+
pln.propSeq.numLevels = matRad_cfg.defaults.propSeq.numLevels;
69+
end
70+
6771
if ~isfield(pln.propOpt,'runVMAT')
6872
pln.propOpt.runVMAT = false;
6973
end

matRad/sequencing/matRad_xiaLeafSequencing.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
visBool = 0;
4141
end
4242

43+
matRad_cfg = MatRad_Config.instance();
44+
4345
mode = 'rl'; % sliding window (sw) or reducing level (rl)
4446

4547
numOfBeams = numel(stf);
@@ -53,6 +55,10 @@
5355
seqFig = figure('position',[xpos,ypos,sz(2),sz(1)]);
5456
end
5557

58+
if ~isfield(pln,'propSeq') || ~isfield(pln.propSeq,'numLevels')
59+
pln.propSeq.numLevels = matRad_cfg.defaults.propSeq.numLevels;
60+
end
61+
5662
offset = 0;
5763

5864
for i = 1:numOfBeams
@@ -95,7 +101,7 @@
95101

96102
% Stratification
97103
calFac = max(fluenceMx(:));
98-
D_k = round(fluenceMx/calFac*pln.propOpt.numLevels);
104+
D_k = round(fluenceMx/calFac*pln.propSeq.numLevels);
99105

100106
% Save the stratification in the initial intensity matrix D_0.
101107
D_0 = D_k;
@@ -242,11 +248,11 @@
242248

243249
sequencing.beam(i).numOfShapes = k;
244250
sequencing.beam(i).shapes = shapes(:,:,1:k);
245-
sequencing.beam(i).shapesWeight = shapesWeight(1:k)/pln.propOpt.numLevels*calFac;
251+
sequencing.beam(i).shapesWeight = shapesWeight(1:k)/pln.propSeq.numLevels*calFac;
246252
sequencing.beam(i).bixelIx = 1+offset:numOfRaysPerBeam+offset;
247253
sequencing.beam(i).fluence = D_0;
248254

249-
sequencing.w(1+offset:numOfRaysPerBeam+offset,1) = D_0(indInFluenceMx)/pln.propOpt.numLevels*calFac;
255+
sequencing.w(1+offset:numOfRaysPerBeam+offset,1) = D_0(indInFluenceMx)/pln.propSeq.numLevels*calFac;
250256

251257
offset = offset + numOfRaysPerBeam;
252258

test/sequencing/test_engelLeafSequencing.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@
1212
% Test Case, and add them to the test-runner
1313
initTestSuite;
1414

15-
function [resultGUI,stf,dij] = helper_getTestData()
15+
function [resultGUI,stf,dij,pln] = helper_getTestData()
1616
p = load('photons_testData.mat');
1717
resultGUI = p.resultGUI;
1818
stf = p.stf;
1919
dij = p.dij;
20+
pln = p.pln;
2021

2122

2223
function test_run_sequencing_basic
23-
[resultGUI,stf,dij] = helper_getTestData();
24+
[resultGUI,stf,dij,pln] = helper_getTestData();
2425
fn_old = fieldnames(resultGUI);
2526

2627
numOfLevels = [1,10];
2728

2829
for levels = numOfLevels
29-
resultGUI_sequenced = matRad_engelLeafSequencing(resultGUI,stf,dij,levels);
30+
pln.propSeq.numLevels = levels;
31+
resultGUI_sequenced = matRad_engelLeafSequencing(resultGUI,stf,dij,pln);
3032

3133
fn_new = fieldnames(resultGUI_sequenced);
3234
for i = 1:numel(fn_old)

test/sequencing/test_siochiLeafSequencing.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@
1212
% Test Case, and add them to the test-runner
1313
initTestSuite;
1414

15-
function [resultGUI,stf,dij] = helper_getTestData()
15+
function [resultGUI,stf,dij,pln] = helper_getTestData()
1616
p = load('photons_testData.mat');
1717
resultGUI = p.resultGUI;
1818
stf = p.stf;
1919
dij = p.dij;
20+
pln = p.pln;
2021

2122

2223
function test_run_sequencing_basic
23-
[resultGUI,stf,dij] = helper_getTestData();
24+
[resultGUI,stf,dij,pln] = helper_getTestData();
2425
fn_old = fieldnames(resultGUI);
2526

26-
numOfLevels = [1,10];
27+
numOfLevels = [1,10];
2728

2829
for levels = numOfLevels
29-
resultGUI_sequenced = matRad_siochiLeafSequencing(resultGUI,stf,dij,levels);
30+
pln.propSeq.numLevels = levels;
31+
resultGUI_sequenced = matRad_siochiLeafSequencing(resultGUI,stf,dij,pln);
3032

3133
fn_new = fieldnames(resultGUI_sequenced);
3234
for i = 1:numel(fn_old)

test/sequencing/test_xiaLeafSequencing.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@
1212
% Test Case, and add them to the test-runner
1313
initTestSuite;
1414

15-
function [resultGUI,stf,dij] = helper_getTestData()
15+
function [resultGUI,stf,dij,pln] = helper_getTestData()
1616
p = load('photons_testData.mat');
1717
resultGUI = p.resultGUI;
1818
stf = p.stf;
1919
dij = p.dij;
20+
pln = p.pln;
2021

2122

2223
function test_run_sequencing_basic
23-
[resultGUI,stf,dij] = helper_getTestData();
24+
[resultGUI,stf,dij,pln] = helper_getTestData();
2425
fn_old = fieldnames(resultGUI);
2526

2627
numOfLevels = [1,10];
2728

2829
for levels = numOfLevels
29-
resultGUI_sequenced = matRad_xiaLeafSequencing(resultGUI,stf,dij,levels);
30+
pln.propSeq.numLevels = levels;
31+
resultGUI_sequenced = matRad_xiaLeafSequencing(resultGUI,stf,dij,pln);
3032

3133
fn_new = fieldnames(resultGUI_sequenced);
3234
for i = 1:numel(fn_old)

0 commit comments

Comments
 (0)