function updatedInfo = matRad_daoVec2ApertureInfo(apertureInfo,apertureInfoVect)
0001 function updatedInfo = matRad_daoVec2ApertureInfo(apertureInfo,apertureInfoVect)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 w = zeros(apertureInfo.totalNumOfBixels,1);
0040
0041
0042 updatedInfo = apertureInfo;
0043
0044 updatedInfo.apertureVector = apertureInfoVect;
0045
0046 shapeInd = 1;
0047
0048 indVect = NaN*ones(apertureInfo.totalNumOfShapes + apertureInfo.totalNumOfLeafPairs,1);
0049
0050
0051 round2 = @(a,b) round(a*10^b)/10^b;
0052
0053
0054
0055
0056
0057
0058
0059 for i = 1:numel(updatedInfo.beam)
0060
0061
0062
0063
0064 edges_l = updatedInfo.beam(i).posOfCornerBixel(1)...
0065 + ([1:size(apertureInfo.beam(i).bixelIndMap,2)]-1-1/2)*updatedInfo.bixelWidth;
0066 edges_r = updatedInfo.beam(i).posOfCornerBixel(1)...
0067 + ([1:size(apertureInfo.beam(i).bixelIndMap,2)]-1+1/2)*updatedInfo.bixelWidth;
0068
0069
0070 for j = 1:updatedInfo.beam(i).numOfShapes
0071
0072
0073 updatedInfo.beam(i).shape(j).weight = apertureInfoVect(shapeInd);
0074
0075
0076 n = apertureInfo.beam(i).numOfActiveLeafPairs;
0077
0078
0079 vectorIx = updatedInfo.beam(i).shape(j).vectorOffset + ([1:n]-1);
0080 leftLeafPos = apertureInfoVect(vectorIx);
0081 rightLeafPos = apertureInfoVect(vectorIx+apertureInfo.totalNumOfLeafPairs);
0082
0083
0084 updatedInfo.beam(i).shape(j).leftLeafPos = leftLeafPos;
0085 updatedInfo.beam(i).shape(j).rightLeafPos = rightLeafPos;
0086
0087
0088 leftLeafPos = round2(leftLeafPos,6);
0089 rightLeafPos = round2(rightLeafPos,6);
0090
0091
0092 xPosIndLeftLeaf = round((leftLeafPos - apertureInfo.beam(i).posOfCornerBixel(1))/apertureInfo.bixelWidth + 1);
0093 xPosIndRightLeaf = round((rightLeafPos - apertureInfo.beam(i).posOfCornerBixel(1))/apertureInfo.bixelWidth + 1);
0094
0095
0096
0097 xPosIndLeftLeaf(leftLeafPos == apertureInfo.beam(i).lim_r) = ...
0098 .5 + (leftLeafPos(leftLeafPos == apertureInfo.beam(i).lim_r) ...
0099 - apertureInfo.beam(i).posOfCornerBixel(1))/apertureInfo.bixelWidth;
0100 xPosIndRightLeaf(rightLeafPos == apertureInfo.beam(i).lim_r) = ...
0101 .5 + (rightLeafPos(rightLeafPos == apertureInfo.beam(i).lim_r) ...
0102 - apertureInfo.beam(i).posOfCornerBixel(1))/apertureInfo.bixelWidth;
0103
0104
0105 bixelIndLeftLeaf = apertureInfo.beam(i).bixelIndMap((xPosIndLeftLeaf-1)*n+[1:n]');
0106 bixelIndRightLeaf = apertureInfo.beam(i).bixelIndMap((xPosIndRightLeaf-1)*n+[1:n]');
0107
0108 if any(isnan(bixelIndLeftLeaf)) || any(isnan(bixelIndRightLeaf))
0109 error('cannot map leaf position to bixel index');
0110 end
0111
0112
0113 indVect(apertureInfo.beam(i).shape(j).vectorOffset+[1:n]-1) = bixelIndLeftLeaf;
0114 indVect(apertureInfo.beam(i).shape(j).vectorOffset+[1:n]-1+apertureInfo.totalNumOfLeafPairs) = bixelIndRightLeaf;
0115
0116
0117
0118
0119 coveredByLeftLeaf = bsxfun(@minus,leftLeafPos,edges_l) / updatedInfo.bixelWidth;
0120 coveredByRightLeaf = bsxfun(@minus,edges_r,rightLeafPos) / updatedInfo.bixelWidth;
0121
0122 tempMap = 1 - (coveredByLeftLeaf + abs(coveredByLeftLeaf)) / 2 ...
0123 - (coveredByRightLeaf + abs(coveredByRightLeaf)) / 2;
0124
0125
0126 tempMapIx = tempMap > 0;
0127
0128 currBixelIx = apertureInfo.beam(i).bixelIndMap(tempMapIx);
0129 w(currBixelIx) = w(currBixelIx) + tempMap(tempMapIx)*updatedInfo.beam(i).shape(j).weight;
0130
0131
0132 updatedInfo.beam(i).shape(j).shapeMap = (tempMap + abs(tempMap)) / 2;
0133
0134
0135 shapeInd = shapeInd +1;
0136 end
0137
0138 end
0139
0140 updatedInfo.bixelWeights = w;
0141 updatedInfo.bixelIndices = indVect;
0142
0143 end
0144