Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring for origin shift #260

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
26 changes: 26 additions & 0 deletions src/buildblock/ProjDataInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -652,5 +652,31 @@ operator>=(const ProjDataInfo& proj_data_info) const
return (proj_data_info == *smaller_proj_data_info_sptr);
}

CartesianCoordinate3D<float>
ProjDataInfo::get_point_on_lor_in_gantry_coordinates
(const float s_in_mm, const float m_in_mm, const float a_in_mm,
const float cphi, const float sphi, const float tantheta) const
{
return CartesianCoordinate3D<float>(m_in_mm - a_in_mm*tantheta, // z
s_in_mm*sphi - a_in_mm*cphi, // y
s_in_mm*cphi + a_in_mm*sphi); // x
}

CartesianCoordinate3D<float>
ProjDataInfo::
get_vector_centre_of_first_ring_to_centre_of_gantry() const
{
float middle_of_first_ring_to_middle_of_last
= (scanner_ptr->get_num_rings() - 1) * scanner_ptr->get_ring_spacing();
return CartesianCoordinate3D<float>(middle_of_first_ring_to_middle_of_last / 2.F, 0, 0);
}

CartesianCoordinate3D<float>
ProjDataInfo::get_bed_position() const
{
return CartesianCoordinate3D<float>
(bed_position_horizontal, bed_position_vertical, 0);
}

END_NAMESPACE_STIR

1 change: 1 addition & 0 deletions src/buildblock/ProjDataInfoCylindricalNoArcCorr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ find_cartesian_coordinates_given_scanner_coordinates (CartesianCoordinate3D<floa
cyl_coords.p2().psi() = static_cast<float>((2.*_PI/num_detectors_per_ring)*(det2));
cyl_coords.p1().z() = Ring_A*get_scanner_ptr()->get_ring_spacing();
cyl_coords.p2().z() = Ring_B*get_scanner_ptr()->get_ring_spacing();
// ORIGINTODO: ^
ashgillman marked this conversation as resolved.
Show resolved Hide resolved
LORAs2Points<float> lor(cyl_coords);
coord_1 = lor.p1();
coord_2 = lor.p2();
Expand Down
1 change: 1 addition & 0 deletions src/buildblock/zoom.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ construct_new_image_from_zoom_parameters(const VoxelsOnCartesianGrid<float> &ima
new_image.get_physical_coordinates_for_indices(new_max_indices))/2;
// now make sure that these are shifted as required
new_image.set_origin(offsets_in_mm + middle - new_middle);
// ORIGINTODO: ^
// check
{
const BasicCoordinate<3,float> final_middle =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ find_relation_between_coordinate_systems(int& num_planes_per_scanner_ring,
*(proj_data_info_cyl_ptr->get_max_axial_pos_num(segment_num)
+ proj_data_info_cyl_ptr->get_min_axial_pos_num(segment_num))
+ num_planes_per_scanner_ring*delta)/2;
// ORIGINDOTO: ^
}
}

Expand Down
1 change: 1 addition & 0 deletions src/include/stir/DiscretisedDensity.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "stir/CartesianCoordinate3D.h"
#include "stir/Array.h"
#include "stir/ExamData.h"
#include "stir/ProjDataInfo.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be needed if it wasn't before (will need to be in cxx, but probably already there)

#include "stir/shared_ptr.h"
#include <string>

Expand Down
26 changes: 24 additions & 2 deletions src/include/stir/ProjDataInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "stir/VectorWithOffset.h"
#include "stir/Scanner.h"
#include "stir/CartesianCoordinate3D.h"
#include "stir/shared_ptr.h"
#include "stir/unique_ptr.h"
#include <string>
Expand Down Expand Up @@ -255,6 +256,16 @@ class ProjDataInfo
const Bin&) const = 0;
//@}

//! Get a point in gantry space along an LOR
/*!
The point is parameterised by s, a, m, cos(phi), sin(phi) and tan(theta).
Gantry space is defined w.r.t. the center of the gantry.
*/
virtual CartesianCoordinate3D<float>
get_point_on_lor_in_gantry_coordinates
(const float s_in_mm, const float m_in_mm, const float a_in_mm,
const float cphi, const float sphi, const float tantheta) const;

//! \name Functions that return info on the sampling in the different coordinates
//@{
//! Get sampling distance in the \c t coordinate
Expand Down Expand Up @@ -364,7 +375,15 @@ class ProjDataInfo

//! Get vertical bed position
float get_bed_position_vertical() const { return bed_position_vertical; }


//! Vector represention bed position in 3D
CartesianCoordinate3D<float> get_bed_position() const;

// Convert coordinates from a sinogram-based
inline CartesianCoordinate3D<float>
get_physical_coordinates_for_gantry_coordinates
(const CartesianCoordinate3D<float>& coords) const;

protected:
virtual bool blindly_equals(const root_type * const) const = 0;

Expand All @@ -378,7 +397,10 @@ class ProjDataInfo
VectorWithOffset<int> max_axial_pos_per_seg;
float bed_position_horizontal;
float bed_position_vertical;


//! Vector from image frame of reference (centre of first ring) to gantry centre
CartesianCoordinate3D<float>
get_vector_centre_of_first_ring_to_centre_of_gantry() const;
};

END_NAMESPACE_STIR
Expand Down
9 changes: 9 additions & 0 deletions src/include/stir/ProjDataInfo.inl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ ProjDataInfo::get_scanner_sptr() const
return scanner_ptr;
}

CartesianCoordinate3D<float>
ProjDataInfo::
get_physical_coordinates_for_gantry_coordinates
(const CartesianCoordinate3D<float>& coords) const
{
// TODO: bed postion
return coords + get_vector_centre_of_first_ring_to_centre_of_gantry();
}


END_NAMESPACE_STIR

Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public :
CartesianCoordinate3D<int> min_index;
CartesianCoordinate3D<int> max_index;

shared_ptr<ProjDataInfo> proj_data_info_ptr;
shared_ptr<ProjDataInfo> proj_data_info_sptr;
shared_ptr< DiscretisedDensity<3,float> > density_info_sptr;


virtual void
Expand Down
2 changes: 1 addition & 1 deletion src/include/stir/zoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ zoom_image(const VoxelsOnCartesianGrid<float> &image,

The index range of the new image is according to the standard STIR
conventions (z starts from 0, but x and y from -(new_size/2)).
The origin is then chosen such that the geometric centres of the
The origin is then chosen such that the geometric centres of the // ORIGINTODO
images satisfy
\verbatim
offsets_in_mm == new_middle - old_middle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ find_relation_between_coordinate_systems(int& num_planes_per_scanner_ring,
*(proj_data_info_cyl_ptr->get_max_axial_pos_num(segment_num)
+ proj_data_info_cyl_ptr->get_min_axial_pos_num(segment_num))
+ num_planes_per_scanner_ring*delta)/2;
// ORIGINTODO: ^
}
}

Expand Down
1 change: 1 addition & 0 deletions src/recon_buildblock/ProjMatrixByBinUsingInterpolation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ set_up(
origin = image_info_ptr->get_origin();
const float z_to_middle =
(densel_range.get_max_index() + densel_range.get_min_index())*voxel_size.z()/2.F;
// ORIGINTODO: ^
origin.z() -= z_to_middle;

symmetries_sptr.reset(
Expand Down
Loading