STIR  6.2.0
GatedDiscretisedDensity.h
Go to the documentation of this file.
1 //
2 /*
3  Copyright (C) 2005- 2009, Hammersmith Imanet Ltd
4  Copyright (C) 2009- 2013, King's College London
5  This file is part of STIR.
6 
7  SPDX-License-Identifier: Apache-2.0
8 
9  See STIR/LICENSE.txt for details
10  */
18 #ifndef __stir_GatedDiscretisedDensity_H__
19 #define __stir_GatedDiscretisedDensity_H__
20 
22 #include "stir/shared_ptr.h"
24 #include <vector>
25 #include <string>
26 
27 START_NAMESPACE_STIR
28 
29 class Succeeded;
30 
35 {
36 public:
37  static GatedDiscretisedDensity* read_from_file(const std::string& filename);
38 
39  static GatedDiscretisedDensity* read_from_files(const std::string& filename);
40 
41  static GatedDiscretisedDensity* read_from_files(const std::string& filename, const std::string& suffix);
42 
44 
46  GatedDiscretisedDensity(const std::string& filename);
47 
48  GatedDiscretisedDensity(const TimeGateDefinitions& time_gate_definitions)
49  {
50  _densities.resize(time_gate_definitions.get_num_gates());
51  _time_gate_definitions = time_gate_definitions;
52  }
53 
54  GatedDiscretisedDensity(const shared_ptr<DiscretisedDensity<3, float>>& density_sptr, const unsigned int num_gates);
55 
57  GatedDiscretisedDensity(const TimeGateDefinitions& time_gate_definitions,
58  const shared_ptr<DiscretisedDensity<3, float>>& density_sptr)
59  {
60  _densities.resize(time_gate_definitions.get_num_gates());
61  _time_gate_definitions = time_gate_definitions;
62 
63  for (unsigned int gate_num = 0; gate_num < time_gate_definitions.get_num_gates(); ++gate_num)
64  this->_densities[gate_num].reset(density_sptr->get_empty_discretised_density());
65  }
66 
67 #if 0
70  {
71  _densities.resize(gated_density.get_num_gates());
72  _time_gate_definitions=gated_density.get_time_gate_definitions();
73  for (unsigned int gate_num=0; gate_num<time_gate_definitions.get_num_gates(); ++gate_num)
74  this->_densities[gate_num] = (gated_density.get_densities[0])->get_empty_discretised_density();
75  }
76 #endif
77 
78  GatedDiscretisedDensity& operator=(const GatedDiscretisedDensity& argument);
79 
87  void set_density_sptr(const shared_ptr<DiscretisedDensity<3, float>>& density_sptr, const unsigned int gate_num);
88 
89  void resize_densities(const TimeGateDefinitions& time_gate_definitions)
90  {
91  _densities.resize(time_gate_definitions.get_num_gates());
92  _time_gate_definitions = time_gate_definitions;
93  }
94 
95  /*
96  GatedDiscretisedDensity( TimeGateDefinitions time_gate_defintions,
97  std::vector<shared_ptr<DiscretiseDensity<3,float> > _densities);
98  */
99 
100  const std::vector<shared_ptr<DiscretisedDensity<3, float>>>& get_densities() const;
101 
102  const DiscretisedDensity<3, float>& get_density(const unsigned int gate_num) const;
103 
104  const DiscretisedDensity<3, float>& operator[](const unsigned int gate_num) const
105  {
106  return this->get_density(gate_num);
107  }
108 
109  DiscretisedDensity<3, float>& get_density(const unsigned int gate_num);
110 
111  DiscretisedDensity<3, float>& operator[](const unsigned int gate_num)
112  {
113  return this->get_density(gate_num);
114  }
116 
117  void set_time_gate_definitions(TimeGateDefinitions time_gate_definitions)
118  {
119  this->_time_gate_definitions = time_gate_definitions;
120  }
121 
122  const TimeGateDefinitions& get_time_gate_definitions() const;
123 
124  unsigned get_num_gates() const
125  {
126  return this->get_time_gate_definitions().get_num_time_gates();
127  }
128  void fill_with_zero();
129 
134  Succeeded write_to_files(const std::string& filename) const;
135  Succeeded write_to_files(const std::string& filename, const std::string& suffix) const;
136 
137 private:
138  // warning: if adding any new members, you have to change the copy constructor as well.
139  TimeGateDefinitions _time_gate_definitions;
140  std::vector<shared_ptr<DiscretisedDensity<3, float>>> _densities;
141 };
142 
143 END_NAMESPACE_STIR
144 
145 #endif //__stir_GatedDiscretisedDensity_H__
GatedDiscretisedDensity(const TimeGateDefinitions &time_gate_definitions, const shared_ptr< DiscretisedDensity< 3, float >> &density_sptr)
Construct an empty GatedDiscretisedDensity based on a shared_ptr<DiscretisedDensity<3,float> >
Definition: GatedDiscretisedDensity.h:57
Declaration of class stir::TimeGateDefinitions.
unsigned int get_num_time_gates() const
Get number of gates.
Definition: TimeGateDefinitions.cxx:54
Import of std::shared_ptr, std::dynamic_pointer_cast and std::static_pointer_cast (or corresponding b...
defines the stir::DiscretisedDensity class
unique_ptr< DataT > read_from_file(const FileSignature &signature, FileT file)
Function that reads data from file using the default InputFileFormatRegistry, using the provided File...
Definition: read_from_file.h:46
unsigned int get_num_gates() const
Get number of gates.
Definition: TimeGateDefinitions.cxx:48
Class used for storing time gate durations.
Definition: TimeGateDefinitions.h:42
Class of multiple image gates.
Definition: GatedDiscretisedDensity.h:34
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition: Succeeded.h:43