STIR 6.4.0
stir::ProjDataInMemory Class Reference

A class which reads/writes projection data from/to memory. More...

#include "stir/ProjDataInMemory.h"

Inheritance diagram for stir::ProjDataInMemory:

Public Types

iterator typedefs

iterator typedefs

typedef Array< 1, float >::iterator iterator
 
typedef Array< 1, float >::const_iterator const_iterator
 
typedef Array< 1, float >::full_iterator full_iterator
 
typedef Array< 1, float >::const_full_iterator const_full_iterator
 

Public Member Functions

 ProjDataInMemory (shared_ptr< const ExamInfo > const &exam_info_sptr, shared_ptr< const ProjDataInfo > const &proj_data_info_ptr, const bool initialise_with_0=true)
 constructor with only info, but no data
 
 ProjDataInMemory (shared_ptr< const ExamInfo > const &exam_info_sptr, shared_ptr< const ProjDataInfo > const &proj_data_info_ptr, Array< 1, float > &&buffer)
 constructor using externally allocated storage
 
 ProjDataInMemory (const ProjData &proj_data)
 constructor that copies data from another ProjData
 
 ProjDataInMemory (const ProjDataInMemory &proj_data)
 Copy constructor.
 
Viewgram< float > get_viewgram (const int view_num, const int segment_num, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const override
 Get viewgram.
 
Succeeded set_viewgram (const Viewgram< float > &v) override
 Set viewgram.
 
Sinogram< float > get_sinogram (const int ax_pos_num, const int segment_num, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const override
 Get sinogram.
 
Succeeded set_sinogram (const Sinogram< float > &s) override
 Set sinogram.
 
SegmentBySinogram< float > get_segment_by_sinogram (const int segment_num, const int timing_pos=0) const override
 Get all sinograms for the given segment.
 
SegmentByView< float > get_segment_by_view (const int segment_num, const int timing_pos=0) const override
 Get all viewgrams for the given segment.
 
Succeeded set_segment (const SegmentBySinogram< float > &) override
 Set all sinograms for the given segment.
 
Succeeded set_segment (const SegmentByView< float > &) override
 Set all viewgrams for the given segment.
 
void fill (const float value) override
 set all bins to the same value
 
void fill (const ProjData &) override
 set all bins from another ProjData object
 
 ~ProjDataInMemory () override
 destructor deallocates all memory the object owns
 
float get_bin_value (const Bin &bin) const
 Returns a value of a bin.
 
void set_bin_value (const Bin &bin)
 
iterator begin ()
 start value for iterating through all elements in the array, see iterator
 
const_iterator begin () const
 start value for iterating through all elements in the (const) array, see iterator
 
iterator end ()
 end value for iterating through all elements in the array, see iterator
 
const_iterator end () const
 end value for iterating through all elements in the (const) array, see iterator
 
iterator begin_all ()
 start value for iterating through all elements in the array, see iterator
 
const_iterator begin_all () const
 start value for iterating through all elements in the (const) array, see iterator
 
iterator end_all ()
 end value for iterating through all elements in the array, see iterator
 
const_iterator end_all () const
 end value for iterating through all elements in the (const) array, see iterator
 
arithmetic operations

return sum of all elements

float sum () const override
 
float find_max () const override
 return maximum value of all elements
 
float find_min () const override
 return minimum value of all elements
 
double norm () const override
 return L2-norm (sqrt of sum of squares)
 
double norm_squared () const override
 return L2-norm squared (sum of squares)
 
self_type operator+ (const self_type &iv) const
 elem by elem addition
 
self_type operator- (const self_type &iv) const
 elem by elem subtraction
 
self_type operator* (const self_type &iv) const
 elem by elem multiplication
 
self_type operator/ (const self_type &iv) const
 elem by elem division
 
self_type operator+ (const float a) const
 addition with a 'float'
 
self_type operator- (const float a) const
 subtraction with a 'float'
 
self_type operator* (const float a) const
 multiplication with a 'float'
 
self_type operator/ (const float a) const
 division with a 'float'
 
self_typeoperator+= (const base_type &v) override
 adding elements of v to the current data
 
self_typeoperator-= (const base_type &v) override
 subtracting elements of v from the current data
 
self_typeoperator*= (const base_type &v) override
 multiplying elements of the current data with elements of v
 
self_typeoperator/= (const base_type &v) override
 dividing all elements of the current data by elements of v
 
self_typeoperator+= (const float v) override
 adding an float to the elements of the current data
 
self_typeoperator-= (const float v) override
 subtracting an float from the elements of the current data
 
self_typeoperator*= (const float v) override
 multiplying the elements of the current data with an float
 
self_typeoperator/= (const float v) override
 dividing the elements of the current data by an float
 
STIR_DEPRECATED void axpby (const float a, const ProjData &x, const float b, const ProjData &y) override
 
void xapyb (const ProjData &x, const float a, const ProjData &y, const float b) override
 set values of the array to x*a+y*b, where a and b are scalar, and x and y are ProjData. This implementation requires that x and y are ProjDataInMemory (else falls back on general method)
 
void xapyb (const ProjData &x, const ProjData &a, const ProjData &y, const ProjData &b) override
 set values of the array to x*a+y*b, where a, b, x and y are ProjData. This implementation requires that a, b, x and y are ProjDataInMemory (else falls back on general method)
 
void sapyb (const float a, const ProjData &y, const float b) override
 set values of the array to self*a+y*b where a and b are scalar, y is ProjData This implementation requires that a, b and y are ProjDataInMemory (else falls back on general method)
 
void sapyb (const ProjData &a, const ProjData &y, const ProjData &b) override
 set values of the array to self*a+y*b where a, b and y are ProjData This implementation requires that a, b and y are ProjDataInMemory (else falls back on general method)
 
- Public Member Functions inherited from stir::ProjData
 ProjData ()
 Empty constructor.
 
 ProjData (const shared_ptr< const ExamInfo > &exam_info_sptr, const shared_ptr< const ProjDataInfo > &proj_data_info_ptr)
 construct by specifying info. Data will be undefined.
 
Viewgram< float > get_viewgram (const ViewgramIndices &) const
 Get viewgram.
 
Sinogram< float > get_sinogram (const SinogramIndices &) const
 Get sinogram.
 
unique_ptr< ProjDataInMemoryget_subset (const std::vector< int > &views) const
 construct projection data that stores a subset of the views
 
Viewgram< float > get_empty_viewgram (const ViewgramIndices &) const
 Get empty viewgram.
 
Viewgram< float > get_empty_viewgram (const int view, const int segment_num, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const
 Get empty viewgram.
 
Sinogram< float > get_empty_sinogram (const SinogramIndices &) const
 Get empty_sinogram.
 
Sinogram< float > get_empty_sinogram (const int ax_pos_num, const int segment_num, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const
 Get empty_sinogram.
 
SegmentByView< float > get_empty_segment_by_view (const SegmentIndices &) const
 Get empty segment by view.
 
SegmentBySinogram< float > get_empty_segment_by_sinogram (const SegmentIndices &) const
 Get empty segment by sino.
 
SegmentByView< float > get_empty_segment_by_view (const int segment_num, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const
 Get empty segment view.
 
SegmentBySinogram< float > get_empty_segment_by_sinogram (const int segment_num, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const
 Get empty segment sino.
 
SegmentBySinogram< float > get_segment_by_sinogram (const SegmentIndices &) const
 Get segment by sinogram.
 
SegmentByView< float > get_segment_by_view (const SegmentIndices &) const
 Get segment by view.
 
virtual RelatedViewgrams< float > get_related_viewgrams (const ViewgramIndices &, const shared_ptr< DataSymmetriesForViewSegmentNumbers > &, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const
 Get related viewgrams.
 
virtual Succeeded set_related_viewgrams (const RelatedViewgrams< float > &viewgrams)
 Set related viewgrams.
 
RelatedViewgrams< float > get_empty_related_viewgrams (const ViewgramIndices &viewgram_indices, const shared_ptr< DataSymmetriesForViewSegmentNumbers > &symmetries_ptr, const bool make_num_tangential_poss_odd=false, const int timing_pos=0) const
 Get empty related viewgrams, where the symmetries_ptr specifies the symmetries to use.
 
template<typename iterT>
iterT fill_from (iterT array_iter)
 set all bins from an array iterator
 
template<typename iterT>
iterT copy_to (iterT array_iter) const
 Copy all bins to a range specified by a (forward) iterator.
 
int get_num_sinograms () const
 Get the total number of sinograms.
 
int get_num_non_tof_sinograms () const
 Get the number of non-tof sinograms.
 
std::size_t size_all () const
 Get the total size of the data.
 
std::vector< int > get_original_view_nums () const
 forward ProjDataInfo::get_original_view_nums()
 
Succeeded write_to_file (const std::string &filename) const
 writes data to a file in Interfile format
 
- Public Member Functions inherited from stir::ExamData
 ExamData ()
 ExamData.
 
 ExamData (const shared_ptr< const ExamInfo > &_this_exam)
 
virtual const ExamInfoget_exam_info () const
 
virtual shared_ptr< const ExamInfoget_exam_info_sptr () const
 Get shared pointer to exam info.
 
virtual void set_exam_info (ExamInfo const &)
 change exam info
 
void set_exam_info_sptr (shared_ptr< const ExamInfo > new_exam_info_sptr)
 
- Public Member Functions inherited from stir::DataWithProjDataInfo
 DataWithProjDataInfo ()
 Default constructor sets internal member to 0.
 
 DataWithProjDataInfo (const shared_ptr< const ProjDataInfo > &proj_data_info_sptr_v)
 
virtual const ProjDataInfoget_proj_data_info () const
 
virtual shared_ptr< const ProjDataInfoget_proj_data_info_sptr () const
 Get shared pointer to ProjData info.
 
int get_num_segments () const
 Get number of segments.
 
int get_num_axial_poss (const int segment_num) const
 Get number of axial positions per segment.
 
int get_num_views () const
 Get number of views.
 
int get_num_tangential_poss () const
 Get number of tangential positions.
 
int get_num_tof_poss () const
 Get number of TOF positions.
 
int get_min_tof_pos_num () const
 Get the index of the first timing position.
 
int get_max_tof_pos_num () const
 Get the index of the last timing position.
 
int get_tof_mash_factor () const
 Get TOG mash factor.
 
int get_min_segment_num () const
 Get minimum segment number.
 
int get_max_segment_num () const
 Get maximum segment number.
 
int get_min_axial_pos_num (const int segment_num) const
 Get mininum axial position per segmnet.
 
int get_max_axial_pos_num (const int segment_num) const
 Get maximum axial position per segment.
 
int get_min_view_num () const
 Get minimum view number.
 
int get_max_view_num () const
 Get maximum view number.
 
int get_min_tangential_pos_num () const
 Get minimum tangential position number.
 
int get_max_tangential_pos_num () const
 Get maximum tangential position number.
 

Static Public Member Functions

static shared_ptr< ProjDataInMemoryread_from_file (const std::string &filename)
 A static member to get the projection data in memory from a file.
 
- Static Public Member Functions inherited from stir::ProjData
static shared_ptr< ProjDataread_from_file (const std::string &filename, const std::ios::openmode open_mode=std::ios::in)
 A static member to get the projection data from a file.
 
static std::vector< int > standard_segment_sequence (const ProjDataInfo &pdi)
 Return a vector with segment numbers in a standard order.
 

access to the data via a pointer

float * get_data_ptr ()
 member function for access to the data via a float*
 
const float * get_const_data_ptr () const
 member function for access to the data via a const float*
 
void release_data_ptr ()
 signal end of access to float*
 
void release_const_data_ptr () const
 signal end of access to const float*
 

Additional Inherited Members

- Protected Attributes inherited from stir::ExamData
shared_ptr< const ExamInfoexam_info_sptr
 
- Protected Attributes inherited from stir::DataWithProjDataInfo
shared_ptr< const ProjDataInfoproj_data_info_sptr
 

Detailed Description

A class which reads/writes projection data from/to memory.

Mainly useful for temporary storage of projection data.

Constructor & Destructor Documentation

◆ ProjDataInMemory() [1/2]

stir::ProjDataInMemory::ProjDataInMemory ( shared_ptr< const ExamInfo > const & exam_info_sptr,
shared_ptr< const ProjDataInfo > const & proj_data_info_ptr,
const bool initialise_with_0 = true )

constructor with only info, but no data

Parameters
proj_data_info_ptrobject specifying all sizes etc. The ProjDataInfo object pointed to will not be modified.
initialise_with_0specifies if the data should be set to 0. If false, the data is undefined until you set it yourself.

References stir::ProjData::ProjData(), ProjDataInMemory(), and stir::ProjData::standard_segment_sequence().

Referenced by fill(), operator*(), operator*(), operator*=(), operator+(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator/(), operator/(), operator/=(), ProjDataInMemory(), ProjDataInMemory(), ProjDataInMemory(), xapyb(), and xapyb().

◆ ProjDataInMemory() [2/2]

stir::ProjDataInMemory::ProjDataInMemory ( shared_ptr< const ExamInfo > const & exam_info_sptr,
shared_ptr< const ProjDataInfo > const & proj_data_info_ptr,
Array< 1, float > && buffer )

constructor using externally allocated storage

The supplied buffer must have exactly size_all() elements for the projection-data geometry.

References stir::error(), stir::ProjData::ProjData(), and stir::ProjData::standard_segment_sequence().

Member Function Documentation

◆ get_viewgram()

Viewgram< float > stir::ProjDataInMemory::get_viewgram ( const int view,
const int segment_num,
const bool make_num_tangential_poss_odd = false,
const int timing_pos = 0 ) const
overridevirtual

◆ set_viewgram()

◆ get_sinogram()

Sinogram< float > stir::ProjDataInMemory::get_sinogram ( const int ax_pos_num,
const int segment_num,
const bool make_num_tangential_poss_odd = false,
const int timing_pos = 0 ) const
overridevirtual

◆ set_sinogram()

◆ get_segment_by_sinogram()

SegmentBySinogram< float > stir::ProjDataInMemory::get_segment_by_sinogram ( const int segment_num,
const int timing_pos = 0 ) const
overridevirtual

◆ get_segment_by_view()

SegmentByView< float > stir::ProjDataInMemory::get_segment_by_view ( const int segment_num,
const int timing_pos = 0 ) const
overridevirtual

Get all viewgrams for the given segment.

Reimplemented from stir::ProjData.

References get_segment_by_sinogram().

◆ set_segment() [1/2]

◆ set_segment() [2/2]

Succeeded stir::ProjDataInMemory::set_segment ( const SegmentByView< float > & segmentbyview_v)
overridevirtual

Set all viewgrams for the given segment.

Reimplemented from stir::ProjData.

References set_segment().

◆ fill() [1/2]

void stir::ProjDataInMemory::fill ( const float value)
overridevirtual

set all bins to the same value

will call error() if setting failed

Reimplemented from stir::ProjData.

References begin_all(), and end_all().

Referenced by ProjDataInMemory().

◆ fill() [2/2]

void stir::ProjDataInMemory::fill ( const ProjData & proj_data)
overridevirtual

set all bins from another ProjData object

will call error() if setting failed or if the 'source' proj_data is not compatible. The current check requires at least the same segment numbers (but the source can have more), all other geometric parameters have to be the same.

Reimplemented from stir::ProjData.

References begin_all(), stir::ProjData::fill(), stir::DataWithProjDataInfo::get_proj_data_info_sptr(), stir::ProjData::ProjData(), and ProjDataInMemory().

◆ sum()

float stir::ProjDataInMemory::sum ( ) const
overridevirtual

Reimplemented from stir::ProjData.

◆ find_max()

float stir::ProjDataInMemory::find_max ( ) const
overridevirtual

return maximum value of all elements

Reimplemented from stir::ProjData.

◆ find_min()

float stir::ProjDataInMemory::find_min ( ) const
overridevirtual

return minimum value of all elements

Reimplemented from stir::ProjData.

◆ norm()

double stir::ProjDataInMemory::norm ( ) const
overridevirtual

return L2-norm (sqrt of sum of squares)

Reimplemented from stir::ProjData.

References stir::norm().

◆ norm_squared()

double stir::ProjDataInMemory::norm_squared ( ) const
overridevirtual

return L2-norm squared (sum of squares)

Reimplemented from stir::ProjData.

References stir::norm_squared().

◆ operator+=() [1/2]

ProjDataInMemory & stir::ProjDataInMemory::operator+= ( const base_type & v)
overridevirtual

adding elements of v to the current data

Reimplemented from stir::ProjData.

References stir::ProjData::operator+=(), and ProjDataInMemory().

◆ operator-=() [1/2]

ProjDataInMemory & stir::ProjDataInMemory::operator-= ( const base_type & v)
overridevirtual

subtracting elements of v from the current data

Reimplemented from stir::ProjData.

References stir::ProjData::operator-=(), and ProjDataInMemory().

◆ operator*=() [1/2]

ProjDataInMemory & stir::ProjDataInMemory::operator*= ( const base_type & v)
overridevirtual

multiplying elements of the current data with elements of v

Reimplemented from stir::ProjData.

References stir::ProjData::operator*=(), and ProjDataInMemory().

◆ operator/=() [1/2]

ProjDataInMemory & stir::ProjDataInMemory::operator/= ( const base_type & v)
overridevirtual

dividing all elements of the current data by elements of v

Reimplemented from stir::ProjData.

References stir::ProjData::operator/=(), and ProjDataInMemory().

◆ operator+=() [2/2]

ProjDataInMemory & stir::ProjDataInMemory::operator+= ( const float v)
overridevirtual

adding an float to the elements of the current data

Reimplemented from stir::ProjData.

◆ operator-=() [2/2]

ProjDataInMemory & stir::ProjDataInMemory::operator-= ( const float v)
overridevirtual

subtracting an float from the elements of the current data

Reimplemented from stir::ProjData.

◆ operator*=() [2/2]

ProjDataInMemory & stir::ProjDataInMemory::operator*= ( const float v)
overridevirtual

multiplying the elements of the current data with an float

Reimplemented from stir::ProjData.

◆ operator/=() [2/2]

ProjDataInMemory & stir::ProjDataInMemory::operator/= ( const float v)
overridevirtual

dividing the elements of the current data by an float

Reimplemented from stir::ProjData.

◆ axpby()

void stir::ProjDataInMemory::axpby ( const float a,
const ProjData & x,
const float b,
const ProjData & y )
overridevirtual
Deprecated
a*x+b*y (use xapyb)

Reimplemented from stir::ProjData.

References stir::ProjData::ProjData(), and xapyb().

◆ xapyb() [1/2]

void stir::ProjDataInMemory::xapyb ( const ProjData & x,
const float a,
const ProjData & y,
const float b )
overridevirtual

set values of the array to x*a+y*b, where a and b are scalar, and x and y are ProjData. This implementation requires that x and y are ProjDataInMemory (else falls back on general method)

Reimplemented from stir::ProjData.

References stir::error(), stir::DataWithProjDataInfo::get_proj_data_info_sptr(), stir::ProjData::ProjData(), ProjDataInMemory(), stir::ProjData::size_all(), stir::Array< num_dimensions, elemT >::xapyb(), and stir::ProjData::xapyb().

Referenced by axpby(), sapyb(), and sapyb().

◆ xapyb() [2/2]

void stir::ProjDataInMemory::xapyb ( const ProjData & x,
const ProjData & a,
const ProjData & y,
const ProjData & b )
overridevirtual

set values of the array to x*a+y*b, where a, b, x and y are ProjData. This implementation requires that a, b, x and y are ProjDataInMemory (else falls back on general method)

Reimplemented from stir::ProjData.

References stir::error(), stir::DataWithProjDataInfo::get_proj_data_info_sptr(), stir::ProjData::ProjData(), ProjDataInMemory(), stir::ProjData::size_all(), stir::Array< num_dimensions, elemT >::xapyb(), and stir::ProjData::xapyb().

◆ sapyb() [1/2]

void stir::ProjDataInMemory::sapyb ( const float a,
const ProjData & y,
const float b )
overridevirtual

set values of the array to self*a+y*b where a and b are scalar, y is ProjData This implementation requires that a, b and y are ProjDataInMemory (else falls back on general method)

Reimplemented from stir::ProjData.

References stir::ProjData::ProjData(), and xapyb().

◆ sapyb() [2/2]

void stir::ProjDataInMemory::sapyb ( const ProjData & a,
const ProjData & y,
const ProjData & b )
overridevirtual

set values of the array to self*a+y*b where a, b and y are ProjData This implementation requires that a, b and y are ProjDataInMemory (else falls back on general method)

Reimplemented from stir::ProjData.

References stir::ProjData::ProjData(), and xapyb().


The documentation for this class was generated from the following files: