STIR 6.4.0
ProjDataFromStream.h
Go to the documentation of this file.
1//
2//
17/*
18 Copyright (C) 2000 PARAPET partners
19 Copyright (C) 2000- 2013, Hammersmith Imanet Ltd
20 Copyright (C) 2016, University of Hull
21 Copyright (C) 2020, 2022 University College London
22
23 This file is part of STIR.
24
25 SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
26
27 See STIR/LICENSE.txt for details
28*/
29#ifndef __ProjDataFromStream_H__
30#define __ProjDataFromStream_H__
31
32#include "stir/ProjData.h"
33#include "stir/NumericType.h"
34#include "stir/ByteOrder.h"
35#include "stir/shared_ptr.h"
36#include "stir/Bin.h"
37#include <iostream>
38#include <vector>
39
40START_NAMESPACE_STIR
41
57{
58public:
59 enum StorageOrder
60 {
61 Segment_AxialPos_View_TangPos,
62 Timing_Segment_AxialPos_View_TangPos,
63 Segment_View_AxialPos_TangPos,
64 Timing_Segment_View_AxialPos_TangPos,
65 Unsupported
66 };
67#if 0
68 static ProjDataFromStream* ask_parameters(const bool on_disk = true);
69#endif
70
71#if 0
74 {}
75#endif
76
78
83 ProjDataFromStream(shared_ptr<const ExamInfo> const& exam_info_sptr,
84 shared_ptr<const ProjDataInfo> const& proj_data_info_ptr,
85 shared_ptr<std::iostream> const& s,
86 const std::streamoff offs,
87 const std::vector<int>& segment_sequence_in_stream,
88 StorageOrder o = Segment_View_AxialPos_TangPos,
89 NumericType data_type = NumericType::FLOAT,
90 ByteOrder byte_order = ByteOrder::native,
91 float scale_factor = 1.f);
92
94
97 ProjDataFromStream(shared_ptr<const ExamInfo> const& exam_info_sptr,
98 shared_ptr<const ProjDataInfo> const& proj_data_info_ptr,
99 shared_ptr<std::iostream> const& s,
100 const std::streamoff offs = 0,
101 StorageOrder o = Segment_View_AxialPos_TangPos,
102 NumericType data_type = NumericType::FLOAT,
103 ByteOrder byte_order = ByteOrder::native,
104 float scale_factor = 1.f);
105
107 inline StorageOrder get_storage_order() const;
108
110 // inline int get_offset_in_stream() const;
111 inline std::streamoff get_offset_in_stream() const;
112
115
117 inline ByteOrder get_byte_order_in_stream() const;
118
120 inline std::vector<int> get_segment_sequence_in_stream() const;
122 inline std::vector<int> get_timing_poss_sequence_in_stream() const;
124 void set_timing_poss_sequence_in_stream(const std::vector<int>& seq);
125
127 Viewgram<float> get_viewgram(const int view_num,
128 const int segment_num,
129 const bool make_num_tangential_poss_odd = false,
130 const int timing_pos = 0) const override;
131 Succeeded set_viewgram(const Viewgram<float>& v) override;
132
134 Sinogram<float> get_sinogram(const int ax_pos_num,
135 const int segment_num,
136 const bool make_num_tangential_poss_odd = false,
137 const int timing_pos = 0) const override;
138
139 Succeeded set_sinogram(const Sinogram<float>& s) override;
140
142 SegmentBySinogram<float> get_segment_by_sinogram(const int segment_num, const int timing_num = 0) const override;
144 SegmentByView<float> get_segment_by_view(const int segment_num, const int timing_pos = 0) const override;
145
150
152 float get_scale_factor() const;
153
155 virtual float get_bin_value(const Bin& this_bin) const;
156
158 virtual void set_bin_value(const Bin& bin);
159
160protected:
162 shared_ptr<std::iostream> sino_stream;
163
165
166 std::streamoff get_offset(const Bin&) const;
167
168private:
169 void activate_TOF();
171 std::streamoff offset;
173 std::streamoff offset_3d_data;
174
176 std::vector<int> segment_sequence;
178 std::vector<int> timing_poss_sequence;
179
180 inline int find_segment_index_in_sequence(const int segment_num) const;
181
182 StorageOrder storage_order;
183
184 NumericType on_disk_data_type;
185
186 ByteOrder on_disk_byte_order;
187
188 // scale_factor is only used when reading data from file. Data are stored in
189 // memory as float, with the scale factor multiplied out
190 float scale_factor;
191
192private:
193#if __cplusplus > 199711L
194 ProjDataFromStream& operator=(ProjDataFromStream&&) = delete;
195#endif
196};
197
198END_NAMESPACE_STIR
199
201
202#endif
Declaration of class stir::Bin.
This file declares the stir::ByteOrder class.
This file declares the stir::NumericType class.
Inline implementations for class stir::ProjDataFromStream.
Declaration of class stir::ProjData.
A class for storing coordinates and value of a single projection bin.
Definition Bin.h:49
This class provides member functions to find out what byte-order your machine is and to swap numbers.
Definition ByteOrder.h:100
@ native
Definition ByteOrder.h:107
provides names for some numeric types and methods for finding their properties.
Definition NumericType.h:55
Succeeded set_sinogram(const Sinogram< float > &s) override
Set sinogram.
Definition ProjDataFromStream.cxx:572
shared_ptr< std::iostream > sino_stream
the stream with the data
Definition ProjDataFromStream.h:162
NumericType get_data_type_in_stream() const
Get the data_type in the stream.
Definition ProjDataFromStream.inl:53
Succeeded set_segment(const SegmentBySinogram< float > &) override
Set all sinograms for the given segment.
Definition ProjDataFromStream.cxx:759
SegmentBySinogram< float > get_segment_by_sinogram(const int segment_num, const int timing_num=0) const override
Get all sinograms for the given segment.
Definition ProjDataFromStream.cxx:661
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.
Definition ProjDataFromStream.cxx:179
std::vector< int > get_segment_sequence_in_stream() const
Get the segment sequence.
Definition ProjDataFromStream.inl:65
ByteOrder get_byte_order_in_stream() const
Get the byte order.
Definition ProjDataFromStream.inl:59
void set_timing_poss_sequence_in_stream(const std::vector< int > &seq)
set the timing bins sequence
Definition ProjDataFromStream.cxx:152
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
virtual float get_bin_value(const Bin &this_bin) const
Get the value of bin.
Definition ProjDataFromStream.cxx:258
std::streamoff get_offset(const Bin &) const
Calculate the offset for a specific bin.
Definition ProjDataFromStream.cxx:414
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
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.
Definition ProjDataFromStream.cxx:501
float get_scale_factor() const
Get scale factor.
Definition ProjDataFromStream.cxx:1062
std::vector< int > get_timing_poss_sequence_in_stream() const
Get the timing bins sequence.
Definition ProjDataFromStream.inl:71
SegmentByView< float > get_segment_by_view(const int segment_num, const int timing_pos=0) const override
Get all viewgrams for the given segment.
Definition ProjDataFromStream.cxx:711
StorageOrder get_storage_order() const
Obtain the storage order.
Definition ProjDataFromStream.inl:32
virtual void set_bin_value(const Bin &bin)
Set the value of the bin.
Definition ProjDataFromStream.cxx:285
std::streamoff get_offset_in_stream() const
Get the offset -Changed into streamoff from int.
Definition ProjDataFromStream.inl:47
Succeeded set_viewgram(const Viewgram< float > &v) override
Set viewgram.
Definition ProjDataFromStream.cxx:309
ProjData()
Empty constructor.
Definition ProjData.cxx:394
A class for storing (3d) projection data with fixed SegmentIndices.
Definition SegmentBySinogram.h:51
A class for storing (3d) projection data with fixed SegmentIndices.
Definition SegmentByView.h:52
A class for 2d projection data.
Definition Sinogram.h:47
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44
A class for 2d projection data.
Definition Viewgram.h:49
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast into the stir names...