matRad_daoApertureInfo2Vec

Purpose ^

matRad function to generate a vector respresentation of objects

Synopsis ^

function [apertureInfoVec, mappingMx, limMx] = matRad_daoApertureInfo2Vec(apertureInfo)

Description ^

 matRad function to generate a vector respresentation of objects
 A vector representation of the aperture weights and shapes and (optional) 
 some meta information needed during optimization is generated.

 call
   [apertureInfoVec, mappingMx, limMx] = matRad_daoApertureInfo2Vec(apertureInfo)

 input
   apertureInfo:    aperture weight and shape info struct

 output
   apertureInfoVec: vector respresentation of the apertue weights and shapes
   mappingMx:       mapping of vector components to beams, shapes and leaves
   limMx:           bounds on vector components, i.e., minimum and maximum
                    aperture weights (0/inf) and leav positions (custom)

 References
   

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

Cross-reference information ^

This function calls: This function is called by:

Source code ^

0001 function [apertureInfoVec, mappingMx, limMx] = matRad_daoApertureInfo2Vec(apertureInfo)
0002 % matRad function to generate a vector respresentation of objects
0003 % A vector representation of the aperture weights and shapes and (optional)
0004 % some meta information needed during optimization is generated.
0005 %
0006 % call
0007 %   [apertureInfoVec, mappingMx, limMx] = matRad_daoApertureInfo2Vec(apertureInfo)
0008 %
0009 % input
0010 %   apertureInfo:    aperture weight and shape info struct
0011 %
0012 % output
0013 %   apertureInfoVec: vector respresentation of the apertue weights and shapes
0014 %   mappingMx:       mapping of vector components to beams, shapes and leaves
0015 %   limMx:           bounds on vector components, i.e., minimum and maximum
0016 %                    aperture weights (0/inf) and leav positions (custom)
0017 %
0018 % References
0019 %
0020 %
0021 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 
0023 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0024 %
0025 % Copyright 2015 the matRad development team.
0026 %
0027 % This file is part of the matRad project. It is subject to the license
0028 % terms in the LICENSE file found in the top-level directory of this
0029 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0030 % of the matRad project, including this file, may be copied, modified,
0031 % propagated, or distributed except according to the terms contained in the
0032 % LICENSE file.
0033 %
0034 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0035 
0036 % function to create a single vector for the direct aperature optimization
0037 % first: aperature weights
0038 % second: left leaf positions
0039 % third: right leaf positions
0040 
0041 % initializing variables
0042 
0043 apertureInfoVec = NaN * ones(apertureInfo.totalNumOfShapes+apertureInfo.totalNumOfLeafPairs*2,1);
0044 
0045 offset = 0;
0046 
0047 %% 1. aperture weights
0048 for i = 1:size(apertureInfo.beam,2)
0049     for j = 1:apertureInfo.beam(i).numOfShapes
0050         apertureInfoVec(offset+j) = apertureInfo.beam(i).shape(j).weight;            
0051     end
0052     offset = offset + apertureInfo.beam(i).numOfShapes;
0053 end
0054 
0055 % 2. left and right leaf positions
0056 %% fill the vector for all shapes of all beams
0057 for i = 1:size(apertureInfo.beam,2)
0058     for j = 1:apertureInfo.beam(i).numOfShapes
0059         apertureInfoVec(offset+[1:apertureInfo.beam(i).numOfActiveLeafPairs]) = apertureInfo.beam(i).shape(j).leftLeafPos;
0060         apertureInfoVec(offset+[1:apertureInfo.beam(i).numOfActiveLeafPairs]+apertureInfo.totalNumOfLeafPairs) = apertureInfo.beam(i).shape(j).rightLeafPos;
0061         offset = offset + apertureInfo.beam(i).numOfActiveLeafPairs;
0062     end
0063 end
0064     
0065 
0066 %% 3. create additional information for later use
0067 if nargout > 1
0068     
0069     mappingMx =  NaN * ones(apertureInfo.totalNumOfShapes+apertureInfo.totalNumOfLeafPairs*2,4);
0070     limMx     =  NaN * ones(apertureInfo.totalNumOfShapes+apertureInfo.totalNumOfLeafPairs*2,2);
0071     limMx(1:apertureInfo.totalNumOfShapes,:) = ones(apertureInfo.totalNumOfShapes,1)*[0 inf];
0072     
0073     counter = 1;
0074     for i = 1:numel(apertureInfo.beam)
0075         for j = 1:apertureInfo.beam(i).numOfShapes
0076             mappingMx(counter,1) = i;
0077             counter = counter + 1;
0078         end
0079     end
0080     
0081     shapeOffset = 0;
0082     for i = 1:numel(apertureInfo.beam)
0083         for j = 1:apertureInfo.beam(i).numOfShapes
0084             for k = 1:apertureInfo.beam(i).numOfActiveLeafPairs
0085                 mappingMx(counter,1) = i;
0086                 mappingMx(counter,2) = j + shapeOffset; % store global shape number for grad calc
0087                 mappingMx(counter,3) = j; % store local shape number
0088                 mappingMx(counter,4) = k; % store local leaf number
0089                 
0090                 limMx(counter,1)     = apertureInfo.beam(i).lim_l(k);
0091                 limMx(counter,2)     = apertureInfo.beam(i).lim_r(k);
0092                 counter = counter + 1;
0093             end
0094         end
0095         shapeOffset = shapeOffset + apertureInfo.beam(i).numOfShapes;
0096     end
0097     
0098     mappingMx(counter:end,:) = mappingMx(apertureInfo.totalNumOfShapes+1:counter-1,:);
0099     limMx(counter:end,:)     = limMx(apertureInfo.totalNumOfShapes+1:counter-1,:);
0100 
0101 end

| Generated by m2html © 2005