STIR 6.4.0
ECAT962ListmodeInputFileFormat.h
Go to the documentation of this file.
1//
2//
3#ifndef __stir_IO_ECAT962ListmodeInputFileFormat_h__
4#define __stir_IO_ECAT962ListmodeInputFileFormat_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*/
24
25#include "stir/error.h"
26#include "stir/utilities.h"
27#include <string>
28
29#ifndef HAVE_LLN_MATRIX
30# error HAVE_LLN_MATRIX not define: you need the lln ecat library.
31#endif
32
33#include "stir/IO/stir_ecat7.h"
34START_NAMESPACE_STIR
35START_NAMESPACE_ECAT
36START_NAMESPACE_ECAT7
37
39
43{
44public:
45 virtual const std::string get_name() const { return "ECAT962"; }
46
47 virtual bool can_read(const FileSignature& signature, std::istream& input) const
48 {
49 return this->actual_can_read(signature, input);
50 }
51 virtual bool can_read(const FileSignature& signature, const std::string& listmode_filename_prefix) const
52 {
53 const std::string singles_filename = listmode_filename_prefix + "_1.sgl";
54 std::ifstream singles_file(singles_filename.c_str(), std::ios::binary);
55 char buffer[sizeof(Main_header)];
56 Main_header singles_main_header;
57 singles_file.read(buffer, sizeof(singles_main_header));
58 if (!singles_file)
59 return false;
60 unmap_main_header(buffer, &singles_main_header);
61 shared_ptr<Scanner> scanner_sptr;
62 ecat::ecat7::find_scanner(scanner_sptr, singles_main_header);
63 if (scanner_sptr->get_type() == Scanner::E962)
64 return false;
65
66 return true;
67 }
68
69protected:
70 virtual bool actual_can_read(const FileSignature& signature, std::istream& input) const
71 {
72 warning("can_read for ECAT962 listmode data with istream not implemented %s:%d. Sorry", __FILE__, __LINE__);
73 return false;
74
75 if (strncmp(signature.get_signature(), "MATRIX", 6) != 0)
76 return false;
77
78 // TODO
79 // return (is_ECAT7_image_file(filename))
80 return true;
81 }
82
83public:
84 virtual unique_ptr<data_type> read_from_file(std::istream& input) const
85 {
86 // cannot do this as need both .sgl and .lm
87 error("read_from_file for ECAT962 listmode data with istream not implemented %s:%d. Sorry", __FILE__, __LINE__);
88 return unique_ptr<data_type>();
89 }
90 virtual unique_ptr<data_type> read_from_file(const std::string& filename) const
91 {
92 return unique_ptr<data_type>(new ecat::ecat7::CListModeDataECAT<ecat::ecat7::CListRecordECAT962>(filename));
93 }
94};
95
96END_NAMESPACE_ECAT
97END_NAMESPACE_ECAT7
98END_NAMESPACE_STIR
99
100#endif
Declaration of class stir::CListModeDataECAT.
Classes for listmode events for the ECAT 962 (aka Exact HR+)
Declaration of class stir::InputFileFormat.
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
A class that reads the listmode data for ECAT scanners.
Definition CListModeDataECAT.h:49
Class for reading list mode data from the ECAT 962 scanner.
Definition ECAT962ListmodeInputFileFormat.h:43
virtual unique_ptr< data_type > read_from_file(const std::string &filename) const
read data from a filename
Definition ECAT962ListmodeInputFileFormat.h:90
virtual unique_ptr< data_type > read_from_file(std::istream &input) const
read data from a stream
Definition ECAT962ListmodeInputFileFormat.h:84
Declaration of stir::error()
void find_scanner(shared_ptr< Scanner > &scanner_ptr, const Main_header &mhead)
determine scanner type from the main_header
Definition stir_ecat7.cxx:184
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.