Skip to content

Commit 1c07ad5

Browse files
authored
Merge pull request e0404#763 from Gattowski/dev
Stf Generators Refactor
2 parents 1002eb9 + 01fe209 commit 1c07ad5

24 files changed

+2829
-1125
lines changed

examples/matRad_example12_simpleParticleMonteCarlo.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
%Enable/Disable use of range shifter (has effect only when we need to fill
6666
%up the low-range region)
6767
pln.propStf.useRangeShifter = false;
68+
pln.propStf.generator = 'ParticleSingleSpot';
6869

6970
%Enable LET calculation
7071
pln.propDoseCalc.calcLET = true;
@@ -74,8 +75,7 @@
7475
% pln.propMC.externalCalculation = true;
7576

7677
%% generate steering file
77-
%stf = matRad_generateStf(ct,cst,pln);
78-
stf = matRad_generateSingleBixelStf(ct,cst,pln); %Example to create a single beamlet stf
78+
stf = matRad_generateStf(ct,cst,pln);
7979

8080
%% analytical dose calculation
8181
pln.propDoseCalc.engine = 'MCsquare';

examples/matRad_example15_brachy.m

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -121,32 +121,34 @@
121121

122122

123123
pln.propStf.bixelWidth = 5; % [mm] template grid distance
124-
pln.propStf.templateRoot = matRad_getTemplateRoot(ct,cst); % mass center of
125-
% target in x and y and bottom in z
124+
125+
%Template Type
126+
pln.propStf.template.type = 'checkerboard'; % 'checkerboard' if template is created automatically
127+
% 'manual' if template is needed as preset manually (see below)
128+
129+
%Template Root - mass center of target in x and y and bottom in z
130+
pln.propStf.template.root = matRad_getTemplateRoot(ct,cst);
126131

127132
% Here, we define active needles as 1 and inactive needles
128133
% as 0. This is the x-y plane and needles point in z direction.
129134
% A checkerboard pattern is frequantly used. The whole geometry will become
130135
% clearer when it is displayed in 3D view in the next section.
131-
132-
pln.propStf.template.activeNeedles = [0 0 0 1 0 1 0 1 0 1 0 0 0;... % 7.0
133-
0 0 1 0 1 0 0 0 1 0 1 0 0;... % 6.5
134-
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 6.0
135-
1 0 1 0 1 0 0 0 1 0 1 0 1;... % 5.5
136-
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 5.0
137-
1 0 1 0 1 0 0 0 1 0 1 0 1;... % 4.5
138-
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 4.0
139-
1 0 1 0 1 0 0 0 1 0 1 0 1;... % 4.5
140-
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 3.0
141-
1 0 1 0 1 0 1 0 1 0 1 0 1;... % 2.5
142-
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 2.0
143-
1 0 1 0 1 0 0 0 0 0 1 0 1;... % 1.5
144-
0 0 0 0 0 0 0 0 0 0 0 0 0]; % 1.0
145-
%A a B b C c D d E e F f G
146-
147-
pln.propStf.isoCenter = matRad_getIsoCenter(cst,ct,0); % target center
148-
149-
136+
if strcmp(pln.propStf.template.type,'manual')
137+
pln.propStf.template.activeNeedles = [0 0 0 1 0 1 0 1 0 1 0 0 0;... % 7.0
138+
0 0 1 0 1 0 0 0 1 0 1 0 0;... % 6.5
139+
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 6.0
140+
1 0 1 0 1 0 0 0 1 0 1 0 1;... % 5.5
141+
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 5.0
142+
1 0 1 0 1 0 0 0 1 0 1 0 1;... % 4.5
143+
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 4.0
144+
1 0 1 0 1 0 0 0 1 0 1 0 1;... % 4.5
145+
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 3.0
146+
1 0 1 0 1 0 1 0 1 0 1 0 1;... % 2.5
147+
0 1 0 1 0 1 0 1 0 1 0 1 0;... % 2.0
148+
1 0 1 0 1 0 0 0 0 0 1 0 1;... % 1.5
149+
0 0 0 0 0 0 0 0 0 0 0 0 0]; % 1.0
150+
%A a B b C c D d E e F f G
151+
end
150152

151153
%% II.1 - dose calculation options
152154
% for dose calculation we use eather the 2D or the 1D formalism proposed by
@@ -176,6 +178,8 @@
176178
else
177179
pln.propOpt.optimizer = 'IPOPT';
178180
end
181+
182+
pln.propOpt.optimizer = 'IPOPT';
179183
%% II.1 - book keeping
180184
% Some field names have to be kept although they don't have a direct
181185
% relevance for brachy therapy.
@@ -189,21 +193,21 @@
189193

190194
%% II.1 - view plan
191195
% Et voila! Our treatment plan structure is ready. Lets have a look:
192-
display(pln);
196+
disp(pln);
193197

194198

195199
%% II.2 Steering Seed Positions From STF
196200
% The steering file struct contains all needls/catheter geometry with the
197201
% target volume, number of needles, seeds and the positions of all needles
198202
% The one in the end enables visualization.
199203

200-
stf = matRad_generateStf(ct,cst,pln,1);
204+
stf = matRad_generateStf(ct,cst,pln);
205+
201206

202207
%% II.2 - view stf
203208
% The 3D view is interesting, but we also want to know how the stf struct
204209
% looks like.
205-
206-
display(stf)
210+
disp(stf);
207211

208212
%% II.3 - Dose Calculation
209213
% Let's generate dosimetric information by pre-computing a dose influence
@@ -226,7 +230,7 @@
226230
%% IV.1 Plot the Resulting Dose Slice
227231
% Let's plot the transversal iso-center dose slice
228232

229-
slice = matRad_world2cubeIndex(pln.propStf.isoCenter(1,:),ct);
233+
slice = matRad_world2cubeIndex(matRad_getIsoCenter(cst,ct),ct);
230234
slice = slice(3);
231235
figure
232236
imagesc(resultGUI.physicalDose(:,:,slice)),colorbar, colormap(jet);

examples/matRad_example2_photons.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
% calculate the iso-center which is per default the center of gravity of
123123
% all target voxels.
124124
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles);
125-
pln.propStf.isoCenter = ones(pln.propStf.numOfBeams,1) * matRad_getIsoCenter(cst,ct,0);
125+
pln.propStf.isoCenter = matRad_getIsoCenter(cst,ct,0);
126126

127127
%% dose calculation settings
128128
% set resolution of dose calculation and optimization
@@ -150,6 +150,7 @@
150150
%% Generate Beam Geometry STF
151151
% The steering file struct comprises the complete beam geometry along with
152152
% ray position, pencil beam positions and energies, source to axis distance (SAD) etc.
153+
153154
stf = matRad_generateStf(ct,cst,pln);
154155

155156
%%
@@ -184,6 +185,8 @@
184185
pln.propStf.couchAngles = zeros(1,numel(pln.propStf.gantryAngles));
185186
pln.propStf.numOfBeams = numel(pln.propStf.gantryAngles);
186187

188+
189+
187190
stf = matRad_generateStf(ct,cst,pln);
188191
pln.propStf.isoCenter = vertcat(stf.isoCenter);
189192
dij = matRad_calcDoseInfluence(ct,cst,stf,pln);

matRad/MatRad_Config.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ function setDefaultProperties(obj)
197197
% input
198198

199199
%Default Steering/Geometry Properties
200+
obj.defaults.propStf.generator = {'PhotonIMRT','ParticleIMPT','SimpleBrachy'};
200201
obj.defaults.propStf.longitudinalSpotSpacing = 2;
201202
obj.defaults.propStf.addMargin = true; %expand target for beamlet finding
202203
obj.defaults.propStf.bixelWidth = 5;

matRad/basedata/helium_Generic.mat

-1 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)