STIR  6.2.0
stir_ecat7.h
Go to the documentation of this file.
1 
12 /*
13  Copyright (C) 2000 PARAPET partners
14  Copyright (C) 2000 - 2011-12-31, Hammersmith Imanet Ltd
15  Copyright (C) 2013, University College London
16  This file is part of STIR.
17 
18  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
19 
20  See STIR/LICENSE.txt for details
21 */
22 
23 #ifndef __stir_IO_stir_ecat7_H__
24 #define __stir_IO_stir_ecat7_H__
25 
27 #include "stir/NumericType.h"
28 
29 #ifdef HAVE_LLN_MATRIX
30 # define CTISinogram ::Sinogram
31 
32 # include "matrix.h"
33 extern "C"
34 {
35  int map_main_header(char* bufr, Main_header* header);
36  int mh_update(MatrixFile*);
37 }
38 
39 # include <string>
40 # include <iostream>
41 # include "stir/shared_ptr.h"
42 
43 START_NAMESPACE_STIR
44 
45 class Succeeded;
46 class ByteOrder;
47 class Scanner;
48 template <int num_dimensions, typename elemT>
49 class DiscretisedDensity;
50 template <typename elemT>
51 class VoxelsOnCartesianGrid;
52 template <typename elemT>
53 class Sinogram;
54 class ExamInfo;
55 class ProjData;
56 class ProjDataInfo;
57 class ProjDataFromStream;
58 
59 START_NAMESPACE_ECAT
60 START_NAMESPACE_ECAT7
61 
74 bool is_ECAT7_file(const std::string& filename);
79 bool is_ECAT7_image_file(const std::string& filename);
85 bool is_ECAT7_emission_file(const std::string& filename);
91 bool is_ECAT7_attenuation_file(const std::string& filename);
92 
96 Succeeded read_ECAT7_main_header(Main_header& mhead, const std::string& filename);
97 
99 
102 void find_scanner(shared_ptr<Scanner>& scanner_ptr, const Main_header& mhead);
103 
105 
108 Succeeded DiscretisedDensity_to_ECAT7(DiscretisedDensity<3, float> const& density,
109  std::string const& cti_name,
110  std::string const& orig_name,
111  const Scanner& scanner,
112  const int frame_num = 1,
113  const int gate_num = 1,
114  const int data_num = 0,
115  const int bed_num = 0);
116 
118 
123 Succeeded DiscretisedDensity_to_ECAT7(MatrixFile* mptr,
124  DiscretisedDensity<3, float> const& density,
125  const int frame_num = 1,
126  const int gate_num = 1,
127  const int data_num = 0,
128  const int bed_num = 0);
129 
131 
136 Succeeded ProjData_to_ECAT7(ProjData const& proj_data,
137  NumericType output_type,
138  std::string const& cti_name,
139  std::string const& orig_name,
140  const int frame_num = 1,
141  const int gate_num = 1,
142  const int data_num = 0,
143  const int bed_num = 0,
144  const bool write_as_attenuation = false,
145  float scale_factor = 0.0F);
146 
148 
158 Succeeded ProjData_to_ECAT7(MatrixFile* mptr,
159  ProjData const& proj_data,
160  const int frame_num = 1,
161  const int gate_num = 1,
162  const int data_num = 0,
163  const int bed_num = 0,
164  float scale_factor = 0.0F);
165 
167 
168 shared_ptr<ExamInfo> read_ECAT7_exam_info(MatrixFile* mptr);
169 
171 
172 shared_ptr<ExamInfo> read_ECAT7_exam_info(const std::string& filename);
173 
175 
178 void make_ECAT7_main_header(Main_header&, const Scanner&, const std::string& orig_name, ExamInfo const& exam_info);
179 
181 
184 void make_ECAT7_main_header(Main_header& mhead,
185  Scanner const& scanner,
186  const std::string& orig_name,
187  DiscretisedDensity<3, float> const& density);
188 
190 
207 NumericType make_ECAT7_main_header(Main_header& mhead,
208  const std::string& orig_name,
209  ExamInfo const& exam_info,
210  ProjDataInfo const& proj_data_info,
211  const bool write_as_attenuation = false,
212  NumericType output_type = NumericType::FLOAT);
213 
215 
218 void make_subheader_for_ECAT7(Attn_subheader& shead, const Main_header& mhead, const ProjDataInfo& proj_data_info);
220 
223 void make_subheader_for_ECAT7(Scan3D_subheader& shead, const Main_header& mhead, const ProjDataInfo& proj_data_info);
224 
226 
239 ProjDataFromStream*
240 make_pdfs_from_matrix(MatrixFile* const mptr, MatrixData* const matrix, const shared_ptr<std::iostream>& stream_ptr);
241 
243 
252 Succeeded write_basic_interfile_header_for_ECAT7(std::string& interfile_header_name,
253  const std::string& ECAT7_filename,
254  const int frame_num,
255  const int gate_num,
256  const int data_num,
257  const int bed_num);
258 
259 /*
260  \brief Read an image from an ECAT7 file.
261  \ingroup ECAT
262  \warning do not use directly, but use read_from_file<DiscretisedDensity<3,float> >().
263 
264  \return a pointer to a newly allocated image, or 0 if it failed.
265 */
266 VoxelsOnCartesianGrid<float>* ECAT7_to_VoxelsOnCartesianGrid(
267  const std::string& ECAT7_filename, const int frame_num, const int gate_num, const int data_num, const int bed_num);
268 /*
269  \brief Read projection data from an ECAT7 file
270  \ingroup ECAT
271  \warning do not use directly, but use ProjData::read_from_file().
272 
273  \return a pointer to a newly allocated ProjDataFromStream object, or 0 if it failed.
274 */
275 ProjDataFromStream*
276 ECAT7_to_PDFS(const std::string& ECAT7_filename, const int frame_num, const int gate_num, const int data_num, const int bed_num);
277 
278 END_NAMESPACE_ECAT7
279 END_NAMESPACE_ECAT
280 END_NAMESPACE_STIR
281 
282 #endif
283 
284 #endif
bool is_ECAT7_emission_file(const std::string &filename)
checks if the file is in ECAT6 format and if the file contains emission sinograms (or blank/transmisi...
Definition: stir_ecat7.cxx:168
void make_subheader_for_ECAT7(Scan3D_subheader &shead, const Main_header &mhead, const ProjDataInfo &proj_data_info)
Fill in most of the subheader.
Definition: stir_ecat7.cxx:1143
Succeeded DiscretisedDensity_to_ECAT7(MatrixFile *mptr, DiscretisedDensity< 3, float > const &density, const int frame_num=1, const int gate_num=1, const int data_num=0, const int bed_num=0)
Write an (extra) image to an existing ECAT7 file.
Definition: stir_ecat7.cxx:1780
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
bool is_ECAT7_attenuation_file(const std::string &filename)
checks if the file is in ECAT6 format and if the file contains attenuation correction factors ...
Definition: stir_ecat7.cxx:177
bool is_ECAT7_file(const std::string &filename)
checks if the file is in ECAT7 formatThis partly relies on the implementation of matrix_open in the L...
Definition: stir_ecat7.cxx:153
Succeeded read_ECAT7_main_header(Main_header &mhead, const std::string &filename)
read an ECAT7 main header from a file
Definition: stir_ecat7.cxx:111
Succeeded write_basic_interfile_header_for_ECAT7(std::string &interfile_header_name, const std::string &ECAT7_filename, const int frame_num, const int gate_num, const int data_num, const int bed_num)
Writes an Interfile header that &#39;points&#39; into an ECAT7 file.
Definition: stir_ecat7.cxx:1624
ProjDataFromStream * make_pdfs_from_matrix(MatrixFile *const mptr, MatrixData *const matrix, const shared_ptr< std::iostream > &stream_ptr)
Make a ProjDataFromStream object that &#39;points&#39; into an ECAT7 file.
Succeeded ProjData_to_ECAT7(MatrixFile *mptr, ProjData const &proj_data, const int frame_num=1, const int gate_num=1, const int data_num=0, const int bed_num=0, float scale_factor=0.0F)
Write an (extra) set of sinograms to an existing ECAT7 file.
Definition: stir_ecat7.cxx:2211
shared_ptr< ExamInfo > read_ECAT7_exam_info(const std::string &filename)
read ExamInfo from an ECAT7 file
Definition: stir_ecat7.cxx:582
NumericType make_ECAT7_main_header(Main_header &mhead, const std::string &orig_name, ExamInfo const &exam_info, ProjDataInfo const &proj_data_info, const bool write_as_attenuation=false, NumericType output_type=NumericType::FLOAT)
Fill in most of the main header given an orig_name and a proj_data_info.
Definition: stir_ecat7.cxx:793
void find_scanner(shared_ptr< Scanner > &scanner_ptr, const Main_header &mhead)
determine scanner type from the main_header
Definition: stir_ecat7.cxx:184
This file declares the stir::NumericType class.
bool is_ECAT7_image_file(const std::string &filename)
checks if the file is in ECAT6 format and if the file contains images
Definition: stir_ecat7.cxx:160
Declaration of routines which convert ECAT things into our building blocks and vice versa...