Skip to content

Commit f860f34

Browse files
authored
Merge pull request #1645 from z-k-li/TOF-bin-fix-for-RayTracingMatrix
fix bug for oblique LORs when using TOF with the RayTracingMatrix (or any matrix). This bug was due to different coordinate systems used for images and projection data. Fixes #1537
1 parent ec3a567 commit f860f34

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/include/stir/recon_buildblock/ProjMatrixByBin.inl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
\author Mustapha Sadki
1212
\author Kris Thielemans
1313
\author Robert Twyman
14+
\author Zekai Li
1415
\author PARAPET project
1516
1617
*/
@@ -114,22 +115,35 @@ ProjMatrixByBin::get_proj_matrix_elems_for_one_bin(ProjMatrixElemsForOneBin& pro
114115
void
115116
ProjMatrixByBin::apply_tof_kernel(ProjMatrixElemsForOneBin& probabilities) const
116117
{
117-
118118
LORInAxialAndNoArcCorrSinogramCoordinates<float> lor;
119119
proj_data_info_sptr->get_LOR(lor, probabilities.get_bin());
120120
const LORAs2Points<float> lor2(lor);
121121
const CartesianCoordinate3D<float> point1 = lor2.p1();
122122
const CartesianCoordinate3D<float> point2 = lor2.p2();
123123

124-
// The direction can be from 1 -> 2 depending on the bin sign.
124+
// Coordinate system correction: TODO remove in future with ORIGIN shift PR
125+
// LOR coordinates have origin at scanner center (z=0 at center of all rings)
126+
// Image coordinates have origin at first ring (z=0 at ring 0)
127+
// Calculate the offset: distance from first ring to scanner center
128+
const float scanner_z_offset = (proj_data_info_sptr->get_scanner_ptr()->get_num_rings() - 1) / 2.0f
129+
* proj_data_info_sptr->get_scanner_ptr()->get_ring_spacing();
130+
const CartesianCoordinate3D<float> coord_system_offset(scanner_z_offset, 0.0f, 0.0f);
131+
125132
const CartesianCoordinate3D<float> middle = (point1 + point2) * 0.5f;
126133
const CartesianCoordinate3D<float> diff = point2 - middle;
127134
const CartesianCoordinate3D<float> diff_unit_vector(diff / static_cast<float>(norm(diff)));
128135

129136
for (ProjMatrixElemsForOneBin::iterator element_ptr = probabilities.begin(); element_ptr != probabilities.end(); ++element_ptr)
130137
{
131138
Coordinate3D<int> c(element_ptr->get_coords());
132-
const float d2 = -inner_product(image_info_sptr->get_physical_coordinates_for_indices(c) - middle, diff_unit_vector);
139+
// Get voxel physical coordinates (in image coordinate system)
140+
const CartesianCoordinate3D<float> voxel_pos_image = image_info_sptr->get_physical_coordinates_for_indices(c);
141+
142+
// Convert to scanner coordinate system by subtracting the offset
143+
const CartesianCoordinate3D<float> voxel_pos_scanner = voxel_pos_image - coord_system_offset;
144+
145+
// Now compute TOF distance in the same coordinate system as the LOR
146+
const float d2 = -inner_product(voxel_pos_scanner - middle, diff_unit_vector);
133147

134148
const float low_dist
135149
= ((proj_data_info_sptr->tof_bin_boundaries_mm[probabilities.get_bin().timing_pos_num()].low_lim - d2));

0 commit comments

Comments
 (0)