STIR 6.4.0
BloodFrameData.inl
1//
2//
3/*
4 Copyright (C) 2005 - 2007, Hammersmith Imanet Ltd
5 This file is part of STIR.
6
7 SPDX-License-Identifier: Apache-2.0
8
9 See STIR/LICENSE.txt for details
10
11 \file
12 \ingroup modelling
13
14 \brief Implementations of inline functions of class stir::BloodFrameData
15
16 \author Charalampos Tsoumpas
17
18*/
19#include "stir/warning.h"
20#include "stir/error.h"
22START_NAMESPACE_STIR
23
27
29// ChT::ToDO: Better to use iterators
30BloodFrameData::BloodFrameData(const std::vector<BloodFrame>& blood_plot)
31{
32 this->_blood_plot = blood_plot;
33}
34
38
40void
41BloodFrameData::read_blood_frame_data(const std::string input_string)
42{
43 std::ifstream data_stream(input_string.c_str());
44 if (!data_stream)
45 error("cannot read blood frame data from file.\n");
46 else
47 {
48 data_stream >> _num_frames;
49 while (true)
50 {
51 unsigned int frame_num = 0;
52 float blood_sample_radioactivity = 0.F;
53 data_stream >> frame_num;
54 data_stream >> blood_sample_radioactivity;
55 if (!data_stream)
56 break;
57 const BloodFrame current_sample(frame_num, blood_sample_radioactivity);
58 (this->_blood_plot).push_back(current_sample);
59 }
60 }
61}
62
64/*
65void
66BloodFrameData::set_input_units( SamplingTimeUnits input_sampling_time_units,
67 VolumeUnits input_volume_units,
68 RadioactivityUnits input_radioactivity_units )
69{
70 _input_sampling_time_units=input_sampling_time_units ;
71 _input_volume_units=input_volume_units ;
72 _input_radioactivity_units=input_radioactivity_units ;
73}
74*/
76void
77BloodFrameData::shift_time(const float time_shift)
78{
79 _time_shift = time_shift;
80 for (std::vector<BloodFrame>::iterator cur_iter = this->_blood_plot.begin(); cur_iter != this->_blood_plot.end(); ++cur_iter)
81 {
82 cur_iter->set_frame_start_time_in_s(cur_iter->get_frame_start_time_in_s() + time_shift);
83 cur_iter->set_frame_end_time_in_s(cur_iter->get_frame_end_time_in_s() + time_shift);
84 }
85}
86
87float
89{
90 return BloodFrameData::_time_shift;
91}
92
93void
94BloodFrameData::set_isotope_halflife(const float isotope_halflife)
95{
96 _isotope_halflife = isotope_halflife;
97}
98
99void
100BloodFrameData::set_if_decay_corrected(const bool is_decay_corrected)
101{
102 this->_is_decay_corrected = is_decay_corrected;
103}
104
105bool
107{
108 return this->_is_decay_corrected;
109}
110
111void
113{
114 if (BloodFrameData::_is_decay_corrected == true)
115 warning("BloodFrameData are already decay corrected");
116 else
117 {
118 for (std::vector<BloodFrame>::iterator cur_iter = this->_blood_plot.begin(); cur_iter != this->_blood_plot.end();
119 ++cur_iter)
120 cur_iter->set_blood_counts_in_kBq(cur_iter->get_blood_counts_in_kBq()
121 * decay_correct_factor(_isotope_halflife,
122 cur_iter->get_frame_start_time_in_s(),
123 cur_iter->get_frame_end_time_in_s()));
125 }
126}
127
128void
129BloodFrameData::set_plot(const std::vector<BloodFrame>& blood_plot)
130{
131 this->_blood_plot = blood_plot;
132}
133
134// BloodFrameData begin() and end() of the BloodFrameData ;
135BloodFrameData::const_iterator
137{
138 return this->_blood_plot.begin();
139}
140
141BloodFrameData::const_iterator
142BloodFrameData::end() const
143{
144 return this->_blood_plot.end();
145}
146unsigned int
147BloodFrameData::size() const
148{
149 return this->_blood_plot.size();
150}
151
152/*
153//BloodFrameData begin() and end() of the BloodFrameData ;
154BloodFrameData::iterator
155BloodFrameData::begin()
156{ return this->_blood_plot.begin() ; } BloodFrameData::iterator BloodFrameData::end() { return this->_blood_plot.end() ; } */
157
158END_NAMESPACE_STIR
bool get_if_decay_corrected()
Function to set _is_decay_corrected boolean true ar false.
Definition BloodFrameData.inl:106
void read_blood_frame_data(const std::string input_string)
Implementation to read the input function from ONLY a 2-columns frame data (FrameNumber-InputFunction...
Definition BloodFrameData.inl:41
void set_isotope_halflife(const float isotope_halflife)
Function to set the isotope halflife.
Definition BloodFrameData.inl:94
float get_time_shift()
Function to get the time data.
Definition BloodFrameData.inl:88
~BloodFrameData()
default constructor
Definition BloodFrameData.inl:36
const_iterator begin() const
void begin() and end() iterators for the plasma curve ;
Definition BloodFrameData.inl:136
void set_if_decay_corrected(const bool is_decay_corrected)
Function to set _is_decay_corrected boolean true ar false.
Definition BloodFrameData.inl:100
BloodFrameData()
default constructor
Definition BloodFrameData.inl:25
void decay_correct_BloodFrameData()
Function to decay correct the data.
Definition BloodFrameData.inl:112
void shift_time(const float time_shift)
Implementation to set the input units not currently used. Always, it assumed to use kBq,...
Definition BloodFrameData.inl:77
Simple functions to compute the decay correction factor.
Declaration of stir::error()
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 stir::warning()