|
STIR 6.4.0
|
A class which reads/writes projection data from/to a (binary) stream. More...
#include "stir/ProjDataFromStream.h"

Public Types | |
| enum | StorageOrder { Segment_AxialPos_View_TangPos , Timing_Segment_AxialPos_View_TangPos , Segment_View_AxialPos_TangPos , Timing_Segment_View_AxialPos_TangPos , Unsupported } |
Public Member Functions | |
| ProjDataFromStream (shared_ptr< const ExamInfo > const &exam_info_sptr, shared_ptr< const ProjDataInfo > const &proj_data_info_ptr, shared_ptr< std::iostream > const &s, const std::streamoff offs, const std::vector< int > &segment_sequence_in_stream, StorageOrder o=Segment_View_AxialPos_TangPos, NumericType data_type=NumericType::FLOAT, ByteOrder byte_order=ByteOrder::native, float scale_factor=1.f) | |
| constructor taking all necessary parameters | |
| ProjDataFromStream (shared_ptr< const ExamInfo > const &exam_info_sptr, shared_ptr< const ProjDataInfo > const &proj_data_info_ptr, shared_ptr< std::iostream > const &s, const std::streamoff offs=0, StorageOrder o=Segment_View_AxialPos_TangPos, NumericType data_type=NumericType::FLOAT, ByteOrder byte_order=ByteOrder::native, float scale_factor=1.f) | |
| as above, but with a default value for segment_sequence_in_stream | |
| StorageOrder | get_storage_order () const |
| Obtain the storage order. | |
| std::streamoff | get_offset_in_stream () const |
| Get the offset -Changed into streamoff from int. | |
| NumericType | get_data_type_in_stream () const |
| Get the data_type in the stream. | |
| ByteOrder | get_byte_order_in_stream () const |
| Get the byte order. | |
| std::vector< int > | get_segment_sequence_in_stream () const |
| Get the segment sequence. | |
| std::vector< int > | get_timing_poss_sequence_in_stream () const |
| Get the timing bins sequence. | |
| void | set_timing_poss_sequence_in_stream (const std::vector< int > &seq) |
| set the timing bins sequence | |
| 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 & set 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 & set sinogram. | |
| Succeeded | set_sinogram (const Sinogram< float > &s) override |
| Set sinogram. | |
| SegmentBySinogram< float > | get_segment_by_sinogram (const int segment_num, const int timing_num=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. | |
| float | get_scale_factor () const |
| Get scale factor. | |
| virtual float | get_bin_value (const Bin &this_bin) const |
| Get the value of bin. | |
| virtual void | set_bin_value (const Bin &bin) |
| Set the value of the bin. | |
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< ProjDataInMemory > | get_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. | |
| virtual void | fill (const float value) |
| set all bins to the same value | |
| virtual void | fill (const ProjData &) |
| set all bins from another ProjData object | |
| 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 | |
| virtual float | sum () const |
| virtual float | find_max () const |
| return maximum value of all elements | |
| virtual float | find_min () const |
| return minimum value of all elements | |
| virtual double | norm () const |
| return L2-norm (sqrt of sum of squares) | |
| virtual double | norm_squared () const |
| return L2-norm squared (sum of squares) | |
| virtual self_type & | operator+= (const self_type &v) |
adding elements of v to the current data | |
| virtual self_type & | operator-= (const self_type &v) |
subtracting elements of v from the current data | |
| virtual self_type & | operator*= (const self_type &v) |
multiplying elements of the current data with elements of v | |
| virtual self_type & | operator/= (const self_type &v) |
dividing all elements of the current data by elements of v | |
| virtual self_type & | operator+= (const float v) |
adding an float to the elements of the current data | |
| virtual self_type & | operator-= (const float v) |
subtracting an float from the elements of the current data | |
| virtual self_type & | operator*= (const float v) |
multiplying the elements of the current data with an float | |
| virtual self_type & | operator/= (const float v) |
dividing the elements of the current data by an float | |
| virtual STIR_DEPRECATED void | axpby (const float a, const ProjData &x, const float b, const ProjData &y) |
| virtual void | xapyb (const ProjData &x, const float a, const ProjData &y, const float b) |
| set values of the array to x*a+y*b, where a and b are scalar, and x and y are ProjData | |
| virtual void | xapyb (const ProjData &x, const ProjData &a, const ProjData &y, const ProjData &b) |
| set values of the array to x*a+y*b, where a, b, x and y are ProjData | |
| virtual void | sapyb (const float a, const ProjData &y, const float b) |
| set values of the array to self*a+y*b where a and b are scalar, y is ProjData | |
| virtual void | sapyb (const ProjData &a, const ProjData &y, const ProjData &b) |
| set values of the array to self*a+y*b where a, b and y are ProjData | |
Public Member Functions inherited from stir::ExamData | |
| ExamData () | |
| ExamData. | |
| ExamData (const shared_ptr< const ExamInfo > &_this_exam) | |
| virtual const ExamInfo & | get_exam_info () const |
| virtual shared_ptr< const ExamInfo > | get_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 ProjDataInfo & | get_proj_data_info () const |
| virtual shared_ptr< const ProjDataInfo > | get_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. | |
Protected Member Functions | |
| std::streamoff | get_offset (const Bin &) const |
| Calculate the offset for a specific bin. | |
Protected Attributes | |
| shared_ptr< std::iostream > | sino_stream |
| the stream with the data | |
Protected Attributes inherited from stir::ExamData | |
| shared_ptr< const ExamInfo > | exam_info_sptr |
Protected Attributes inherited from stir::DataWithProjDataInfo | |
| shared_ptr< const ProjDataInfo > | proj_data_info_sptr |
Additional Inherited Members | |
Static Public Member Functions inherited from stir::ProjData | |
| static shared_ptr< ProjData > | read_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. | |
A class which reads/writes projection data from/to a (binary) stream.
At the end of every write (i.e., \ set_*) operation, the stream is flushed such that subsequent read operations from the same file will be able this data even if the stream isn't closed yet. This is important in an interactive context, as the object owning the stream might not be deleted yet before we try to read the file again.
| stir::ProjDataFromStream::ProjDataFromStream | ( | shared_ptr< const ExamInfo > const & | exam_info_sptr, |
| shared_ptr< const ProjDataInfo > const & | proj_data_info_ptr, | ||
| shared_ptr< std::iostream > const & | s, | ||
| const std::streamoff | offs, | ||
| const std::vector< int > & | segment_sequence_in_stream, | ||
| StorageOrder | o = Segment_View_AxialPos_TangPos, | ||
| NumericType | data_type = NumericType::FLOAT, | ||
| ByteOrder | byte_order = ByteOrder::native, | ||
| float | scale_factor = 1.f ) |
constructor taking all necessary parameters
| segment_sequence_in_stream | has to be set according to the order in which the segments occur in the stream. segment_sequence_in_stream[i] is the segment number of the i-th segment in the stream. |
References stir::ByteOrder::native.
| stir::ProjDataFromStream::ProjDataFromStream | ( | shared_ptr< const ExamInfo > const & | exam_info_sptr, |
| shared_ptr< const ProjDataInfo > const & | proj_data_info_ptr, | ||
| shared_ptr< std::iostream > const & | s, | ||
| const std::streamoff | offs = 0, | ||
| StorageOrder | o = Segment_View_AxialPos_TangPos, | ||
| NumericType | data_type = NumericType::FLOAT, | ||
| ByteOrder | byte_order = ByteOrder::native, | ||
| float | scale_factor = 1.f ) |
as above, but with a default value for segment_sequence_in_stream
The default value for segment_sequence_in_stream is a vector with values min_segment_num, min_segment_num+1, ..., max_segment_num
References get_bin_value(), get_byte_order_in_stream(), get_data_type_in_stream(), get_offset_in_stream(), get_scale_factor(), get_segment_by_sinogram(), get_segment_by_view(), get_segment_sequence_in_stream(), get_sinogram(), get_storage_order(), get_timing_poss_sequence_in_stream(), get_viewgram(), stir::ByteOrder::native, set_bin_value(), set_segment(), set_sinogram(), set_timing_poss_sequence_in_stream(), and set_viewgram().
|
overridevirtual |
Get & set viewgram.
Implements stir::ProjData.
References stir::Bin::axial_pos_num(), stir::error(), stir::DataWithProjDataInfo::get_max_axial_pos_num(), stir::DataWithProjDataInfo::get_max_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_axial_pos_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_num_tangential_poss(), get_offset(), get_storage_order(), get_viewgram(), stir::Viewgram< elemT >::grow(), stir::read_data(), sino_stream, and stir::warning().
Referenced by get_viewgram(), and ProjDataFromStream().
Set viewgram.
Implements stir::ProjData.
References stir::Bin::axial_pos_num(), stir::error(), stir::DataWithProjDataInfo::get_max_axial_pos_num(), stir::DataWithProjDataInfo::get_min_axial_pos_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_num_axial_poss(), stir::Viewgram< elemT >::get_num_axial_poss(), stir::DataWithProjDataInfo::get_num_tangential_poss(), get_offset(), stir::DataWithProjDataInfo::get_proj_data_info_sptr(), stir::Viewgram< elemT >::get_segment_num(), get_storage_order(), stir::Viewgram< elemT >::get_timing_pos_num(), stir::Viewgram< elemT >::get_view_num(), set_viewgram(), sino_stream, stir::warning(), and stir::write_data().
Referenced by ProjDataFromStream(), and set_viewgram().
|
overridevirtual |
Get & set sinogram.
Implements stir::ProjData.
References stir::error(), stir::DataWithProjDataInfo::get_max_tangential_pos_num(), stir::DataWithProjDataInfo::get_max_view_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_view_num(), stir::DataWithProjDataInfo::get_num_tangential_poss(), get_offset(), get_sinogram(), get_storage_order(), stir::Sinogram< elemT >::grow(), stir::read_data(), sino_stream, stir::ViewgramIndices::view_num(), and stir::warning().
Referenced by get_sinogram(), and ProjDataFromStream().
Set sinogram.
Implements stir::ProjData.
References stir::Sinogram< elemT >::get_axial_pos_num(), stir::DataWithProjDataInfo::get_max_view_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_view_num(), get_offset(), stir::DataWithProjDataInfo::get_proj_data_info_sptr(), stir::Sinogram< elemT >::get_segment_num(), get_storage_order(), stir::Sinogram< elemT >::get_timing_pos_num(), set_sinogram(), sino_stream, stir::ViewgramIndices::view_num(), stir::warning(), and stir::write_data().
Referenced by ProjDataFromStream(), and set_sinogram().
|
overridevirtual |
Get all sinograms for the given segment.
Reimplemented from stir::ProjData.
References stir::error(), stir::DataWithProjDataInfo::get_min_axial_pos_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_view_num(), get_offset(), get_segment_by_sinogram(), get_segment_by_view(), get_storage_order(), stir::read_data(), and sino_stream.
Referenced by get_segment_by_sinogram(), get_segment_by_view(), and ProjDataFromStream().
|
overridevirtual |
Get all viewgrams for the given segment.
Reimplemented from stir::ProjData.
References stir::error(), stir::DataWithProjDataInfo::get_min_axial_pos_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_view_num(), get_offset(), get_segment_by_sinogram(), get_segment_by_view(), get_storage_order(), stir::read_data(), and sino_stream.
Referenced by get_segment_by_sinogram(), get_segment_by_view(), and ProjDataFromStream().
|
overridevirtual |
Set all sinograms for the given segment.
Reimplemented from stir::ProjData.
References stir::error(), stir::DataWithProjDataInfo::get_min_axial_pos_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_view_num(), stir::DataWithProjDataInfo::get_num_tangential_poss(), stir::DataWithProjDataInfo::get_num_views(), get_offset(), stir::Segment< elemT >::get_segment_num(), get_storage_order(), stir::Segment< elemT >::get_timing_pos_num(), set_segment(), sino_stream, stir::warning(), and stir::write_data().
Referenced by ProjDataFromStream(), stir::stir_mathTests::run_tests(), set_segment(), and set_segment().
|
overridevirtual |
Set all viewgrams for the given segment.
Reimplemented from stir::ProjData.
References stir::error(), stir::DataWithProjDataInfo::get_min_axial_pos_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_view_num(), stir::DataWithProjDataInfo::get_num_tangential_poss(), stir::DataWithProjDataInfo::get_num_views(), get_offset(), stir::Segment< elemT >::get_segment_num(), get_storage_order(), stir::Segment< elemT >::get_timing_pos_num(), set_segment(), sino_stream, stir::warning(), and stir::write_data().
|
protected |
Calculate the offset for a specific bin.
Throws if out-of-range or other error
References stir::Bin::axial_pos_num(), stir::error(), stir::DataWithProjDataInfo::get_max_axial_pos_num(), stir::DataWithProjDataInfo::get_max_segment_num(), stir::DataWithProjDataInfo::get_max_tof_pos_num(), stir::DataWithProjDataInfo::get_min_axial_pos_num(), stir::DataWithProjDataInfo::get_min_segment_num(), stir::DataWithProjDataInfo::get_min_tangential_pos_num(), stir::DataWithProjDataInfo::get_min_tof_pos_num(), stir::DataWithProjDataInfo::get_min_view_num(), stir::DataWithProjDataInfo::get_num_axial_poss(), stir::DataWithProjDataInfo::get_num_tangential_poss(), stir::DataWithProjDataInfo::get_num_views(), get_offset(), get_storage_order(), stir::SegmentIndices::segment_num(), stir::Bin::tangential_pos_num(), stir::SegmentIndices::timing_pos_num(), and stir::ViewgramIndices::view_num().
Referenced by get_bin_value(), get_offset(), get_segment_by_sinogram(), get_segment_by_view(), get_sinogram(), get_viewgram(), set_bin_value(), set_segment(), set_segment(), set_sinogram(), and set_viewgram().