|
11 | 11 | \author Mustapha Sadki |
12 | 12 | \author Kris Thielemans |
13 | 13 | \author Robert Twyman |
| 14 | + \author Zekai Li |
14 | 15 | \author PARAPET project |
15 | 16 |
|
16 | 17 | */ |
@@ -114,22 +115,35 @@ ProjMatrixByBin::get_proj_matrix_elems_for_one_bin(ProjMatrixElemsForOneBin& pro |
114 | 115 | void |
115 | 116 | ProjMatrixByBin::apply_tof_kernel(ProjMatrixElemsForOneBin& probabilities) const |
116 | 117 | { |
117 | | - |
118 | 118 | LORInAxialAndNoArcCorrSinogramCoordinates<float> lor; |
119 | 119 | proj_data_info_sptr->get_LOR(lor, probabilities.get_bin()); |
120 | 120 | const LORAs2Points<float> lor2(lor); |
121 | 121 | const CartesianCoordinate3D<float> point1 = lor2.p1(); |
122 | 122 | const CartesianCoordinate3D<float> point2 = lor2.p2(); |
123 | 123 |
|
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 | + |
125 | 132 | const CartesianCoordinate3D<float> middle = (point1 + point2) * 0.5f; |
126 | 133 | const CartesianCoordinate3D<float> diff = point2 - middle; |
127 | 134 | const CartesianCoordinate3D<float> diff_unit_vector(diff / static_cast<float>(norm(diff))); |
128 | 135 |
|
129 | 136 | for (ProjMatrixElemsForOneBin::iterator element_ptr = probabilities.begin(); element_ptr != probabilities.end(); ++element_ptr) |
130 | 137 | { |
131 | 138 | 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); |
133 | 147 |
|
134 | 148 | const float low_dist |
135 | 149 | = ((proj_data_info_sptr->tof_bin_boundaries_mm[probabilities.get_bin().timing_pos_num()].low_lim - d2)); |
|
0 commit comments