STIR 6.5.0
CListModeDataPETSIRD.h
1/*
2
3 Copyright 2025, 2026, University Medical Center Groningen
4 Copyright 2025, MGH / HST A. Martinos Center for Biomedical Imaging
5
6 SPDX-License-Identifier: Apache-2.0
7 See STIR/LICENSE.txt for details.
8
9 */
10
11#ifndef __stir_listmode_CListModeDataPETSIRD_H__
12#define __stir_listmode_CListModeDataPETSIRD_H__
13
17#include "stir/Succeeded.h"
18#include "petsird_helpers.h"
19#include "stir/PETSIRDInfo.h"
20#include "petsird/binary/protocols.h"
21#include "petsird/hdf5/protocols.h"
22
23START_NAMESPACE_STIR
24
64class CListModeDataPETSIRD : public CListModeDataBasedOnCoordinateMap
65{
66private:
68
74 struct PetsirdCursor
75 {
77
80 bool is_prompt = true;
82 std::size_t event_in_block = 0;
84 std::size_t time_block_index = 0;
86 petsird::TimeBlock time_block;
88 petsird::EventTimeBlock event_block;
90 bool has_cached_blocks = false;
91 };
92
93public:
99 CListModeDataPETSIRD(const std::string& listmode_filename, bool use_hdf5);
100
101 virtual shared_ptr<CListRecord> get_empty_record_sptr() const override;
102
103 Succeeded get_next_record(CListRecord& record_of_general_type) const override;
104
106
108
110 void reopen_and_prime();
111
112 Succeeded seek_to_event_block_index(std::size_t target_event_block_index) const;
113
114 Succeeded set_get_position(const SavedPosition& pos) override;
115
116 virtual bool has_delayeds() const override { return m_has_delayeds; }
117
118 Succeeded reset() override;
119 // expose singles for dead time correction
120 const std::vector<float>& get_singles_per_bucket() const { return singles_per_bucket; }
121 double get_singles_time_start() const { return singles_time_start; }
122 double get_singles_time_stop() const { return singles_time_stop; }
123
124protected:
125 virtual Succeeded open_lm_file() const override;
126
127 shared_ptr<petsird::PETSIRDReaderBase> current_lm_data_ptr;
128
129private:
131 const bool use_hdf5;
133 mutable unsigned long int curr_event_in_event_block = 0;
135 mutable petsird::TimeBlock curr_time_block;
137 mutable petsird::EventTimeBlock curr_event_block;
140 mutable bool curr_is_prompt = true;
142 mutable bool m_has_delayeds;
144 shared_ptr<const PETSIRDInfo> petsird_info_sptr;
146 mutable PetsirdCursor m_saved_cursor;
148 mutable std::size_t m_time_block_index = 0;
150
155 mutable std::vector<PetsirdCursor> m_saved_positions;
156 // accumulated singles per bucket from SinglesHistogramTimeBlock entries
157 mutable std::vector<float> singles_per_bucket;
158 mutable double singles_time_start = 0.0;
159 mutable double singles_time_stop = 0.0;
160};
161
162END_NAMESPACE_STIR
163#endif // CLISTMODEDATAPETSIRD_H
Declaration of class stir::CListModeDataBasedOnCoordinateMap.
Declaration of class stir::CListEventPETSIRD and stir::CListRecordPETSIRD with supporting classes.
Declarations of classes stir::CListRecord, and stir::CListEvent which are used for list mode data.
Declaration of class stir::PETSIRDInfo.
Declaration of class stir::Succeeded.
CListModeDataPETSIRD(const std::string &listmode_filename, bool use_hdf5)
Construct reader.
Definition CListModeDataPETSIRD.cxx:25
virtual shared_ptr< CListRecord > get_empty_record_sptr() const override
Get a pointer to an empty record.
Definition CListModeDataPETSIRD.cxx:81
virtual bool has_delayeds() const override
Return if the file stores delayed events as well (as opposed to prompts).
Definition CListModeDataPETSIRD.h:116
void reopen_and_prime()
Reopens the underlying reader and primes it at the first event block.
Definition CListModeDataPETSIRD.cxx:190
Succeeded set_get_position(const SavedPosition &pos) override
Set the position for reading to a previously saved point.
Definition CListModeDataPETSIRD.cxx:235
Succeeded get_next_record(CListRecord &record_of_general_type) const override
Gets the next record in the listmode sequence.
Definition CListModeDataPETSIRD.cxx:88
SavedPosition save_get_position() override
Save the current reading position.
Definition CListModeDataPETSIRD.cxx:173
Class for records in a PET list mode file.
Definition CListRecord.h:68
unsigned int SavedPosition
Use this typedef for save/set_get_position.
Definition ListModeData.h:129
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44