STIR 6.5.0
stir::SinglesRatesFromJSON Class Reference

A class that gets the singles rates of the singles units ("buckets") from a JSON file. More...

#include "stir/data/SinglesRatesFromJSON.h"

Inheritance diagram for stir::SinglesRatesFromJSON:

Public Member Functions

bool read_from_file (const std::string &filename)
 Reads the rates and the layout of the singles units from a JSON file.
float get_singles_rate (const DetectionPosition<> &det_pos, const double start_time, const double end_time) const override
 Singles rate of the singles unit that contains the detector.
Public Member Functions inherited from stir::RegisteredParsingObject< SinglesRatesFromJSON, SinglesRates, SinglesRatesForTimeFrames >
std::string get_registered_name () const override
 Returns Derived::registered_name.
std::string parameter_info () override
 Returns a string with all parameters and their values, in a form suitable for parsing again.
Public Member Functions inherited from stir::SinglesRatesForTimeFrames
 SinglesRatesForTimeFrames ()
 Default constructor.
float get_singles (int singles_bin_index, unsigned int frame_number) const
 get the singles for a particular singles unit and frame number.
float get_singles (const int singles_bin_index, const double start_time, const double end_time) const override
 get the singles for a particular singles unit and a frame with the specified start and end times.
FrameSinglesRates STIR_DEPRECATED get_rates_for_frame (double start_time, double end_time) const
 Generate a FramesSinglesRate - containing the average rates.
void set_singles (const int singles_bin_index, const unsigned time_frame_num, const float new_singles)
 Set a singles rate by singles bin index and time frame number.
unsigned int get_num_frames () const
 Get the number of frames for which singles rates are recorded.
const TimeFrameDefinitions & get_time_frame_definitions () const
 Get the time frame definitions.
virtual float get_singles (const DetectionPosition<> &det_pos, const double start_time, const double end_time) const
 Virtual function that returns the number of singles given the detection positions and time-interval of detection.
Public Member Functions inherited from stir::SinglesRates
virtual float get_singles_rate (const int singles_bin_index, const double start_time, const double end_time) const
 Get the (average) singles rate for a particular singles unit and a frame with the specified start and end times.
const Scanner * get_scanner_ptr () const
 Get the scanner pointer.
Public Member Functions inherited from stir::ParsingObject
 ParsingObject (const ParsingObject &)
ParsingObject & operator= (const ParsingObject &)
bool parse (std::istream &f)
bool parse (const char *const filename)
void ask_parameters ()

Static Public Attributes

static constexpr const char *const registered_name = "SinglesRatesFromJSON"
 Name which will be used when parsing a SinglesRatesFromJSON object.

Additional Inherited Members

Static Public Member Functions inherited from stir::RegisteredParsingObject< SinglesRatesFromJSON, SinglesRates, SinglesRatesForTimeFrames >
static SinglesRates * read_from_stream (std::istream *)
 Construct a new object (of type Derived) by parsing the istream.
Static Public Member Functions inherited from stir::RegisteredObject< SinglesRates >
static SinglesRates * read_registered_object (std::istream *in, const std::string &registered_name)
 Construct a new object (of a type derived from Root, its actual type determined by the registered_name parameter) by parsing the istream.
static SinglesRates * ask_type_and_parameters ()
 ask the user for the type, and then calls read_registered_object(0, type)
static void list_registered_names (std::ostream &stream)
 List all possible registered names to the stream.
Protected Types inherited from stir::RegisteredObject< SinglesRates >
typedef SinglesRates *(*) RootFactory(std::istream *)
 The type of a root factory is a function, taking an istream* as argument, and returning a Root*.
typedef FactoryRegistry< std::string, RootFactory, interfile_less > RegistryType
 The type of the registry.
virtual void set_key_values ()
 This will be called before parsing or parameter_info is called.
Static Protected Member Functions inherited from stir::RegisteredObject< SinglesRates >
static RegistryType & registry ()
 Static function returning the registry.
Protected Attributes inherited from stir::SinglesRatesForTimeFrames
Array< 2, float > _singles
TimeFrameDefinitions _time_frame_defs
Protected Attributes inherited from stir::SinglesRates
shared_ptr< Scanner > scanner_sptr
 Generate a FramesSinglesRate - containing the average rates.
KeyParser parser

Detailed Description

A class that gets the singles rates of the singles units ("buckets") from a JSON file.

The file needs the entries "interval_start" and "interval_end" (the times in seconds of each singles interval), "bucket_rates" (for each interval, an array with the singles rate of each singles unit), "num_axial_buckets", "num_transaxial_buckets", "num_rings" and "num_detectors_per_ring". Bucket i is at transaxial + num_transaxial_buckets * axial. This is what lm_to_projdata writes for list-mode data with singles records, for instance

{ "num_buckets": 224, "num_axial_buckets": 8, "num_transaxial_buckets": 28, "num_rings": 64,
"num_detectors_per_ring": 504, "interval_start": [0, 1.0], "interval_end": [1.0, 2.0],
"bucket_rates": [ [115378.4, 115102.2, ... ], [115280.1, 115015.7, ... ] ] }

get_singles_rate() averages the rates of the intervals that overlap the requested times, weighted by the overlap. The singles of a single interval are given by get_singles() with the start and end time of that interval.

In the parameter file, use

singles rates := SinglesRatesFromJSON
SinglesRatesFromJSON :=
filename := head2_f1_singles.json
End SinglesRatesFromJSON :=

Member Function Documentation

◆ read_from_file()

bool stir::SinglesRatesFromJSON::read_from_file ( const std::string & filename)

Reads the rates and the layout of the singles units from a JSON file.

Returns
false if the file cannot be read, an entry is missing, or the layout does not match the number of rates. Any rates read before are replaced.

References stir::error(), and read_from_file().

Referenced by read_from_file().

◆ get_singles_rate()

float stir::SinglesRatesFromJSON::get_singles_rate ( const DetectionPosition<> & det_pos,
const double start_time,
const double end_time ) const
overridevirtual

Singles rate of the singles unit that contains the detector.

Reimplemented from stir::SinglesRates.

References stir::SinglesRatesForTimeFrames::get_num_frames(), stir::SinglesRatesForTimeFrames::get_singles(), get_singles_rate(), and stir::sum().

Referenced by get_singles_rate().


The documentation for this class was generated from the following files: