STIR  6.2.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 
40 START_NAMESPACE_STIR
41 
57 {
58 public:
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 
114  inline NumericType get_data_type_in_stream() const;
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 
147  Succeeded set_segment(const SegmentBySinogram<float>&) override;
149  Succeeded set_segment(const SegmentByView<float>&) override;
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 
160 protected:
162  shared_ptr<std::iostream> sino_stream;
163 
165 
166  std::streamoff get_offset(const Bin&) const;
167 
168 private:
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 
192 private:
193 #if __cplusplus > 199711L
194  ProjDataFromStream& operator=(ProjDataFromStream&&) = delete;
195 #endif
196 };
197 
198 END_NAMESPACE_STIR
199 
201 
202 #endif
A class for 2d projection data.
Definition: FBP3DRPReconstruction.h:39
This file declares the stir::ByteOrder class.
shared_ptr< std::iostream > sino_stream
the stream with the data
Definition: ProjDataFromStream.h:162
A class for storing (3d) projection data with fixed SegmentIndices.
Definition: FBP3DRPReconstruction.h:41
This class provides member functions to find out what byte-order your machine is and to swap numbers...
Definition: ByteOrder.h:99
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
Declaration of class stir::ProjData.
Inline implementations for class stir::ProjDataFromStream.
A class for storing (3d) projection data with fixed SegmentIndices.
Definition: ArcCorrection.h:40
A class for storing coordinates and value of a single projection bin.
Definition: Bin.h:48
Declaration of class stir::Bin.
A class which reads/writes projection data from/to a (binary) stream.
Definition: ProjDataFromStream.h:56
provides names for some numeric types and methods for finding their properties.
Definition: NumericType.h:54
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition: Succeeded.h:43
The (abstract) base class for the projection data.
Definition: ProjData.h:103
This file declares the stir::NumericType class.