STIR  6.2.0
interfile.h
Go to the documentation of this file.
1 //
2 //
3 #ifndef __stir_Interfile_h__
4 #define __stir_Interfile_h__
5 
6 /*
7  Copyright (C) 2000 PARAPET partners
8  Copyright (C) 2000- 2011, Hammersmith Imanet Ltd
9  Copyright (C) 2018, University College London
10  This file is part of STIR.
11  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
12 
13  See STIR/LICENSE.txt for details
14 */
28 #include "stir/NumericType.h"
29 // note that I had to include Succeeded.h instead of just forward
30 // declaring the class. Otherwise every file that used write_*interfile*
31 // has to include Succeeded.h (even if it doesn't use the return value).
32 #include "stir/Succeeded.h"
33 #include "stir/ByteOrder.h"
34 #include <iostream>
35 #include <string>
36 
37 START_NAMESPACE_STIR
38 
39 template <int num_dimensions>
40 class IndexRange;
41 template <int num_dimensions, typename elemT>
42 class Array;
43 template <int num_dimensions, typename elemT>
44 class DiscretisedDensity;
45 template <typename elemT>
46 class VectorWithOffset;
47 template <typename elemT>
48 class CartesianCoordinate3D;
49 template <typename elemT>
50 class Coordinate3D;
51 template <typename elemT>
52 class VoxelsOnCartesianGrid;
53 class ProjDataFromStream;
54 class DynamicDiscretisedDensity;
55 template <typename elemT>
56 class ParametricDiscretisedDensity;
57 template <typename elemT>
58 class VoxelsOnCartesianGrid;
59 template <int num_dimensions, typename elemT>
60 class KineticParameters;
61 
62 class ExamInfo;
63 
65 
78 bool is_interfile_signature(const char* const signature);
79 
81 
92 VoxelsOnCartesianGrid<float>* read_interfile_image(std::istream& input, const std::string& directory_for_data = "");
93 
95 
104 VoxelsOnCartesianGrid<float>* read_interfile_image(const std::string& filename);
105 
107 DynamicDiscretisedDensity* read_interfile_dynamic_image(std::istream& input, const std::string& directory_for_data);
108 
110 DynamicDiscretisedDensity* read_interfile_dynamic_image(const std::string& filename);
111 
113 ParametricDiscretisedDensity<VoxelsOnCartesianGrid<KineticParameters<2, float>>>*
114 read_interfile_parametric_image(std::istream& input, const std::string& directory_for_data);
115 
117 ParametricDiscretisedDensity<VoxelsOnCartesianGrid<KineticParameters<2, float>>>*
118 read_interfile_parametric_image(const std::string& filename);
119 
121 
139 Succeeded write_basic_interfile_image_header(const std::string& header_file_name,
140  const std::string& image_file_name,
141  const ExamInfo& exam_info,
142  const IndexRange<3>& index_range,
143  const CartesianCoordinate3D<float>& voxel_size,
144  const CartesianCoordinate3D<float>& origin,
145  const NumericType output_type,
146  const ByteOrder byte_order,
147  const VectorWithOffset<float>& scaling_factors,
148  const VectorWithOffset<unsigned long>& file_offsets,
149  const std::vector<std::string>& data_type_descriptions = std::vector<std::string>());
150 
152 
155 const VectorWithOffset<unsigned long> compute_file_offsets(int number_of_time_frames,
156  const NumericType output_type,
157  const Coordinate3D<int>& dim,
158  unsigned long initial_offset = 0);
159 
161 
167 template <class elemT>
168 Succeeded write_basic_interfile(const std::string& filename,
169  const Array<3, elemT>& image,
170  const CartesianCoordinate3D<float>& voxel_size,
171  const CartesianCoordinate3D<float>& origin,
172  const NumericType output_type = NumericType::FLOAT,
173  const float scale = 0,
174  const ByteOrder byte_order = ByteOrder::native);
175 
177 
183 template <class elemT>
184 Succeeded write_basic_interfile(const std::string& filename,
185  const ExamInfo& exam_info,
186  const Array<3, elemT>& image,
187  const CartesianCoordinate3D<float>& voxel_size,
188  const CartesianCoordinate3D<float>& origin,
189  const NumericType output_type = NumericType::FLOAT,
190  const float scale = 0,
191  const ByteOrder byte_order = ByteOrder::native);
192 
194 
204 template <class elemT>
205 Succeeded write_basic_interfile(const std::string& filename,
206  const Array<3, elemT>& image,
207  const NumericType output_type = NumericType::FLOAT,
208  const float scale = 0,
209  const ByteOrder byte_order = ByteOrder::native);
210 
212 
217 Succeeded write_basic_interfile(const std::string& filename,
218  const VoxelsOnCartesianGrid<float>& image,
219  const NumericType output_type = NumericType::FLOAT,
220  const float scale = 0,
221  const ByteOrder byte_order = ByteOrder::native);
222 
224 
232 Succeeded write_basic_interfile(const std::string& filename,
233  const DiscretisedDensity<3, float>& image,
234  const NumericType output_type = NumericType::FLOAT,
235  const float scale = 0,
236  const ByteOrder byte_order = ByteOrder::native);
237 
238 Succeeded write_basic_interfile(const std::string& filename,
239  const ParametricDiscretisedDensity<VoxelsOnCartesianGrid<KineticParameters<2, float>>>& image,
240  const NumericType output_type = NumericType::FLOAT,
241  const float scale = 0,
242  const ByteOrder byte_order = ByteOrder::native);
243 
244 Succeeded write_basic_interfile(const std::string& filename,
245  const DynamicDiscretisedDensity& image,
246  const NumericType output_type = NumericType::FLOAT,
247  const float scale = 0,
248  const ByteOrder byte_order = ByteOrder::native);
249 
251 
265 ProjDataFromStream* read_interfile_PDFS(std::istream& input,
266  const std::string& directory_for_data = "",
267  const std::ios::openmode openmode = std::ios::in);
268 
270 
279 ProjDataFromStream* read_interfile_PDFS(const std::string& filename, const std::ios::openmode open_mode);
280 
282 
287 Succeeded write_basic_interfile_PDFS_header(const std::string& header_filename,
288  const std::string& data_filename,
289  const ProjDataFromStream& pdfs);
290 
292 
298 Succeeded write_basic_interfile_PDFS_header(const std::string& data_filename, const ProjDataFromStream& pdfs);
299 
300 END_NAMESPACE_STIR
301 
302 #endif // __Interfile_h__
This file declares the stir::ByteOrder class.
bool is_interfile_signature(const char *const signature)
Checks if the signature corresponds to the start of an interfile header.
Definition: interfile.cxx:75
Declaration of class stir::Succeeded.
ParametricDiscretisedDensity< VoxelsOnCartesianGrid< KineticParameters< 2, float > > > * read_interfile_parametric_image(const std::string &filename)
Read parametric image.
Definition: interfile.cxx:311
Succeeded write_basic_interfile(const std::string &filename, const Array< 3, elemT > &image, const CartesianCoordinate3D< float > &voxel_size, const CartesianCoordinate3D< float > &origin, const NumericType output_type=NumericType::FLOAT, const float scale=0, const ByteOrder byte_order=ByteOrder::native)
This outputs an Interfile header and data for a Array<3,elemT> object.
VoxelsOnCartesianGrid< float > * read_interfile_image(const std::string &filename)
This reads the first 3d image in an Interfile header file, given as a filename.
Definition: interfile.cxx:281
DynamicDiscretisedDensity * read_interfile_dynamic_image(const std::string &filename)
Read dynamic image.
Definition: interfile.cxx:296
const VectorWithOffset< unsigned long > compute_file_offsets(int number_of_time_frames, const NumericType output_type, const Coordinate3D< int > &dim, unsigned long initial_offset=0)
a utility function that computes the file offsets of subsequent images
Succeeded write_basic_interfile_PDFS_header(const std::string &data_filename, const ProjDataFromStream &pdfs)
This function writes an Interfile header for the pdfs object.
Definition: interfile.cxx:1446
ProjDataFromStream * read_interfile_PDFS(const std::string &filename, const std::ios::openmode open_mode)
This reads the first 3D sinogram from an Interfile header, given as a filename.
Succeeded write_basic_interfile_image_header(const std::string &header_file_name, const std::string &image_file_name, const ExamInfo &exam_info, const IndexRange< 3 > &index_range, const CartesianCoordinate3D< float > &voxel_size, const CartesianCoordinate3D< float > &origin, const NumericType output_type, const ByteOrder byte_order, const VectorWithOffset< float > &scaling_factors, const VectorWithOffset< unsigned long > &file_offsets, const std::vector< std::string > &data_type_descriptions=std::vector< std::string >())
This outputs an Interfile header for an image.
Definition: interfile.cxx:512
This file declares the stir::NumericType class.