STIR  6.2.0
ParametricDiscretisedDensity.h
Go to the documentation of this file.
1 //
2 //
3 #ifndef __stir_modelling_ParametricDiscretisedDensity_H__
4 #define __stir_modelling_ParametricDiscretisedDensity_H__
5 /*
6  Copyright (C) 2006 - 2011, Hammersmith Imanet Ltd
7  Copyright (C) 2019 - 2020, University College London
8  This file is part of STIR.
9 
10  SPDX-License-Identifier: Apache-2.0
11 
12  See STIR/LICENSE.txt for details
13 */
24 #include "stir/NestedIterator.h"
25 // for ParametricVoxelsOnCartesianGrid typedef
28 START_NAMESPACE_STIR
29 template <typename DiscDensT>
30 class ParametricDiscretisedDensity;
31 
33 class DynamicDiscretisedDensity;
34 
36 template <typename DiscDensT>
38 
39 template <typename DiscDensT>
41 {
42  typedef typename Parametric2Single<DiscDensT>::type type;
43 };
44 
45 template <int num_parameters, typename elemT>
46 struct Parametric2Single<VoxelsOnCartesianGrid<KineticParameters<num_parameters, elemT>>>
47 {
48  typedef VoxelsOnCartesianGrid<elemT> type;
49 };
50 
52 
63 template <typename DiscDensT>
64 class ParametricDiscretisedDensity : public DiscDensT
65 {
66 private:
67  // typedef DiscretisedDensity<num_dimensions, KinParsT> base_type;
68  typedef DiscDensT base_type;
69 
70 public:
72 
77 
78  typedef typename Parametric2Single<DiscDensT>::type SingleDiscretisedDensityType;
79 
80  typedef typename base_type::full_iterator full_densel_iterator;
81  typedef typename base_type::const_full_iterator const_full_densel_iterator;
82 
85 
87  static ParametricDiscretisedDensity* read_from_file(const std::string& filename);
88 
90  static unsigned int get_num_params();
91 
92  ParametricDiscretisedDensity(const base_type& density)
93  : base_type(density)
94  {}
95 
97 
99 
101 
102  ParametricDiscretisedDensity(const SingleDiscretisedDensityType& im);
103 
104  // implementation works, although only for VoxelsOnCartesianGrid , but not needed for now
105  // ParametricDiscretisedDensity(const VectorWithOffset<shared_ptr<SingleDiscretisedDensityType> > & densities);
106 
107  // implementation works, but not needed for now
108  // void update_parametric_image(const VectorWithOffset<shared_ptr<SingleDiscretisedDensityType> > & densities);
109 
110  void update_parametric_image(const SingleDiscretisedDensityType& single_density, const unsigned int param_num);
111 
112  full_iterator begin_all() { return full_iterator(base_type::begin_all(), base_type::end_all()); }
113 
114  const_full_iterator begin_all_const() const
115  {
116  return const_full_iterator(base_type::begin_all_const(), base_type::end_all_const());
117  }
118 
119  full_iterator end_all() { return full_iterator(base_type::end_all(), base_type::end_all()); }
120 
121  const_full_iterator end_all_const() const
122  {
123  return const_full_iterator(base_type::end_all_const(), base_type::end_all_const());
124  }
125 
126  const_full_iterator begin_all() const { return this->begin_all_const(); }
127 
128  const_full_iterator end_all() const { return this->end_all_const(); }
129 
130  full_densel_iterator begin_all_densel() { return base_type::begin_all(); }
131 
132  const_full_densel_iterator begin_all_densel_const() const { return base_type::begin_all_const(); }
133 
134  full_densel_iterator end_all_densel() { return base_type::end_all(); }
135 
136  const_full_densel_iterator end_all_densel_const() const { return base_type::end_all_const(); }
137 
138  const_full_densel_iterator begin_all_densel() const { return this->begin_all_densel_const(); }
139 
140  const_full_densel_iterator end_all_densel() const { return this->end_all_densel_const(); }
141 
143  ParametricDiscretisedDensity* get_empty_copy() const override;
144 
146  ParametricDiscretisedDensity* clone() const override;
147 
149  template <class KPFunctionObject>
150  void construct_single_density_using_function(SingleDiscretisedDensityType& density, KPFunctionObject f) const;
151 
152  template <class KPFunctionObject>
153  const SingleDiscretisedDensityType construct_single_density_using_function(KPFunctionObject f) const;
154 
156 
157  void construct_single_density(SingleDiscretisedDensityType& density, const int i) const;
158 
159  const SingleDiscretisedDensityType construct_single_density(const int index) const;
160 #if 0
161  // can't be done really
162  SingleDiscretisedDensityType &
163  construct_single_density(const int index);
164 #endif
165 
166 };
167 
170 
173 
174 END_NAMESPACE_STIR
175 //#include "stir/modelling/ParametricDiscretisedDensity.inl"
176 
177 #endif //__stir_modelling_ParametricDiscretisedDensity_H__
This class is used to represent voxelised densities on a cuboid grid (3D).
Definition: FBP3DRPReconstruction.h:43
ParametricDiscretisedDensity hierarchy_base_type
A typedef that can be used what the base of the hierarchy is.
Definition: ParametricDiscretisedDensity.h:76
Class to store parametric images.
Definition: ECAT7ParametricDensityOutputFileFormat.h:36
defines the stir::DiscretisedDensity class
Class NestedIterator implements a (forward) iterator using a pair of &#39;nested&#39; iterators.
Definition: NestedIterator.h:93
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
Class of multiple image frames, one for each time frame Each time frame is a DiscretisedDensity<3,float>
Definition: DynamicDiscretisedDensity.h:45
A helper class to find the type of a &#39;single&#39; image for a corresponding parametric image...
Definition: ParametricDiscretisedDensity.h:37
VoxelsOnCartesianGrid< KineticParameters< 2, float > > ParametricVoxelsOnCartesianGridBaseType
Convenience typedef for base-type of Cartesian Voxelised Parametric Images with just two parameters...
Definition: ParametricDiscretisedDensity.h:169
defines the stir::VoxelsOnCartesianGrid class
Declaration of class stir::KineticParameters.
This file declares the stir::NestedIterator class and supporting function objects.
ParametricDiscretisedDensity< ParametricVoxelsOnCartesianGridBaseType > ParametricVoxelsOnCartesianGrid
Convenience typedef for Cartesian Voxelised Parametric Images with just two parameters.
Definition: ParametricDiscretisedDensity.h:172