Skip to content

Commit

Permalink
Merge pull request e0404#492 from e0404/master_hotfixEffectiveCutoff
Browse files Browse the repository at this point in the history
Fix issue with effective lateral cutoff for large photon fields
  • Loading branch information
wahln authored Apr 1, 2021
2 parents 6fad1b8 + 803d0de commit d10fb18
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions MatRad_Config.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function setDefaultProperties(obj)
obj.propDoseCalc.defaultResolution = struct('x',3,'y',3,'z',3); %[mm]
obj.propDoseCalc.defaultLateralCutOff = 0.995; %[rel.]
obj.propDoseCalc.defaultGeometricCutOff = 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
Expand Down Expand Up @@ -180,6 +181,7 @@ function setDefaultPropertiesForTesting(obj)
obj.propDoseCalc.defaultResolution = struct('x',5,'y',6,'z',7); %[mm]
obj.propDoseCalc.defaultGeometricCutOff = 20;
obj.propDoseCalc.defaultLateralCutOff = 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;
Expand Down
31 changes: 26 additions & 5 deletions matRad_calcPhotonDose.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,24 @@
set(figureWait,'pointer','watch');

% set lateral cutoff value
lateralCutoff = matRad_cfg.propDoseCalc.defaultGeometricCutOff; % [mm]
if ~isfield(pln,'propDoseCalc') || ~isfield(pln.propDoseCalc,'geometricCutOff')
pln.propDoseCalc.geometricCutOff = matRad_cfg.propDoseCalc.defaultGeometricCutOff; % [mm]
end

lateralCutoff = pln.propDoseCalc.geometricCutOff;

if ~isfield(pln,'propDoseCalc') || ~isfield(pln.propDoseCalc,'kernelCutOff')
pln.propDoseCalc.kernelCutOff = matRad_cfg.propDoseCalc.defaultKernelCutOff; % [mm]
end

% set kernel cutoff value (determines how much of the kernel is used. This
% value is separated from lateralCutOff to obtain accurate large open fields)
kernelCutoff = pln.propDoseCalc.kernelCutOff;

if kernelCutoff < lateralCutoff
matRad_cfg.dispWarning('Kernel Cut-Off ''%f mm'' cannot be smaller than geometric lateral cutoff ''%f mm''. Using ''%f mm''!',kernelCutoff,lateralCutoff,lateralCutoff);
kernelCutoff = lateralCutoff;
end

% toggle custom primary fluence on/off. if 0 we assume a homogeneous
% primary fluence, if 1 we use measured radially symmetric data
Expand Down Expand Up @@ -119,12 +136,16 @@
end

% get kernel size and distances
kernelLimit = ceil(lateralCutoff/intConvResolution);
if kernelCutoff > machine.data.kernelPos(end)
kernelCutoff = machine.data.kernelPos(end);
end

kernelLimit = ceil(kernelCutoff/intConvResolution);
[kernelX, kernelZ] = meshgrid(-kernelLimit*intConvResolution: ...
intConvResolution: ...
(kernelLimit-1)*intConvResolution);

% precalculate convoluted kernel size and distances
% precalculate convolved kernel size and distances
kernelConvLimit = fieldLimit + gaussLimit + kernelLimit;
[convMx_X, convMx_Z] = meshgrid(-kernelConvLimit*intConvResolution: ...
intConvResolution: ...
Expand All @@ -134,7 +155,7 @@

% define an effective lateral cutoff where dose will be calculated. note
% that storage within the influence matrix may be subject to sampling
effectiveLateralCutoff = lateralCutoff + fieldWidth/2;
effectiveLateralCutoff = lateralCutoff + fieldWidth/sqrt(2);

counter = 0;
matRad_cfg.dispInfo('matRad: Photon dose calculation...\n');
Expand Down Expand Up @@ -206,7 +227,7 @@
% apply the primary fluence to the field
Fx = F .* Psi;

% convolute with the gaussian
% convolve with the gaussian
Fx = real( ifft2(fft2(Fx,gaussConvSize,gaussConvSize).* fft2(gaussFilter,gaussConvSize,gaussConvSize)) );

% 2D convolution of Fluence and Kernels in fourier domain
Expand Down

0 comments on commit d10fb18

Please sign in to comment.