STIR 6.4.0
ECAT7ImageInputFileFormat.h
Go to the documentation of this file.
1//
2//
3#ifndef __stir_IO_ECAT7ImageInputFileFormat_h__
4#define __stir_IO_ECAT7ImageInputFileFormat_h__
5/*
6 Copyright (C) 2006- 2013, Hammersmith Imanet Ltd
7 This file is part of STIR.
8 SPDX-License-Identifier: Apache-2.0
9
10 See STIR/LICENSE.txt for details
11*/
22#include "stir/utilities.h"
24#include "stir/error.h"
25#include <fstream>
26#include <string>
27
28#ifndef HAVE_LLN_MATRIX
29# error HAVE_LLN_MATRIX not define: you need the lln ecat library.
30#endif
31
32#include "stir/IO/stir_ecat7.h"
33START_NAMESPACE_STIR
34START_NAMESPACE_ECAT
35START_NAMESPACE_ECAT7
36
38
42class ECAT7ImageInputFileFormat : public InputFileFormat<DiscretisedDensity<3, float>>
43{
44public:
45 virtual const std::string get_name() const { return "ECAT7"; }
46
47protected:
48 virtual bool actual_can_read(const FileSignature& signature, std::istream& input) const
49 {
50 if (strncmp(signature.get_signature(), "MATRIX", 6) != 0)
51 return false;
52
53 // TODO
54 // return (is_ECAT7_image_file(filename))
55 return true;
56 }
57
58 virtual unique_ptr<data_type> read_from_file(std::istream& input) const
59 {
60 // TODO
61 error("read_from_file for ECAT7 with istream not implemented %s:%d. Sorry", __FILE__, __LINE__);
62 return unique_ptr<data_type>();
63 }
64 virtual unique_ptr<data_type> read_from_file(const std::string& filename) const
65 {
66
67 if (is_ECAT7_image_file(filename))
68 {
69 warning("\nReading frame 1, gate 1, data 0, bed 0 from file %s\n", filename.c_str());
70 return unique_ptr<data_type>(ECAT7_to_VoxelsOnCartesianGrid(filename,
71 /*frame_num, gate_num, data_num, bed_num*/ 1,
72 1,
73 0,
74 0));
75 }
76 else
77 {
78 error("ECAT7 file %s is not an image file", filename.c_str());
79 return unique_ptr<data_type>();
80 }
81 }
82};
83
84END_NAMESPACE_ECAT
85END_NAMESPACE_ECAT7
86END_NAMESPACE_STIR
87
88#endif
Declaration of class stir::InputFileFormat.
defines the stir::VoxelsOnCartesianGrid class
A class to read/store the file signature.
Definition FileSignature.h:35
const char * get_signature() const
get access to the signature
Definition FileSignature.h:52
Base-class for file-formats for reading.
Definition InputFileFormat.h:40
Class for reading images in ECAT7 file-format.
Definition ECAT7ImageInputFileFormat.h:43
virtual unique_ptr< data_type > read_from_file(const std::string &filename) const
read data from a filename
Definition ECAT7ImageInputFileFormat.h:64
virtual unique_ptr< data_type > read_from_file(std::istream &input) const
read data from a stream
Definition ECAT7ImageInputFileFormat.h:58
Declaration of stir::error()
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
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition error.cxx:42
void warning(const char *const s,...)
Print warning with format string a la printf.
Definition warning.cxx:41
Declaration of routines which convert CTI things into our building blocks and vice versa.
This file declares various utility functions.