diff --git a/src/buildblock/ProjData.cxx b/src/buildblock/ProjData.cxx index 0a8067fe8..9ee604d75 100644 --- a/src/buildblock/ProjData.cxx +++ b/src/buildblock/ProjData.cxx @@ -58,7 +58,7 @@ #include "stir/IO/GEHDF5Wrapper.h" #endif #include "stir/IO/stir_ecat7.h" -#include "stir/ViewSegmentNumbers.h" +#include "stir/ViewgramIndices.h" #include "stir/is_null_ptr.h" #include #include @@ -261,7 +261,19 @@ ProjData::get_subset(const std::vector& views) const } -Viewgram +Viewgram +ProjData::get_empty_viewgram(const ViewgramIndices& ind) const +{ + return proj_data_info_sptr->get_empty_viewgram(ind); +} + +Sinogram +ProjData::get_empty_sinogram(const SinogramIndices& ind) const +{ + return proj_data_info_sptr->get_empty_sinogram(ind); +} + +Viewgram ProjData::get_empty_viewgram(const int view_num, const int segment_num, const bool make_num_tangential_poss_odd) const { @@ -297,7 +309,7 @@ ProjData::get_empty_segment_by_view(const int segment_num, } RelatedViewgrams -ProjData::get_empty_related_viewgrams(const ViewSegmentNumbers& view_segmnet_num, +ProjData::get_empty_related_viewgrams(const ViewgramIndices& view_segmnet_num, //const int view_num, const int segment_num, const shared_ptr& symmetries_used, const bool make_num_tangential_poss_odd) const @@ -308,15 +320,14 @@ ProjData::get_empty_related_viewgrams(const ViewSegmentNumbers& view_segmnet_num RelatedViewgrams -ProjData::get_related_viewgrams(const ViewSegmentNumbers& view_segmnet_num, - //const int view_num, const int segment_num, +ProjData::get_related_viewgrams(const ViewgramIndices& viewgram_indices, const shared_ptr& symmetries_used, const bool make_num_bins_odd) const { vector pairs; symmetries_used->get_related_view_segment_numbers( pairs, - ViewSegmentNumbers(view_segmnet_num.view_num(),view_segmnet_num.segment_num()) + viewgram_indices ); vector > viewgrams; diff --git a/src/buildblock/ProjDataInfo.cxx b/src/buildblock/ProjDataInfo.cxx index 4b5bfc87c..0a0823dc8 100644 --- a/src/buildblock/ProjDataInfo.cxx +++ b/src/buildblock/ProjDataInfo.cxx @@ -4,7 +4,7 @@ Copyright (C) 2000 PARAPET partners Copyright (C) 2000 - 2009-05-13, Hammersmith Imanet Ltd Copyright (C) 2011-07-01 - 2011, Kris Thielemans - Copyright (C) 2018, 2022, University College London + Copyright (C) 2018, 2022, 2023, University College London Copyright (C) 2018, University of Leeds This file is part of STIR. @@ -262,6 +262,15 @@ ProjDataInfo::get_empty_viewgram(const int view_num, return v; } +Viewgram +ProjDataInfo::get_empty_viewgram(const ViewgramIndices& ind) const +{ + // we can't access the shared ptr, so we have to clone 'this'. + shared_ptr proj_data_info_sptr(this->clone()); + Viewgram v(proj_data_info_sptr, ind); + return v; +} + Sinogram ProjDataInfo::get_empty_sinogram(const int axial_pos_num, const int segment_num, @@ -278,6 +287,15 @@ ProjDataInfo::get_empty_sinogram(const int axial_pos_num, const int segment_num, return s; } +Sinogram +ProjDataInfo::get_empty_sinogram(const SinogramIndices& ind) const +{ + // we can't access the shared ptr, so we have to clone 'this'. + shared_ptr proj_data_info_sptr(this->clone()); + Sinogram s(proj_data_info_sptr, ind); + return s; +} + SegmentBySinogram ProjDataInfo::get_empty_segment_by_sinogram(const int segment_num, const bool make_num_tangential_poss_odd) const @@ -296,6 +314,14 @@ ProjDataInfo::get_empty_segment_by_sinogram(const int segment_num, return s; } +SegmentBySinogram +ProjDataInfo::get_empty_segment_by_sinogram(const SegmentIndices& ind) const +{ + // we can't access the shared ptr, so we have to clone 'this'. + shared_ptr proj_data_info_sptr(this->clone()); + SegmentBySinogram s(proj_data_info_sptr, ind); + return s; +} SegmentByView ProjDataInfo::get_empty_segment_by_view(const int segment_num, @@ -315,17 +341,24 @@ ProjDataInfo::get_empty_segment_by_view(const int segment_num, return s; } +SegmentByView +ProjDataInfo::get_empty_segment_by_view(const SegmentIndices& ind) const +{ + // we can't access the shared ptr, so we have to clone 'this'. + shared_ptr proj_data_info_sptr(this->clone()); + SegmentByView s(proj_data_info_sptr, ind); + return s; +} + RelatedViewgrams -ProjDataInfo::get_empty_related_viewgrams(const ViewSegmentNumbers& view_segmnet_num, - //const int view_num, const int segment_num, +ProjDataInfo::get_empty_related_viewgrams(const ViewgramIndices& viewgram_indices, const shared_ptr& symmetries_used, const bool make_num_tangential_poss_odd) const { + if (make_num_tangential_poss_odd) + error("make_num_tangential_poss_odd is no longer supported"); vector pairs; - symmetries_used->get_related_view_segment_numbers( - pairs, - ViewSegmentNumbers(view_segmnet_num.view_num(),view_segmnet_num.segment_num()) - ); + symmetries_used->get_related_view_segment_numbers(pairs, viewgram_indices); vector > viewgrams; viewgrams.reserve(pairs.size()); @@ -333,8 +366,7 @@ ProjDataInfo::get_empty_related_viewgrams(const ViewSegmentNumbers& view_segmnet for (unsigned int i=0; i(viewgrams, symmetries_used); diff --git a/src/buildblock/SegmentBySinogram.cxx b/src/buildblock/SegmentBySinogram.cxx index 88a53d460..336790a97 100644 --- a/src/buildblock/SegmentBySinogram.cxx +++ b/src/buildblock/SegmentBySinogram.cxx @@ -35,15 +35,15 @@ template SegmentBySinogram :: SegmentBySinogram(const Array<3,elemT>& v, const shared_ptr& pdi_ptr, - const int segment_num) + const SegmentIndices& ind) : - Segment(pdi_ptr, segment_num), + Segment(pdi_ptr, ind), Array<3,elemT>(v) { assert( get_min_view_num() == pdi_ptr->get_min_view_num()); assert( get_max_view_num() == pdi_ptr->get_max_view_num()); - assert( get_min_axial_pos_num() == pdi_ptr->get_min_axial_pos_num(segment_num)); - assert( get_max_axial_pos_num() == pdi_ptr->get_max_axial_pos_num(segment_num)); + assert( get_min_axial_pos_num() == pdi_ptr->get_min_axial_pos_num(ind.segment_num())); + assert( get_max_axial_pos_num() == pdi_ptr->get_max_axial_pos_num(ind.segment_num())); assert( get_min_tangential_pos_num() == pdi_ptr->get_min_tangential_pos_num()); assert( get_max_tangential_pos_num() == pdi_ptr->get_max_tangential_pos_num()); } @@ -51,22 +51,39 @@ SegmentBySinogram(const Array<3,elemT>& v, template SegmentBySinogram :: SegmentBySinogram(const shared_ptr& pdi_ptr, - const int segment_num) + const SegmentIndices& ind) : - Segment(pdi_ptr, segment_num), - Array<3,elemT>(IndexRange3D(pdi_ptr->get_min_axial_pos_num(segment_num), - pdi_ptr->get_max_axial_pos_num(segment_num), + Segment(pdi_ptr, ind), + Array<3,elemT>(IndexRange3D(pdi_ptr->get_min_axial_pos_num(ind.segment_num()), + pdi_ptr->get_max_axial_pos_num(ind.segment_num()), pdi_ptr->get_min_view_num(), pdi_ptr->get_max_view_num(), pdi_ptr->get_min_tangential_pos_num(), pdi_ptr->get_max_tangential_pos_num())) {} +template +SegmentBySinogram:: +SegmentBySinogram(const Array<3,elemT>& v, + const shared_ptr& pdi_sptr, + int segment_num) + : + SegmentBySinogram(v, pdi_sptr, SegmentIndices(segment_num)) +{} + +template +SegmentBySinogram:: +SegmentBySinogram(const shared_ptr& pdi_sptr, + const int segment_num) + : + SegmentBySinogram(pdi_sptr, SegmentIndices(segment_num)) +{} + template SegmentBySinogram:: SegmentBySinogram(const SegmentByView& s_v ) : Segment(s_v.get_proj_data_info_sptr()->create_shared_clone(), - s_v.get_segment_num()), + s_v.get_segment_indices()), Array<3,elemT> (IndexRange3D (s_v.get_min_axial_pos_num(), s_v.get_max_axial_pos_num(), s_v.get_min_view_num(), s_v.get_max_view_num(), s_v.get_min_tangential_pos_num(), s_v.get_max_tangential_pos_num())) diff --git a/src/buildblock/SegmentByView.cxx b/src/buildblock/SegmentByView.cxx index 554323988..f08fc61ae 100644 --- a/src/buildblock/SegmentByView.cxx +++ b/src/buildblock/SegmentByView.cxx @@ -33,15 +33,15 @@ template SegmentByView:: SegmentByView(const Array<3,elemT>& v, const shared_ptr& pdi_ptr, - const int segment_num) + const SegmentIndices& ind) : - Segment(pdi_ptr, segment_num), + Segment(pdi_ptr, ind), Array<3,elemT>(v) { assert( get_min_view_num() == pdi_ptr->get_min_view_num()); assert( get_max_view_num() == pdi_ptr->get_max_view_num()); - assert( get_min_axial_pos_num() == pdi_ptr->get_min_axial_pos_num(segment_num)); - assert( get_max_axial_pos_num() == pdi_ptr->get_max_axial_pos_num(segment_num)); + assert( get_min_axial_pos_num() == pdi_ptr->get_min_axial_pos_num(ind.segment_num())); + assert( get_max_axial_pos_num() == pdi_ptr->get_max_axial_pos_num(ind.segment_num())); assert( get_min_tangential_pos_num() == pdi_ptr->get_min_tangential_pos_num()); assert( get_max_tangential_pos_num() == pdi_ptr->get_max_tangential_pos_num()); @@ -50,22 +50,37 @@ SegmentByView(const Array<3,elemT>& v, template SegmentByView:: SegmentByView(const shared_ptr& pdi_ptr, - const int segment_num) + const SegmentIndices& ind) : - Segment(pdi_ptr, segment_num), + Segment(pdi_ptr, ind), Array<3,elemT>(IndexRange3D(pdi_ptr->get_min_view_num(), pdi_ptr->get_max_view_num(), - pdi_ptr->get_min_axial_pos_num(segment_num), - pdi_ptr->get_max_axial_pos_num(segment_num), + pdi_ptr->get_min_axial_pos_num(ind.segment_num()), + pdi_ptr->get_max_axial_pos_num(ind.segment_num()), pdi_ptr->get_min_tangential_pos_num(), pdi_ptr->get_max_tangential_pos_num())) {} +template +SegmentByView:: +SegmentByView(const Array<3,elemT>& v, + const shared_ptr& pdi_sptr, + const int segment_num) + : + SegmentByView(v, pdi_sptr, SegmentIndices(segment_num)) +{} + +template +SegmentByView:: +SegmentByView(const shared_ptr& pdi_sptr, + const int segment_num) + : SegmentByView(pdi_sptr, SegmentIndices(segment_num)) +{} + template SegmentByView::SegmentByView(const SegmentBySinogram& s_s) : Segment(s_s.get_proj_data_info_sptr()->create_shared_clone(), - s_s.get_segment_num()), - + s_s.get_segment_indices()), Array<3,elemT> (IndexRange3D(s_s.get_min_view_num(),s_s.get_max_view_num(), s_s.get_min_axial_pos_num(),s_s.get_max_axial_pos_num(), s_s.get_min_tangential_pos_num(), s_s.get_max_tangential_pos_num())) diff --git a/src/include/stir/ProjData.h b/src/include/stir/ProjData.h index 722c045ac..baab84653 100644 --- a/src/include/stir/ProjData.h +++ b/src/include/stir/ProjData.h @@ -44,7 +44,6 @@ template class SegmentBySinogram; template class SegmentByView; template class Viewgram; template class Sinogram; -class ViewSegmentNumbers; class Succeeded; class ProjDataInMemory; //class ExamInfo; @@ -119,14 +118,21 @@ class ProjData : public ExamData inline shared_ptr get_proj_data_info_sptr() const; //! Get viewgram + /*! + \deprecated Use get_viewgram(const ViewgramIndices&) instead. + */ virtual Viewgram get_viewgram(const int view, const int segment_num,const bool make_num_tangential_poss_odd = false) const=0; + //! Get viewgram inline Viewgram get_viewgram(const ViewgramIndices&); //! Set viewgram virtual Succeeded set_viewgram(const Viewgram&) = 0; //! Get sinogram + /*! + \deprecated Use get_sinogram(const SinogramIndices&) instead . + */ virtual Sinogram get_sinogram(const int ax_pos_num, const int segment_num,const bool make_num_tangential_poss_odd = false) const=0; //! Get sinogram @@ -141,34 +147,66 @@ class ProjData : public ExamData get_subset(const std::vector& views) const; //! Get empty viewgram + Viewgram get_empty_viewgram(const ViewgramIndices&) const; + + //! Get empty viewgram + /*! + \deprecated Use get_viewgram(const ViewgramIndices&) instead. + */ Viewgram get_empty_viewgram(const int view, const int segment_num, const bool make_num_tangential_poss_odd = false) const; //! Get empty_sinogram + Sinogram + get_empty_sinogram(const SinogramIndices&) const; + + //! Get empty_sinogram + /*! + \deprecated Use get_sinogram(const SinogramIndices&) instead . + */ Sinogram get_empty_sinogram(const int ax_pos_num, const int segment_num, const bool make_num_tangential_poss_odd = false) const; - //! Get empty segment sino + //! Get empty segment by view + SegmentByView + get_empty_segment_by_view(const SegmentIndices&) const; + //! Get empty segment by sino + SegmentBySinogram + get_empty_segment_by_sinogram(const SegmentIndices&) const; + //! Get empty segment view + /*! + \deprecated Use get_empty_segment_by_sinogram(const SegmentIndices&) instead . + */ SegmentByView get_empty_segment_by_view(const int segment_num, const bool make_num_tangential_poss_odd = false) const; - //! Get empty segment view + //! Get empty segment sino + /*! + \deprecated Use get_empty_segment_by_sinogram(const SegmentIndices&) instead . + */ SegmentBySinogram get_empty_segment_by_sinogram(const int segment_num, const bool make_num_tangential_poss_odd = false) const; - //! Get segment by sinogram + /*! + \deprecated Use get_segment_by_sinogram(const SegmentIndices&) instead. + */ virtual SegmentBySinogram get_segment_by_sinogram(const int segment_num) const; + //! Get segment by sinogram inline SegmentBySinogram get_segment_by_sinogram(const SegmentIndices&) const; //! Get segment by view + /*! + \deprecated Use get_segment_by_view(const SegmentIndices&) instead. + */ virtual SegmentByView get_segment_by_view(const int segment_num) const; + //! Get segment by view inline SegmentByView get_segment_by_view(const SegmentIndices&) const; @@ -181,7 +219,7 @@ class ProjData : public ExamData //! Get related viewgrams virtual RelatedViewgrams - get_related_viewgrams(const ViewSegmentNumbers&, + get_related_viewgrams(const ViewgramIndices&, const shared_ptr&, const bool make_num_tangential_poss_odd = false) const; //! Set related viewgrams @@ -190,7 +228,7 @@ class ProjData : public ExamData //! Get empty related viewgrams, where the symmetries_ptr specifies the symmetries to use RelatedViewgrams - get_empty_related_viewgrams(const ViewSegmentNumbers& view_segmnet_num, + get_empty_related_viewgrams(const ViewgramIndices& view_segmnet_num, //const int view_num, const int segment_num, const shared_ptr& symmetries_ptr, const bool make_num_tangential_poss_odd = false) const; diff --git a/src/include/stir/ProjDataInfo.h b/src/include/stir/ProjDataInfo.h index 64d96cc67..d0be14fb3 100644 --- a/src/include/stir/ProjDataInfo.h +++ b/src/include/stir/ProjDataInfo.h @@ -4,7 +4,7 @@ Copyright (C) 2000 PARAPET partners Copyright (C) 2000 - 2011-10-14, Hammersmith Imanet Ltd Copyright (C) 2011-07-01 - 2011, Kris Thielemans - Copyright (C) 2017-2018, 2020, 2022, University College London + Copyright (C) 2017-2018, 2020, 2022, 2023 University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -24,6 +24,9 @@ #ifndef __stir_ProjDataInfo_H__ #define __stir_ProjDataInfo_H__ +#include "stir/SegmentIndices.h" +#include "stir/ViewgramIndices.h" +#include "stir/SinogramIndices.h" #include "stir/VectorWithOffset.h" #include "stir/Scanner.h" #include "stir/shared_ptr.h" @@ -347,23 +350,37 @@ class ProjDataInfo //@{ //! Get empty viewgram + Viewgram get_empty_viewgram(const ViewgramIndices&) const; + //! Get empty_sinogram + Sinogram get_empty_sinogram(const SinogramIndices&) const; + //! Get empty segment sino + SegmentByView get_empty_segment_by_view(const SegmentIndices&) const; + //! Get empty segment view + SegmentBySinogram get_empty_segment_by_sinogram(const SegmentIndices&) const; + + //! Get empty viewgram + /*! \deprecated */ Viewgram get_empty_viewgram(const int view_num, const int segment_num, const bool make_num_tangential_poss_odd = false) const; //! Get empty_sinogram + /*! \deprecated */ Sinogram get_empty_sinogram(const int ax_pos_num, const int segment_num, const bool make_num_tangential_poss_odd = false) const; //! Get empty segment sino + /*! \deprecated */ SegmentByView get_empty_segment_by_view(const int segment_num, const bool make_num_tangential_poss_odd = false) const; //! Get empty segment view + /*! \deprecated */ SegmentBySinogram get_empty_segment_by_sinogram(const int segment_num, const bool make_num_tangential_poss_odd = false) const; //! Get empty related viewgrams, where the symmetries_ptr specifies the symmetries to use - RelatedViewgrams get_empty_related_viewgrams(const ViewSegmentNumbers&, + /*! make_num_tangential_poss_odd has to be \c false */ + RelatedViewgrams get_empty_related_viewgrams(const ViewgramIndices&, const shared_ptr&, const bool make_num_tangential_poss_odd = false) const; //@} diff --git a/src/include/stir/RelatedViewgrams.h b/src/include/stir/RelatedViewgrams.h index 52742b642..7ad3847bf 100644 --- a/src/include/stir/RelatedViewgrams.h +++ b/src/include/stir/RelatedViewgrams.h @@ -85,8 +85,11 @@ class RelatedViewgrams /*! see DataSymmetriesForViewSegmentNumbers for definition of 'basic' */ inline int get_basic_segment_num() const; //! get 'basic' view_segment_num + /*! \deprecated Use get_basic_viewgram_indices() instead. */ + inline ViewgramIndices get_basic_view_segment_num() const; + //! get 'basic' viewgram indices /*! see DataSymmetriesForViewSegmentNumbers for definition of 'basic' */ - inline ViewSegmentNumbers get_basic_view_segment_num() const; + inline ViewgramIndices get_basic_viewgram_indices() const; //! returns the number of viewgrams in this object inline int get_num_viewgrams() const; diff --git a/src/include/stir/RelatedViewgrams.inl b/src/include/stir/RelatedViewgrams.inl index 084cc68da..6eee8108f 100644 --- a/src/include/stir/RelatedViewgrams.inl +++ b/src/include/stir/RelatedViewgrams.inl @@ -71,10 +71,21 @@ int RelatedViewgrams::get_basic_segment_num() const } template -ViewSegmentNumbers RelatedViewgrams:: +ViewgramIndices +RelatedViewgrams:: +get_basic_viewgram_indices() const +{ + assert(viewgrams.size()>0); + check_state(); + return viewgrams[0].get_viewgram_indices(); +} + +template +ViewgramIndices +RelatedViewgrams:: get_basic_view_segment_num() const { - return ViewSegmentNumbers(get_basic_view_num(), get_basic_segment_num()); + return this->get_basic_viewgram_indices(); } template diff --git a/src/include/stir/Segment.h b/src/include/stir/Segment.h index 5583ff400..7b700e752 100644 --- a/src/include/stir/Segment.h +++ b/src/include/stir/Segment.h @@ -1,6 +1,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000-2012 Hammersmith Imanet Ltd + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -21,6 +22,7 @@ #include "stir/ProjDataInfo.h" +#include "stir/SegmentIndices.h" #include "stir/shared_ptr.h" START_NAMESPACE_STIR @@ -33,7 +35,7 @@ template class Viewgram; \ingroup projdata This stores a subset of the data accessible via a ProjData object, - where the segment_num is fixed. + where the SegmentIndices are fixed. At the moment, 2 'storage modes' are supported (and implemented as derived classes). @@ -60,6 +62,7 @@ class Segment get_proj_data_info_sptr() const; virtual StorageOrder get_storage_order() const = 0; + inline SegmentIndices get_segment_indices() const; //! Get the segment number inline int get_segment_num() const; virtual int get_min_axial_pos_num() const = 0; @@ -114,9 +117,9 @@ class Segment protected: shared_ptr proj_data_info_sptr; - int segment_num; + SegmentIndices _indices; - inline Segment(const shared_ptr& proj_data_info_sptr_v,const int s_num); + inline Segment(const shared_ptr& proj_data_info_sptr_v,const SegmentIndices&); }; END_NAMESPACE_STIR diff --git a/src/include/stir/Segment.inl b/src/include/stir/Segment.inl index 7e32fe1b6..80d31d210 100644 --- a/src/include/stir/Segment.inl +++ b/src/include/stir/Segment.inl @@ -3,6 +3,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000- 2007, IRSL + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -25,16 +26,21 @@ START_NAMESPACE_STIR template Segment:: -Segment( const shared_ptr& proj_data_info_sptr_v,const int s_num) +Segment( const shared_ptr& proj_data_info_sptr_v,const SegmentIndices& ind) : proj_data_info_sptr(proj_data_info_sptr_v), - segment_num(s_num) + _indices(ind) {} +template +SegmentIndices +Segment:: get_segment_indices() const +{ return _indices; } + template int Segment:: get_segment_num() const -{ return segment_num; } +{ return _indices.segment_num(); } template shared_ptr diff --git a/src/include/stir/SegmentBySinogram.h b/src/include/stir/SegmentBySinogram.h index 25c420b5f..a4c8399a6 100644 --- a/src/include/stir/SegmentBySinogram.h +++ b/src/include/stir/SegmentBySinogram.h @@ -3,6 +3,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000- 2012, Hammersmith Imanet Ltd + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -38,7 +39,7 @@ template class SegmentByView; /*! \ingroup projdata - \brief A class for storing (3d) projection data with a fixed segment_num. + \brief A class for storing (3d) projection data with fixed SegmentIndices. Storage order is as follows: \code @@ -56,11 +57,26 @@ class SegmentBySinogram : public Segment, public Array<3,elemT> typedef typename Segment::StorageOrder StorageOrder; //! Constructor that sets the data to a given 3d Array + SegmentBySinogram(const Array<3,elemT>& v, + const shared_ptr& proj_data_info_ptr_v, + const SegmentIndices& ind); + + //! Constructor that sets sizes via the ProjDataInfo object, initialising data to 0 + SegmentBySinogram(const shared_ptr& proj_data_info_ptr_v, + const SegmentIndices& ind); + + //! Constructor that sets the data to a given 3d Array + /*! + \deprecated Use version with SegmentIndices instead + */ SegmentBySinogram(const Array<3,elemT>& v, const shared_ptr& proj_data_info_ptr_v, const int segment_num); //! Constructor that sets sizes via the ProjDataInfo object, initialising data to 0 + /*! + \deprecated Use version with SegmentIndices instead + */ SegmentBySinogram(const shared_ptr& proj_data_info_ptr_v, const int segment_num); diff --git a/src/include/stir/SegmentBySinogram.inl b/src/include/stir/SegmentBySinogram.inl index 2500a7e1e..eb25fc66a 100644 --- a/src/include/stir/SegmentBySinogram.inl +++ b/src/include/stir/SegmentBySinogram.inl @@ -3,6 +3,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000- 2007, Hammersmith Imanet Ltd + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license diff --git a/src/include/stir/SegmentByView.h b/src/include/stir/SegmentByView.h index e0e858d82..231a17246 100644 --- a/src/include/stir/SegmentByView.h +++ b/src/include/stir/SegmentByView.h @@ -3,6 +3,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000- 2007, Hammersmith Imanet Ltd + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -37,7 +38,7 @@ template class Sinogram; /*! \ingroup projdata - \brief A class for storing (3d) projection data with a fixed segment_num. + \brief A class for storing (3d) projection data with fixed SegmentIndices. Storage order is as follows: \code @@ -55,14 +56,28 @@ template class SegmentByView : public Segment, public Ar typedef typename Segment::StorageOrder StorageOrder; //! Constructor that sets the data to a given 3d Array + SegmentByView(const Array<3,elemT>& v, + const shared_ptr& proj_data_info_sptr, + const SegmentIndices&); + + //! Constructor that sets sizes via the ProjDataInfo object, initialising data to 0 + SegmentByView(const shared_ptr& proj_data_info_sptr, + const SegmentIndices&); + + //! Constructor that sets the data to a given 3d Array + /*! + \deprecated Use version with SegmentIndices instead + */ SegmentByView(const Array<3,elemT>& v, const shared_ptr& proj_data_info_ptr, const int segment_num); //! Constructor that sets sizes via the ProjDataInfo object, initialising data to 0 + /*! + \deprecated Use version with SegmentIndices instead + */ SegmentByView(const shared_ptr& proj_data_info_ptr, const int segment_num); - //! Conversion from 1 storage order to the other SegmentByView(const SegmentBySinogram& ); diff --git a/src/include/stir/SegmentByView.inl b/src/include/stir/SegmentByView.inl index 2ec586ffc..d222e6a63 100644 --- a/src/include/stir/SegmentByView.inl +++ b/src/include/stir/SegmentByView.inl @@ -16,6 +16,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000- 2011, Hammersmtih Imanet Ltd + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license diff --git a/src/include/stir/Sinogram.h b/src/include/stir/Sinogram.h index 1661c685c..f523dceb1 100644 --- a/src/include/stir/Sinogram.h +++ b/src/include/stir/Sinogram.h @@ -4,6 +4,7 @@ Copyright (C) 2000 PARAPET partners Copyright (C) 2000 - 2007-10-08, Hammersmith Imanet Ltd Copyright (C) 2011-07-01 - 2012, Kris Thielemans + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -29,6 +30,7 @@ #include "stir/Array.h" #include "stir/ProjDataInfo.h" +#include "stir/SinogramIndices.h" #include "stir/shared_ptr.h" @@ -40,7 +42,7 @@ START_NAMESPACE_STIR \ingroup projdata \brief A class for 2d projection data. - This represents a subset of the full projection. segment_num and axial_pos_num + This represents a subset of the full projection. SegmentIndices and axial_pos_num are fixed. */ @@ -60,14 +62,30 @@ class Sinogram : public Array<2,elemT> #endif public: - //! Construct sinogram from proj_data_info pointer, ring and segment number. Data are set to 0. + //! Construct sinogram from proj_data_info pointe and indices. Data are set to 0. + inline Sinogram(const shared_ptr& proj_data_info_sptr, + const SinogramIndices&); + + //! Construct sinogram with data set to the array. + inline Sinogram(const Array<2,elemT>& p,const shared_ptr& proj_data_info_sptr, + const SinogramIndices&); + + //! Construct sinogram from proj_data_info pointer, axial position and segment number. Data are set to 0. + /*! + \deprecated Use version with SinogramIndices instead. + */ inline Sinogram(const shared_ptr& proj_data_info_ptr, const int ax_pos_num, const int segment_num); //! Construct sinogram with data set to the array. + /*! + \deprecated Use version with SinogramIndices instead. + */ inline Sinogram(const Array<2,elemT>& p,const shared_ptr& proj_data_info_ptr, const int ax_pos_num, const int segment_num); - + + //! Get indices + inline SinogramIndices get_sinogram_indices() const; //! Get segment number inline int get_segment_num() const; //! Get number of axial positions @@ -129,8 +147,7 @@ class Sinogram : public Array<2,elemT> private: shared_ptr proj_data_info_ptr; - int axial_pos_num; - int segment_num; + SinogramIndices _indices; }; diff --git a/src/include/stir/Sinogram.inl b/src/include/stir/Sinogram.inl index 637f9d6ba..e381c6de9 100644 --- a/src/include/stir/Sinogram.inl +++ b/src/include/stir/Sinogram.inl @@ -3,6 +3,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000- 2007,Hammersmith Imanet Ltd + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -28,15 +29,22 @@ START_NAMESPACE_STIR +template +SinogramIndices +Sinogram::get_sinogram_indices() const +{ + return this->_indices; +} + template int Sinogram::get_segment_num() const -{ return segment_num; } +{ return this->_indices.segment_num(); } template int Sinogram::get_axial_pos_num() const -{ return axial_pos_num; } +{ return this->_indices.axial_pos_num(); } template int @@ -74,8 +82,8 @@ template Sinogram Sinogram::get_empty_copy(void) const { - Sinogram copy(proj_data_info_ptr, get_axial_pos_num(), get_segment_num()); - return copy; + Sinogram copy(proj_data_info_ptr, get_sinogram_indices()); + return copy; } template @@ -89,15 +97,14 @@ template Sinogram:: Sinogram(const Array<2,elemT>& p, const shared_ptr& pdi_ptr, - const int ax_pos_num, const int s_num) + const SinogramIndices& ind) : - Array<2,elemT>(p), + Array<2,elemT>(p), proj_data_info_ptr(pdi_ptr), - axial_pos_num(ax_pos_num), - segment_num(s_num) + _indices(ind) { - assert(axial_pos_num <= proj_data_info_ptr->get_max_axial_pos_num(segment_num)); - assert(axial_pos_num >= proj_data_info_ptr->get_min_axial_pos_num(segment_num)); + assert(axial_pos_num <= proj_data_info_ptr->get_max_axial_pos_num(ind.segment_num())); + assert(axial_pos_num >= proj_data_info_ptr->get_min_axial_pos_num(ind.segment_num())); // segment_num is already checked by doing get_max_axial_pos_num(s_num) assert( get_min_view_num() == pdi_ptr->get_min_view_num()); @@ -111,20 +118,33 @@ Sinogram(const Array<2,elemT>& p, template Sinogram:: Sinogram(const shared_ptr& pdi_ptr, - const int ax_pos_num, const int s_num) + const SinogramIndices& ind) : Array<2,elemT>(IndexRange2D (pdi_ptr->get_min_view_num(), pdi_ptr->get_max_view_num(), pdi_ptr->get_min_tangential_pos_num(), pdi_ptr->get_max_tangential_pos_num())), proj_data_info_ptr(pdi_ptr), - axial_pos_num(ax_pos_num), - segment_num(s_num) + _indices(ind) { - assert(axial_pos_num <= proj_data_info_ptr->get_max_axial_pos_num(segment_num)); - assert(axial_pos_num >= proj_data_info_ptr->get_min_axial_pos_num(segment_num)); + assert(axial_pos_num <= proj_data_info_ptr->get_max_axial_pos_num(ind.segment_num())); + assert(axial_pos_num >= proj_data_info_ptr->get_min_axial_pos_num(ind.segment_num())); // segment_num is already checked by doing get_max_axial_pos_num(s_num) } +template +Sinogram:: +Sinogram(const Array<2,elemT>& p, + const shared_ptr& pdi_sptr, + const int ax_pos_num, const int s_num) + : Sinogram(p, pdi_sptr, SinogramIndices(ax_pos_num, s_num)) +{} + +template +Sinogram:: +Sinogram(const shared_ptr& pdi_sptr, + const int ax_pos_num, const int s_num) + : Sinogram(pdi_sptr, SinogramIndices(ax_pos_num, s_num)) +{} END_NAMESPACE_STIR diff --git a/src/include/stir/ViewSegmentNumbers.h b/src/include/stir/ViewSegmentNumbers.h index 40bdb6c8c..d482487c9 100644 --- a/src/include/stir/ViewSegmentNumbers.h +++ b/src/include/stir/ViewSegmentNumbers.h @@ -34,6 +34,10 @@ START_NAMESPACE_STIR class ViewSegmentNumbers : public ViewgramIndices { using ViewgramIndices::ViewgramIndices; +public: + ViewSegmentNumbers(const ViewgramIndices& ind) + : ViewgramIndices(ind) + {} }; END_NAMESPACE_STIR diff --git a/src/include/stir/Viewgram.h b/src/include/stir/Viewgram.h index c6dcce6b1..faaf9f7b1 100644 --- a/src/include/stir/Viewgram.h +++ b/src/include/stir/Viewgram.h @@ -4,6 +4,7 @@ Copyright (C) 2000 PARAPET partners Copyright (C) 2000 - 2007-10-08, Hammersmith Imanet Ltd Copyright (C) 2011-07-01 - 2012, Kris Thielemans + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -28,7 +29,8 @@ #include "stir/Array.h" -#include "stir/ProjDataInfo.h" +#include "stir/ProjDataInfo.h" +#include "stir/ViewgramIndices.h" #include "stir/IndexRange.h" #include "stir/shared_ptr.h" @@ -39,7 +41,7 @@ START_NAMESPACE_STIR \ingroup projdata \brief A class for 2d projection data. - This represents a subset of the full projection. segment_num and view_num + This represents a subset of the full projection. SegmentIndices and view_num are fixed. */ @@ -60,15 +62,31 @@ class Viewgram : public Array<2,elemT> #endif public: + //! Construct from proj_data_info pointer and indices. Data are set to 0. + inline Viewgram(const shared_ptr& proj_data_info_ptr, + const ViewgramIndices& ind); + + //! Construct with data set to the array. + inline Viewgram(const Array<2,elemT>& p,const shared_ptr& proj_data_info_sptr, + const ViewgramIndices& ind); + //! Construct from proj_data_info pointer, view and segment number. Data are set to 0. + /*! + \deprecated Use version with ViewgramIndices instead + */ inline Viewgram(const shared_ptr& proj_data_info_ptr, const int v_num, const int s_num); //! Construct with data set to the array. + /*! + \deprecated Use version with ViewgramIndices instead + */ inline Viewgram(const Array<2,elemT>& p,const shared_ptr& proj_data_info_ptr, const int v_num, const int s_num); + //! Get indices + inline ViewgramIndices get_viewgram_indices() const; //! Get segment number inline int get_segment_num() const; //! Get number of views @@ -128,8 +146,7 @@ class Viewgram : public Array<2,elemT> private: shared_ptr proj_data_info_sptr; - int view_num; - int segment_num; + ViewgramIndices _indices; }; END_NAMESPACE_STIR diff --git a/src/include/stir/Viewgram.inl b/src/include/stir/Viewgram.inl index 7dd883893..d8327d9f6 100644 --- a/src/include/stir/Viewgram.inl +++ b/src/include/stir/Viewgram.inl @@ -16,6 +16,7 @@ /* Copyright (C) 2000 PARAPET partners Copyright (C) 2000- 2009, Hammersmith Imanet Ltd + Copyright (C) 2023, University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -27,15 +28,22 @@ START_NAMESPACE_STIR +template +ViewgramIndices +Viewgram::get_viewgram_indices() const +{ + return this->_indices; +} + template int Viewgram::get_segment_num() const -{ return segment_num; } +{ return this->_indices.segment_num(); } template int Viewgram::get_view_num() const -{ return view_num; } +{ return this->_indices.view_num(); } template int @@ -74,7 +82,7 @@ template Viewgram Viewgram::get_empty_copy(void) const { - Viewgram copy(proj_data_info_sptr, get_view_num(), get_segment_num()); + Viewgram copy(proj_data_info_sptr, get_viewgram_indices()); return copy; } @@ -90,17 +98,17 @@ template Viewgram:: Viewgram(const Array<2,elemT>& p, const shared_ptr& pdi_sptr, - const int v_num, const int s_num) + const ViewgramIndices& ind) : Array<2,elemT>(p), proj_data_info_sptr(pdi_sptr), - view_num(v_num), segment_num(s_num) + _indices(ind) { assert(view_num <= proj_data_info_sptr->get_max_view_num()); assert(view_num >= proj_data_info_sptr->get_min_view_num()); // segment_num is already checked by doing get_max_axial_pos_num(s_num) - assert( get_min_axial_pos_num() == pdi_sptr->get_min_axial_pos_num(s_num)); - assert( get_max_axial_pos_num() == pdi_sptr->get_max_axial_pos_num(s_num)); + assert( get_min_axial_pos_num() == pdi_sptr->get_min_axial_pos_num(ind.segment_num())); + assert( get_max_axial_pos_num() == pdi_sptr->get_max_axial_pos_num(ind.segment_num())); assert( get_min_tangential_pos_num() == pdi_sptr->get_min_tangential_pos_num()); assert( get_max_tangential_pos_num() == pdi_sptr->get_max_tangential_pos_num()); } @@ -108,20 +116,35 @@ Viewgram(const Array<2,elemT>& p, template Viewgram:: Viewgram(const shared_ptr& pdi_sptr, - const int v_num, const int s_num) + const ViewgramIndices& ind) : - Array<2,elemT>(IndexRange2D (pdi_sptr->get_min_axial_pos_num(s_num), - pdi_sptr->get_max_axial_pos_num(s_num), + Array<2,elemT>(IndexRange2D (pdi_sptr->get_min_axial_pos_num(ind.segment_num()), + pdi_sptr->get_max_axial_pos_num(ind.segment_num()), pdi_sptr->get_min_tangential_pos_num(), pdi_sptr->get_max_tangential_pos_num())), proj_data_info_sptr(pdi_sptr), - view_num(v_num), - segment_num(s_num) + _indices(ind) { assert(view_num <= proj_data_info_sptr->get_max_view_num()); assert(view_num >= proj_data_info_sptr->get_min_view_num()); // segment_num is already checked by doing get_max_axial_pos_num(s_num) } +template +Viewgram:: +Viewgram(const Array<2,elemT>& p, + const shared_ptr& pdi_sptr, + const int v_num, const int s_num) + : + Viewgram(p, pdi_sptr, ViewgramIndices(v_num, s_num)) +{} + +template +Viewgram:: +Viewgram(const shared_ptr& pdi_sptr, + const int v_num, const int s_num) + : + Viewgram(pdi_sptr, ViewgramIndices(v_num, s_num)) +{} END_NAMESPACE_STIR diff --git a/src/swig/stir_projdata.i b/src/swig/stir_projdata.i index be38c4f0f..e49a52721 100644 --- a/src/swig/stir_projdata.i +++ b/src/swig/stir_projdata.i @@ -54,12 +54,19 @@ ADD_REPR(stir::DetectionPosition, %arg(*$self)) #endif %template(DetectionPositionPair) stir::DetectionPositionPair; -%attributeref(stir::Bin, int, segment_num); +%attributeref(stir::SegmentIndices, int, segment_num); +#ifdef STIR_TOF +%attributeref(stir::SegmentIndices, int, timing_pos_num); +#endif +%attributeref(stir::ViewgramIndices, int, view_num); +%attributeref(stir::SinogramIndices, int, axial_pos_num); %attributeref(stir::Bin, int, axial_pos_num); -%attributeref(stir::Bin, int, view_num); %attributeref(stir::Bin, int, tangential_pos_num); %attributeref(stir::Bin, int, time_frame_num); %attribute(stir::Bin, float, bin_value, get_bin_value, set_bin_value); +%include "stir/SegmentIndices.h" +%include "stir/ViewgramIndices.h" +%include "stir/SinogramIndices.h" %include "stir/Bin.h" #ifdef STIR_TOF ADD_REPR(stir::Bin, %arg(*$self))