forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
matRad_calcDoseInitBeam.m
55 lines (41 loc) · 2.33 KB
/
matRad_calcDoseInitBeam.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
matRad_cfg.dispInfo('Beam %d of %d:\n',i,dij.numOfBeams);
% remember beam and bixel number
if calcDoseDirect
dij.beamNum(i) = i;
dij.rayNum(i) = i;
dij.bixelNum(i) = i;
end
bixelsPerBeam = 0;
% convert voxel indices to real coordinates using iso center of beam i
xCoordsV = xCoordsV_vox(:)*ct.resolution.x-stf(i).isoCenter(1);
yCoordsV = yCoordsV_vox(:)*ct.resolution.y-stf(i).isoCenter(2);
zCoordsV = zCoordsV_vox(:)*ct.resolution.z-stf(i).isoCenter(3);
coordsV = [xCoordsV yCoordsV zCoordsV];
xCoordsVdoseGrid = xCoordsV_voxDoseGrid(:)*dij.doseGrid.resolution.x-stf(i).isoCenter(1);
yCoordsVdoseGrid = yCoordsV_voxDoseGrid(:)*dij.doseGrid.resolution.y-stf(i).isoCenter(2);
zCoordsVdoseGrid = zCoordsV_voxDoseGrid(:)*dij.doseGrid.resolution.z-stf(i).isoCenter(3);
coordsVdoseGrid = [xCoordsVdoseGrid yCoordsVdoseGrid zCoordsVdoseGrid];
% Get Rotation Matrix
% Do not transpose matrix since we usage of row vectors &
% transformation of the coordinate system need double transpose
rotMat_system_T = matRad_getRotationMatrix(stf(i).gantryAngle,stf(i).couchAngle);
% Rotate coordinates (1st couch around Y axis, 2nd gantry movement)
rot_coordsV = coordsV*rotMat_system_T;
rot_coordsVdoseGrid = coordsVdoseGrid*rotMat_system_T;
rot_coordsV(:,1) = rot_coordsV(:,1)-stf(i).sourcePoint_bev(1);
rot_coordsV(:,2) = rot_coordsV(:,2)-stf(i).sourcePoint_bev(2);
rot_coordsV(:,3) = rot_coordsV(:,3)-stf(i).sourcePoint_bev(3);
rot_coordsVdoseGrid(:,1) = rot_coordsVdoseGrid(:,1)-stf(i).sourcePoint_bev(1);
rot_coordsVdoseGrid(:,2) = rot_coordsVdoseGrid(:,2)-stf(i).sourcePoint_bev(2);
rot_coordsVdoseGrid(:,3) = rot_coordsVdoseGrid(:,3)-stf(i).sourcePoint_bev(3);
% calculate geometric distances
geoDistVdoseGrid{1}= sqrt(sum(rot_coordsVdoseGrid.^2,2));
% Calculate radiological depth cube
matRad_cfg.dispInfo('matRad: calculate radiological depth cube... ');
radDepthVctGrid = matRad_rayTracing(stf(i),ct,VctGrid,rot_coordsV,effectiveLateralCutoff);
matRad_cfg.dispInfo('done.\n');
% interpolate radiological depth cube to dose grid resolution
radDepthVdoseGrid = matRad_interpRadDepth...
(ct,1,VctGrid,VdoseGrid,dij.doseGrid.x,dij.doseGrid.y,dij.doseGrid.z,radDepthVctGrid);
% limit rotated coordinates to positions where ray tracing is availabe
rot_coordsVdoseGrid = rot_coordsVdoseGrid(~isnan(radDepthVdoseGrid{1}),:);