matRad function to bypass dij calculation for MC dose calculation matRad dose calculation wrapper for MC dose calculation algorithms bypassing dij calculation for MC dose calculation algorithms. call resultGUI = matRad_calcDoseDirecMC(ct,stf,pln,cst) resultGUI = matRad_calcDoseDirecMC(ct,stf,pln,cst,w) resultGUI = matRad_calcDoseDirectMC(ct,stf,pln,cst,nHistories) resultGUI = matRad_calcDoseDirectMC(ct,stf,pln,cst,w,nHistories) input ct: ct cube stf: matRad steering information struct pln: matRad plan meta information struct cst: matRad cst struct w: (optional, if no weights available in stf): bixel weight vector nHistories: (optional) number of histories output resultGUI: matRad result struct References - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright 2019 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 resultGUI = matRad_calcDoseDirectMC(ct,stf,pln,cst,w,nHistories) 0002 % matRad function to bypass dij calculation for MC dose calculation 0003 % matRad dose calculation wrapper for MC dose calculation algorithms 0004 % bypassing dij calculation for MC dose calculation algorithms. 0005 % 0006 % call 0007 % resultGUI = matRad_calcDoseDirecMC(ct,stf,pln,cst) 0008 % resultGUI = matRad_calcDoseDirecMC(ct,stf,pln,cst,w) 0009 % resultGUI = matRad_calcDoseDirectMC(ct,stf,pln,cst,nHistories) 0010 % resultGUI = matRad_calcDoseDirectMC(ct,stf,pln,cst,w,nHistories) 0011 % 0012 % input 0013 % ct: ct cube 0014 % stf: matRad steering information struct 0015 % pln: matRad plan meta information struct 0016 % cst: matRad cst struct 0017 % w: (optional, if no weights available in stf): bixel weight 0018 % vector 0019 % nHistories: (optional) number of histories 0020 % 0021 % output 0022 % resultGUI: matRad result struct 0023 % 0024 % References 0025 % - 0026 % 0027 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0028 % 0029 % Copyright 2019 the matRad development team. 0030 % 0031 % This file is part of the matRad project. It is subject to the license 0032 % terms in the LICENSE file found in the top-level directory of this 0033 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0034 % of the matRad project, including this file, may be copied, modified, 0035 % propagated, or distributed except according to the terms contained in the 0036 % LICENSE file. 0037 % 0038 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0039 0040 0041 matRad_cfg = MatRad_Config.instance(); 0042 0043 calcDoseDirect = true; 0044 0045 if nargin < 6 || ~exist('nHistories') 0046 nHistories = matRad_cfg.propMC.direct_defaultHistories; 0047 matRad_cfg.dispInfo('Using default number of Histories: %d\n',nHistories); 0048 end 0049 0050 % check if weight vector is available, either in function call or in stf - otherwise dose calculation not possible 0051 if ~exist('w','var') && ~isfield([stf.ray],'weight') 0052 matRad_cfg.dispError('No weight vector available. Please provide w or add info to stf'); 0053 end 0054 0055 % copy bixel weight vector into stf struct 0056 if exist('w','var') 0057 if sum([stf.totalNumOfBixels]) ~= numel(w) 0058 matRad_cfg.dispError('weighting does not match steering information'); 0059 end 0060 counter = 0; 0061 for i = 1:size(stf,2) 0062 for j = 1:stf(i).numOfRays 0063 for k = 1:stf(i).numOfBixelsPerRay(j) 0064 counter = counter + 1; 0065 stf(i).ray(j).weight(k) = w(counter); 0066 end 0067 end 0068 end 0069 else % weights need to be in stf! 0070 w = NaN*ones(sum([stf.totalNumOfBixels]),1); 0071 counter = 0; 0072 for i = 1:size(stf,2) 0073 for j = 1:stf(i).numOfRays 0074 for k = 1:stf(i).numOfBixelsPerRay(j) 0075 counter = counter + 1; 0076 w(counter) = stf(i).ray(j).weight(k); 0077 end 0078 end 0079 end 0080 end 0081 0082 % dose calculation 0083 if strcmp(pln.radiationMode,'protons') 0084 dij = matRad_calcParticleDoseMC(ct,stf,pln,cst,nHistories,calcDoseDirect); 0085 else 0086 matRad_cfg.dispError('Forward MC only implemented for protons.'); 0087 end 0088 0089 % hack dij struct 0090 dij.numOfBeams = 1; 0091 dij.beamNum = 1; 0092 0093 % calculate cubes; use uniform weights here, weighting with actual fluence 0094 % already performed in dij construction 0095 resultGUI = matRad_calcCubes(sum(w),dij); 0096 0097 % remember original fluence weights 0098 resultGUI.w = w; 0099 0100 0101 0102