Skip to content

Commit

Permalink
Add constructors and get* members using *Indices classes
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisThielemans committed Oct 15, 2023
1 parent bcf77b3 commit 03fe063
Show file tree
Hide file tree
Showing 20 changed files with 366 additions and 92 deletions.
23 changes: 17 additions & 6 deletions src/buildblock/ProjData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstring>
#include <fstream>
Expand Down Expand Up @@ -261,7 +261,19 @@ ProjData::get_subset(const std::vector<int>& views) const
}


Viewgram<float>
Viewgram<float>
ProjData::get_empty_viewgram(const ViewgramIndices& ind) const
{
return proj_data_info_sptr->get_empty_viewgram(ind);
}

Sinogram<float>
ProjData::get_empty_sinogram(const SinogramIndices& ind) const
{
return proj_data_info_sptr->get_empty_sinogram(ind);
}

Viewgram<float>
ProjData::get_empty_viewgram(const int view_num, const int segment_num,
const bool make_num_tangential_poss_odd) const
{
Expand Down Expand Up @@ -297,7 +309,7 @@ ProjData::get_empty_segment_by_view(const int segment_num,
}

RelatedViewgrams<float>
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<DataSymmetriesForViewSegmentNumbers>& symmetries_used,
const bool make_num_tangential_poss_odd) const
Expand All @@ -308,15 +320,14 @@ ProjData::get_empty_related_viewgrams(const ViewSegmentNumbers& view_segmnet_num


RelatedViewgrams<float>
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<DataSymmetriesForViewSegmentNumbers>& symmetries_used,
const bool make_num_bins_odd) const
{
vector<ViewSegmentNumbers> pairs;
symmetries_used->get_related_view_segment_numbers(
pairs,
ViewSegmentNumbers(view_segmnet_num.view_num(),view_segmnet_num.segment_num())
viewgram_indices
);

vector<Viewgram<float> > viewgrams;
Expand Down
50 changes: 41 additions & 9 deletions src/buildblock/ProjDataInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -262,6 +262,15 @@ ProjDataInfo::get_empty_viewgram(const int view_num,
return v;
}

Viewgram<float>
ProjDataInfo::get_empty_viewgram(const ViewgramIndices& ind) const
{
// we can't access the shared ptr, so we have to clone 'this'.
shared_ptr<ProjDataInfo> proj_data_info_sptr(this->clone());
Viewgram<float> v(proj_data_info_sptr, ind);
return v;
}


Sinogram<float>
ProjDataInfo::get_empty_sinogram(const int axial_pos_num, const int segment_num,
Expand All @@ -278,6 +287,15 @@ ProjDataInfo::get_empty_sinogram(const int axial_pos_num, const int segment_num,
return s;
}

Sinogram<float>
ProjDataInfo::get_empty_sinogram(const SinogramIndices& ind) const
{
// we can't access the shared ptr, so we have to clone 'this'.
shared_ptr<ProjDataInfo> proj_data_info_sptr(this->clone());
Sinogram<float> s(proj_data_info_sptr, ind);
return s;
}

SegmentBySinogram<float>
ProjDataInfo::get_empty_segment_by_sinogram(const int segment_num,
const bool make_num_tangential_poss_odd) const
Expand All @@ -296,6 +314,14 @@ ProjDataInfo::get_empty_segment_by_sinogram(const int segment_num,
return s;
}

SegmentBySinogram<float>
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<ProjDataInfo> proj_data_info_sptr(this->clone());
SegmentBySinogram<float> s(proj_data_info_sptr, ind);
return s;
}

SegmentByView<float>
ProjDataInfo::get_empty_segment_by_view(const int segment_num,
Expand All @@ -315,26 +341,32 @@ ProjDataInfo::get_empty_segment_by_view(const int segment_num,
return s;
}

SegmentByView<float>
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<ProjDataInfo> proj_data_info_sptr(this->clone());
SegmentByView<float> s(proj_data_info_sptr, ind);
return s;
}

RelatedViewgrams<float>
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<DataSymmetriesForViewSegmentNumbers>& 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<ViewSegmentNumbers> 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<Viewgram<float> > viewgrams;
viewgrams.reserve(pairs.size());

for (unsigned int i=0; i<pairs.size(); i++)
{
// TODO optimise to get shared proj_data_info_ptr
viewgrams.push_back(get_empty_viewgram(pairs[i].view_num(),
pairs[i].segment_num(), make_num_tangential_poss_odd));
viewgrams.push_back(get_empty_viewgram(pairs[i]));
}

return RelatedViewgrams<float>(viewgrams, symmetries_used);
Expand Down
35 changes: 26 additions & 9 deletions src/buildblock/SegmentBySinogram.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,55 @@ template <typename elemT>
SegmentBySinogram<elemT> ::
SegmentBySinogram(const Array<3,elemT>& v,
const shared_ptr<const ProjDataInfo>& pdi_ptr,
const int segment_num)
const SegmentIndices& ind)
:
Segment<elemT>(pdi_ptr, segment_num),
Segment<elemT>(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());
}

template <typename elemT>
SegmentBySinogram<elemT> ::
SegmentBySinogram(const shared_ptr<const ProjDataInfo>& pdi_ptr,
const int segment_num)
const SegmentIndices& ind)
:
Segment<elemT>(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<elemT>(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 <typename elemT>
SegmentBySinogram<elemT>::
SegmentBySinogram(const Array<3,elemT>& v,
const shared_ptr<const ProjDataInfo>& pdi_sptr,
int segment_num)
:
SegmentBySinogram(v, pdi_sptr, SegmentIndices(segment_num))
{}

template <typename elemT>
SegmentBySinogram<elemT>::
SegmentBySinogram(const shared_ptr<const ProjDataInfo>& pdi_sptr,
const int segment_num)
:
SegmentBySinogram(pdi_sptr, SegmentIndices(segment_num))
{}

template <typename elemT>
SegmentBySinogram<elemT>::
SegmentBySinogram(const SegmentByView<elemT>& s_v )
: Segment<elemT>(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()))
Expand Down
35 changes: 25 additions & 10 deletions src/buildblock/SegmentByView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ template <typename elemT>
SegmentByView<elemT>::
SegmentByView(const Array<3,elemT>& v,
const shared_ptr<const ProjDataInfo>& pdi_ptr,
const int segment_num)
const SegmentIndices& ind)
:
Segment<elemT>(pdi_ptr, segment_num),
Segment<elemT>(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());

Expand All @@ -50,22 +50,37 @@ SegmentByView(const Array<3,elemT>& v,
template <typename elemT>
SegmentByView<elemT>::
SegmentByView(const shared_ptr<const ProjDataInfo>& pdi_ptr,
const int segment_num)
const SegmentIndices& ind)
:
Segment<elemT>(pdi_ptr, segment_num),
Segment<elemT>(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 <typename elemT>
SegmentByView<elemT>::
SegmentByView(const Array<3,elemT>& v,
const shared_ptr<const ProjDataInfo>& pdi_sptr,
const int segment_num)
:
SegmentByView(v, pdi_sptr, SegmentIndices(segment_num))
{}

template <typename elemT>
SegmentByView<elemT>::
SegmentByView(const shared_ptr<const ProjDataInfo>& pdi_sptr,
const int segment_num)
: SegmentByView(pdi_sptr, SegmentIndices(segment_num))
{}

template <typename elemT>
SegmentByView<elemT>::SegmentByView(const SegmentBySinogram<elemT>& s_s)
: Segment<elemT>(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()))
Expand Down
Loading

0 comments on commit 03fe063

Please # to comment.