STIR  6.2.0
InterfileHeader.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2007, Hammersmith Imanet Ltd
3  Copyright (C) 2013, 2016, 2018, 2020 University College London
4  Copyright 2017 ETH Zurich, Institute of Particle Physics and Astrophysics
5  This file is part of STIR.
6 
7  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
8 
9  See STIR/LICENSE.txt for details
10 */
27 #ifndef __stir_INTERFILEHEADER_H__
28 #define __stir_INTERFILEHEADER_H__
29 
30 #include "stir/ByteOrder.h"
31 #include "stir/NumericInfo.h"
32 #include "stir/KeyParser.h"
34 #include "stir/ExamInfo.h"
36 
37 START_NAMESPACE_STIR
38 
39 class ProjDataInfo;
40 
50 {
51 public:
53  static const double double_value_not_set;
55 
56  ~MinimalInterfileHeader() override {}
57 
58 protected:
59  shared_ptr<ExamInfo> exam_info_sptr;
60 
61 private:
62  std::string imaging_modality_as_string;
63  void set_imaging_modality();
64 
65 public:
67  shared_ptr<const ExamInfo> get_exam_info_sptr() const;
69  const ExamInfo& get_exam_info() const;
70 
71  std::string version_of_keys;
72 
73  std::string siemens_mi_version;
74 
75 protected:
77 
85  virtual void set_version_specific_keys();
86 };
87 
95 {
96 public:
98  // Returns false if OK, true if not.
99  bool post_processing() override;
100 
101 private:
102  // TODO the next few ones should be made static members
103  // Lists of possible values for some keywords
104  ASCIIlist_type number_format_values;
105  ASCIIlist_type byte_order_values;
106  ASCIIlist_type patient_orientation_values;
107  ASCIIlist_type patient_rotation_values;
108 
109  // Corresponding variables here
110 
111  int number_format_index;
112  int byte_order_index;
113  int patient_orientation_index;
114  int patient_rotation_index;
115 
116  void set_type_of_data();
117 
118 protected:
119  int num_time_frames;
120  std::vector<double> image_relative_start_times;
121  std::vector<double> image_durations;
122  int bytes_per_pixel;
123 
125  std::string isotope_name;
126  std::vector<std::string> radionuclide_name;
127  std::vector<float> radionuclide_half_life;
128  std::vector<float> radionuclide_branching_ratio;
129 
130  float calibration_factor;
131 
132 private:
133  // Louvain la Neuve style of 'image scaling factors'
134  double lln_quantification_units;
135 
136 protected:
138  void set_version_specific_keys() override;
139  virtual void read_matrix_info();
140  virtual void read_num_energy_windows();
141  void read_frames_info();
143 
146  virtual int get_num_datasets() const { return num_time_frames; }
147 
148 public:
149  ASCIIlist_type type_of_data_values;
150  int type_of_data_index;
151 
152  ASCIIlist_type PET_data_type_values;
153  int PET_data_type_index;
154 
155  ASCIIlist_type process_status_values;
156  int process_status_index;
157 
158  // 'Final' variables
159 
160  std::string data_file_name;
161 
162  DateTimeStrings study_date_time;
163 
168 
169  int num_dimensions;
170  int num_energy_windows;
171  std::vector<std::string> matrix_labels;
172  std::vector<std::vector<int>> matrix_size;
173  std::vector<float> pixel_sizes;
174  std::vector<std::vector<double>> image_scaling_factors;
175  std::vector<unsigned long> data_offset_each_dataset;
176 
177  // Acquisition parameters
181  std::vector<float> lower_en_window_thresholds;
182 
186  std::vector<float> upper_en_window_thresholds;
187  // end acquisition parameters
188 
189 protected:
190  // version 3.3 had only a single offset. we'll internally replace it with data_offset_each_dataset
191  unsigned long data_offset;
192 
193  float bed_position_horizontal;
194  float bed_position_vertical;
195 };
196 
202 {
203 private:
204  typedef InterfileHeader base_type;
205 
206 public:
208  std::vector<double> first_pixel_offsets;
209  int num_image_data_types;
210  std::vector<std::string> index_nesting_level;
211  std::vector<std::string> image_data_type_description;
212 
213 protected:
214  void read_matrix_info() override;
216  bool post_processing() override;
218  void read_image_data_types();
223  int get_num_datasets() const override { return num_time_frames * num_image_data_types; }
224 };
225 
232 {
233 public:
235 
236 protected:
238  bool post_processing() override;
239 
240 public:
241  std::vector<int> segment_sequence;
242  std::vector<int> min_ring_difference;
243  std::vector<int> max_ring_difference;
244  std::vector<int> num_rings_per_segment;
245  std::vector<int> timing_poss_sequence;
246 
247  std::vector<std::string> applied_corrections;
248 
249  // derived values
250  int num_timing_poss;
251  int num_segments;
252  int num_views;
253  int num_bins;
254  ProjDataFromStream::StorageOrder storage_order;
255  shared_ptr<ProjDataInfo> data_info_sptr;
256 
257 private:
258  void resize_segments_and_set();
259  int find_storage_order();
260 
261  // members that will be used to set Scanner
262  // TODO parsing should be moved to Scanner
263  int num_rings;
264  int num_detectors_per_ring;
265 
266  double transaxial_FOV_diameter_in_cm;
267  double inner_ring_diameter_in_cm;
268  double average_depth_of_interaction_in_cm;
269  double distance_between_rings_in_cm;
270  double default_bin_size_in_cm;
271  // this intrinsic tilt
272  double view_offset_in_degrees;
273  int max_num_non_arccorrected_bins;
274  int default_num_arccorrected_bins;
275 
276  int num_axial_blocks_per_bucket;
277  int num_transaxial_blocks_per_bucket;
278  int num_axial_crystals_per_block;
279  int num_transaxial_crystals_per_block;
280  int num_axial_crystals_per_singles_unit;
281  int num_transaxial_crystals_per_singles_unit;
282  int num_detector_layers;
284 
285  float energy_resolution;
287  float reference_energy;
288 
289  int max_num_timing_poss;
290  float size_of_timing_pos;
291  float timing_resolution;
292 
293  int tof_mash_factor;
294 
296 
297  std::string scanner_geometry;
298  float axial_distance_between_crystals_in_cm;
299  float transaxial_distance_between_crystals_in_cm;
300  float axial_distance_between_blocks_in_cm;
301  float transaxial_distance_between_blocks_in_cm;
303 
305 
306  std::string crystal_map;
308  // end scanner parameters
309 
310  double effective_central_bin_size_in_cm;
311  bool is_arccorrected;
312 };
313 
314 END_NAMESPACE_STIR
315 
316 #endif // __stir_INTERFILEHEADER_H__
This file declares the stir::ByteOrder class.
A simple structure to hold 2 strings (date and time)
Definition: date_time_functions.h:72
This file declares the class stir::ExamInfo.
a class for Interfile keywords (and parsing) specific to projection data (i.e. ProjDataFromStream) ...
Definition: InterfileHeader.h:231
A class to parse Interfile headers.
Definition: KeyParser.h:161
Declaration of class stir::KeyParser.
std::vector< float > upper_en_window_thresholds
upper_en_window_thresholds
Definition: InterfileHeader.h:186
Declaration of class stir::ProjDataFromStream.
NumericType type_of_numbers
This will be determined from number_format_index and bytes_per_pixel.
Definition: InterfileHeader.h:165
This class provides member functions to find out what byte-order your machine is and to swap numbers...
Definition: ByteOrder.h:99
Functions for date-time conversions.
This file declares the class stir::NumericInfo.
int get_num_datasets() const override
Get the number of datasets.
Definition: InterfileHeader.h:223
std::vector< float > lower_en_window_thresholds
lower_en_window_thresholds
Definition: InterfileHeader.h:181
static const double double_value_not_set
A value that can be used to signify that a variable has not been set during parsing.
Definition: InterfileHeader.h:53
virtual int get_num_datasets() const
Get the number of datasets.
Definition: InterfileHeader.h:146
a class for Interfile keywords (and parsing) specific to images
Definition: InterfileHeader.h:201
a class for Interfile keywords (and parsing) common to all types of data
Definition: InterfileHeader.h:94
provides names for some numeric types and methods for finding their properties.
Definition: NumericType.h:54
std::string isotope_name
Definition: InterfileHeader.h:125
a class for storing information about 1 exam (or scan)
Definition: ExamInfo.h:41
ByteOrder file_byte_order
This will be determined from byte_order_index, or just keep its default value;.
Definition: InterfileHeader.h:167
a minimal class for Interfile keywords (and parsing) common to all types of data
Definition: InterfileHeader.h:49