matRad function to run direct aperture optimization call [optResult,optimizer] = matRad_directApertureOptimization(dij,cst,apertureInfo,pln) [optResult,optimizer] = matRad_directApertureOptimization(dij,cst,apertureInfo,optResult,pln) input dij: matRad dij struct cst: matRad cst struct apertureInfo: aperture shape info struct optResult: resultGUI struct to which the output data will be added, if this field is empty optResult struct will be created (optional) pln: matRad pln struct output optResult: struct containing optimized fluence vector, dose, and shape info optimizer: used optimizer object References [1] http://dx.doi.org/10.1118/1.4914863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright 2015 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/LICENSES.txt. 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. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function [optResult,optimizer] = matRad_directApertureOptimization(dij,cst,apertureInfo,optResult,pln) 0002 % matRad function to run direct aperture optimization 0003 % 0004 % call 0005 % [optResult,optimizer] = matRad_directApertureOptimization(dij,cst,apertureInfo,pln) 0006 % [optResult,optimizer] = matRad_directApertureOptimization(dij,cst,apertureInfo,optResult,pln) 0007 % 0008 % input 0009 % dij: matRad dij struct 0010 % cst: matRad cst struct 0011 % apertureInfo: aperture shape info struct 0012 % optResult: resultGUI struct to which the output data will be added, if 0013 % this field is empty optResult struct will be created 0014 % (optional) 0015 % pln: matRad pln struct 0016 % 0017 % output 0018 % optResult: struct containing optimized fluence vector, dose, and 0019 % shape info 0020 % optimizer: used optimizer object 0021 % 0022 % References 0023 % [1] http://dx.doi.org/10.1118/1.4914863 0024 % 0025 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 % 0027 % Copyright 2015 the matRad development team. 0028 % 0029 % This file is part of the matRad project. It is subject to the license 0030 % terms in the LICENSE file found in the top-level directory of this 0031 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0032 % of the matRad project, including this file, may be copied, modified, 0033 % propagated, or distributed except according to the terms contained in the 0034 % LICENSE file. 0035 % 0036 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0037 0038 0039 matRad_cfg = MatRad_Config.instance(); 0040 0041 % adjust overlap priorities 0042 cst = matRad_setOverlapPriorities(cst); 0043 0044 % check & adjust objectives and constraints internally for fractionation 0045 for i = 1:size(cst,1) 0046 for j = 1:numel(cst{i,6}) 0047 obj = cst{i,6}{j}; 0048 0049 %In case it is a default saved struct, convert to object 0050 %Also intrinsically checks that we have a valid optimization 0051 %objective or constraint function in the end 0052 if ~isa(obj,'matRad_DoseOptimizationFunction') 0053 try 0054 obj = matRad_DoseOptimizationFunction.createInstanceFromStruct(obj); 0055 catch 0056 matRad_cfg.dispError('cst{%d,6}{%d} is not a valid Objective/constraint! Remove or Replace and try again!',i,j); 0057 end 0058 end 0059 0060 obj = obj.setDoseParameters(obj.getDoseParameters()/pln.numOfFractions); 0061 0062 cst{i,6}{j} = obj; 0063 end 0064 end 0065 0066 % resizing cst to dose cube resolution 0067 cst = matRad_resizeCstToGrid(cst,dij.ctGrid.x,dij.ctGrid.y,dij.ctGrid.z,... 0068 dij.doseGrid.x,dij.doseGrid.y,dij.doseGrid.z); 0069 0070 % update aperture info vector 0071 apertureInfo = matRad_OptimizationProblemDAO.matRad_daoVec2ApertureInfo(apertureInfo,apertureInfo.apertureVector); 0072 0073 %Use Dose Projection only 0074 backProjection = matRad_DoseProjection(); 0075 0076 optiProb = matRad_OptimizationProblemDAO(backProjection,apertureInfo); 0077 0078 if ~isfield(pln.propOpt,'optimizer') 0079 pln.propOpt.optimizer = 'IPOPT'; 0080 end 0081 0082 switch pln.propOpt.optimizer 0083 case 'IPOPT' 0084 optimizer = matRad_OptimizerIPOPT; 0085 case 'fmincon' 0086 optimizer = matRad_OptimizerFmincon; 0087 otherwise 0088 matRad_cfg.dispWarning('Optimizer ''%s'' not known! Fallback to IPOPT!',pln.propOpt.optimizer); 0089 optimizer = matRad_OptimizerIPOPT; 0090 end 0091 0092 % Run IPOPT. 0093 optimizer = optimizer.optimize(apertureInfo.apertureVector,optiProb,dij,cst); 0094 wOpt = optimizer.wResult; 0095 0096 % update the apertureInfoStruct and calculate bixel weights 0097 apertureInfo = matRad_OptimizationProblemDAO.matRad_daoVec2ApertureInfo(apertureInfo,wOpt); 0098 0099 % logging final results 0100 matRad_cfg.dispInfo('Calculating final cubes...\n'); 0101 resultGUI = matRad_calcCubes(apertureInfo.bixelWeights,dij); 0102 resultGUI.w = apertureInfo.bixelWeights; 0103 resultGUI.wDAO = apertureInfo.bixelWeights; 0104 resultGUI.apertureInfo = apertureInfo; 0105