matRad calculation of lateral distances from central ray used for dose calcultion call [ix,rad_distancesSq,isoLatDistsX,isoLatDistsZ] = ... matRad_calcGeoDists(rot_coords_bev, ... sourcePoint_bev, ... targetPoint_bev, ... SAD, ... radDepthIx, ... lateralCutOff) input rot_coords_bev: coordinates in bev of the voxels with index V, where also ray tracing results are availabe sourcePoint_bev: source point in voxel coordinates in beam's eye view targetPoint_bev: target point in voxel coordinated in beam's eye view SAD: source-to-axis distance radDepthIx: sub set of voxels for which radiological depth calculations are available lateralCutOff: lateral cutoff specifying the neighbourhood for which dose calculations will actually be performed output ix: indices of voxels where we want to compute dose influence data rad_distancesSq: squared radial distance to the central ray (where the actual computation of the radiological depth takes place) isoLatDistsX: lateral x-distance to the central ray projected to iso center plane isoLatDistsZ: lateral z-distance to the central ray projected to iso center plane References - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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 [ix,rad_distancesSq,isoLatDistsX,isoLatDistsZ] = ... 0002 matRad_calcGeoDists(rot_coords_bev, ... 0003 sourcePoint_bev, ... 0004 targetPoint_bev, ... 0005 SAD, ... 0006 radDepthIx, ... 0007 lateralCutOff) 0008 % matRad calculation of lateral distances from central ray 0009 % used for dose calcultion 0010 % 0011 % call 0012 % [ix,rad_distancesSq,isoLatDistsX,isoLatDistsZ] = ... 0013 % matRad_calcGeoDists(rot_coords_bev, ... 0014 % sourcePoint_bev, ... 0015 % targetPoint_bev, ... 0016 % SAD, ... 0017 % radDepthIx, ... 0018 % lateralCutOff) 0019 % 0020 % input 0021 % rot_coords_bev: coordinates in bev of the voxels with index V, 0022 % where also ray tracing results are availabe 0023 % sourcePoint_bev: source point in voxel coordinates in beam's eye view 0024 % targetPoint_bev: target point in voxel coordinated in beam's eye view 0025 % SAD: source-to-axis distance 0026 % radDepthIx: sub set of voxels for which radiological depth 0027 % calculations are available 0028 % lateralCutOff: lateral cutoff specifying the neighbourhood for 0029 % which dose calculations will actually be performed 0030 % 0031 % output 0032 % ix: indices of voxels where we want to compute dose 0033 % influence data 0034 % rad_distancesSq: squared radial distance to the central ray (where the 0035 % actual computation of the radiological depth takes place) 0036 % isoLatDistsX: lateral x-distance to the central ray projected to 0037 % iso center plane 0038 % isoLatDistsZ: lateral z-distance to the central ray projected to 0039 % iso center plane 0040 % 0041 % References 0042 % - 0043 % 0044 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0045 % 0046 % Copyright 2015 the matRad development team. 0047 % 0048 % This file is part of the matRad project. It is subject to the license 0049 % terms in the LICENSE file found in the top-level directory of this 0050 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part 0051 % of the matRad project, including this file, may be copied, modified, 0052 % propagated, or distributed except according to the terms contained in the 0053 % LICENSE file. 0054 % 0055 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0056 0057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0058 % ROTATE A SINGLE BEAMLET AND ALIGN WITH BEAMLET WHO PASSES THROUGH 0059 % ISOCENTER 0060 0061 % Put [0 0 0] position in the source point for beamlet who passes through 0062 % isocenter 0063 a = -sourcePoint_bev'; 0064 0065 % Normalize the vector 0066 a = a/norm(a); 0067 0068 % Put [0 0 0] position in the source point for a single beamlet 0069 b = (targetPoint_bev - sourcePoint_bev)'; 0070 0071 % Normalize the vector 0072 b = b/norm(b); 0073 0074 % Define function for obtain rotation matrix. 0075 if all(a==b) % rotation matrix corresponds to eye matrix if the vectors are the same 0076 rot_coords_temp = rot_coords_bev; 0077 else 0078 % Define rotation matrix 0079 ssc = @(v) [0 -v(3) v(2); v(3) 0 -v(1); -v(2) v(1) 0]; 0080 R = eye(3) + ssc(cross(a,b)) + ssc(cross(a,b))^2*(1-dot(a,b))/(norm(cross(a,b))^2); 0081 0082 % Rotate every CT voxel 0083 rot_coords_temp = rot_coords_bev*R; 0084 end 0085 0086 % Put [0 0 0] position CT in center of the beamlet. 0087 latDistsX = rot_coords_temp(:,1) + sourcePoint_bev(1); 0088 latDistsZ = rot_coords_temp(:,3) + sourcePoint_bev(3); 0089 0090 % check of radial distance exceeds lateral cutoff (projected to iso center) 0091 rad_distancesSq = latDistsX.^2 + latDistsZ.^2; 0092 subsetMask = rad_distancesSq ./ rot_coords_temp(:,2).^2 <= lateralCutOff^2 /SAD^2; 0093 0094 % return index list within considered voxels 0095 ix = radDepthIx(subsetMask); 0096 0097 % return radial distances squared 0098 if nargout > 1 0099 rad_distancesSq = rad_distancesSq(subsetMask); 0100 end 0101 0102 % return x & z distance 0103 if nargout > 2 0104 isoLatDistsX = latDistsX(subsetMask)./rot_coords_temp(subsetMask,2)*SAD; 0105 isoLatDistsZ = latDistsZ(subsetMask)./rot_coords_temp(subsetMask,2)*SAD; 0106 end 0107 0108