The goal is to determine how closely a bb in a phantom is aligned with the plan isocenter.
The first step is to determine the bb's location within the CBCT volume. A 3D volume is constructed, and a VOI (volume of interest is searched for the bb. The reasons for limiting the search volume are:
All possible sub-volumes of the VOI are searched of size 4*4*2 (X*Y*Z) voxels. The sub-volume with the largest sum of voxel values is assumed to be a coarse location for the bb.
Next, a sub-volume is taken that is slightly larger than the actual size of the bb (the size of the bb is a configuration value) centered on the coarse location. The sub-volume is summed across the 3 different axis to create 3 one-dimensional arrays. The profile of each array is analyzed with a center of mass algorithm to determine the exact center of the bb in each dimension. As a further check, the magnitude of the 'bump' in each profile created by the bb is checked to ensure that it is above a given number (configured value) of standard deviations to reject random image noise.
The coordinates in mm are then translated to the RTPLAN frame of reference. To do this, a DICOM REG file is found (note the DICOM uses a UID, aka unique id, to identify frames of reference) that references both the CBCT's frame of reference and the RTPLAN's frame of reference as shown in the diagram below.
Standard linear algebra is used to multiply the vector by the $4\times4$ matrix contained in the DICOM REG file as FrameOfReferenceTransformationMatrix . The resulting vector is the bb's $X,Y,Z$ location in the RTPLAN's frame of reference. The RTPLAN IsocenterPosition is subtracted from the result to get the error between CBCT and isocenter: $$X_{error} = X_{CBCT} - X_{PLAN}$$ $$Y_{error} = Y_{CBCT} - Y_{PLAN}$$ $$Z_{error} = Z_{CBCT} - Z_{PLAN}$$
There is a special case where the CBCT has the same frame of reference as the RTPLAN, and no matrix transformation is necessary. While the analysis will be performed, the results may or may not be useful. In practice this should not occur, but the software does support it.
PixelSpacing
: 0.51119 \ 0.51119
SliceThickness
: 1.98972453680719
coarse location in voxels: 276, 239, 49 (calculated from volume)
fine location in voxels: 275.863, 238.8094845, 48.478 (calculated from volume)
ImagePositionPatient
of first slice: -130.2839, -130.70374936618, -91.855446207549
FrameOfReferenceTransformationMatrix
:
$$
\left[
\begin{array}{cccc}
0.999994& -0.000017& 0.003545& -6.006019\\
0.000021& 0.999999& -0.001028& 171.213262\\
-0.003545& 0.001028& 0.999993& 59.937419\\
1.0& 0.000000& 0.000000& 1.000000
\end{array}
\right]
$$
IsocenterPosition
: 4.221317, 162.6656, 64.92423