matRad_objectiveGradient

Purpose ^

matRad IPOPT callback: gradient function for direct aperture optimization

Synopsis ^

function g = matRad_objectiveGradient(optiProb,apertureInfoVec,dij,cst)

Description ^

 matRad IPOPT callback: gradient function for direct aperture optimization

 call
   g = matRad_objectiveGradient(optiProb,apertureInfoVec,dij,cst)

 input
   optiProb:           option struct defining the type of optimization
   apertureInfoVect:   aperture info in form of vector
   dij:                matRad dij struct as generated by bixel-based dose calculation
   cst:                matRad cst struct

 output
   g: gradient

 References
   [1] http://dx.doi.org/10.1118/1.4914863

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cross-reference information ^

This function calls: This function is called by:

Source code ^

0001 function g = matRad_objectiveGradient(optiProb,apertureInfoVec,dij,cst)
0002 % matRad IPOPT callback: gradient function for direct aperture optimization
0003 %
0004 % call
0005 %   g = matRad_objectiveGradient(optiProb,apertureInfoVec,dij,cst)
0006 %
0007 % input
0008 %   optiProb:           option struct defining the type of optimization
0009 %   apertureInfoVect:   aperture info in form of vector
0010 %   dij:                matRad dij struct as generated by bixel-based dose calculation
0011 %   cst:                matRad cst struct
0012 %
0013 % output
0014 %   g: gradient
0015 %
0016 % References
0017 %   [1] http://dx.doi.org/10.1118/1.4914863
0018 %
0019 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 
0021 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 %
0023 % Copyright 2015 the matRad development team.
0024 %
0025 % This file is part of the matRad project. It is subject to the license
0026 % terms in the LICENSE file found in the top-level directory of this
0027 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0028 % of the matRad project, including this file, may be copied, modified,
0029 % propagated, or distributed except according to the terms contained in the
0030 % LICENSE file.
0031 %
0032 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0033 
0034 apertureInfo = optiProb.apertureInfo;
0035 
0036 % update apertureInfo, bixel weight vector an mapping of leafes to bixels
0037 if ~isequal(apertureInfoVec,apertureInfo.apertureVector)
0038     apertureInfo = optiProb.matRad_daoVec2ApertureInfo(apertureInfo,apertureInfoVec);
0039 end
0040 
0041 % bixel based gradient calculation
0042 bixelG = matRad_objectiveGradient@matRad_OptimizationProblem(optiProb,apertureInfo.bixelWeights,dij,cst);
0043     
0044 % allocate gradient vector for aperture weights and leaf positions
0045 g = NaN * ones(size(apertureInfoVec,1),1);
0046 
0047 % 1. calculate aperatureGrad
0048 % loop over all beams
0049 offset = 0;
0050 for i = 1:numel(apertureInfo.beam)
0051 
0052     % get used bixels in beam
0053     ix = ~isnan(apertureInfo.beam(i).bixelIndMap);
0054 
0055     % loop over all shapes and add up the gradients x openingFrac for this shape
0056     for j = 1:apertureInfo.beam(i).numOfShapes            
0057         g(j+offset) = apertureInfo.beam(i).shape(j).shapeMap(ix)' ...
0058                         * bixelG(apertureInfo.beam(i).bixelIndMap(ix));
0059     end
0060 
0061     % increment offset
0062     offset = offset + apertureInfo.beam(i).numOfShapes;
0063 
0064 end
0065 
0066 % 2. find corresponding bixel to the leaf Positions and aperture
0067 % weights to calculate the gradient
0068 g(apertureInfo.totalNumOfShapes+1:end) = ...
0069         apertureInfoVec(apertureInfo.mappingMx(apertureInfo.totalNumOfShapes+1:end,2)) ...
0070      .* bixelG(apertureInfo.bixelIndices(apertureInfo.totalNumOfShapes+1:end)) / apertureInfo.bixelWidth;
0071 
0072 % correct the sign for the left leaf positions
0073 g(apertureInfo.totalNumOfShapes+1:apertureInfo.totalNumOfShapes+apertureInfo.totalNumOfLeafPairs) = ...
0074     -g(apertureInfo.totalNumOfShapes+1:apertureInfo.totalNumOfShapes+apertureInfo.totalNumOfLeafPairs);

| Generated by m2html © 2005