STIR 6.4.0
KOSMAPOSLReconstruction.h
Go to the documentation of this file.
1//
2//
3/*
4
5 Copyright (C) 2018 Commonwealth Scientific and Industrial Research Organisation
6 Copyright (C) 2018-2019 University of Leeds
7 Copyright (C) 2019 University College of London
8 Copyright (C) 2019-2021 National Physical Laboratory
9
10 This file is part of STIR.
11
12 SPDX-License-Identifier: Apache-2.0
13
14 See STIR/LICENSE.txt for details
15*/
27
28#ifndef __stir_KOSMAPOSL_KOSMAPOSLReconstruction_h__
29# define __stir_KOSMAPOSL_KOSMAPOSLReconstruction_h__
30
35
36START_NAMESPACE_STIR
37
38template <typename TargetT>
39class PoissonLogLikelihoodWithLinearModelForMean;
40
114
115template <typename TargetT>
117 : public RegisteredParsingObject<KOSMAPOSLReconstruction<TargetT>, Reconstruction<TargetT>, OSMAPOSLReconstruction<TargetT>>
118{
119private:
121
122 base_type;
123
124public:
126 static const char* const registered_name;
127
134 explicit KOSMAPOSLReconstruction(const std::string& parameter_filename);
135
138
140 const KOSMAPOSLReconstruction& get_parameters() const { return *this; }
141
143 // kernel
144 const std::vector<std::string> get_anatomical_image_filenames() const;
145 const int get_num_neighbours() const;
146 const int get_num_non_zero_feat() const;
147 const std::vector<double> get_sigma_m() const;
148 const double get_sigma_p() const;
149 const double get_sigma_dp() const;
150 const double get_sigma_dm() const;
151 const bool get_only_2D() const;
152 const bool get_hybrid() const;
153 const int get_freeze_iterative_kernel_at_subiter_num() const;
154
155 std::vector<shared_ptr<TargetT>> get_anatomical_prior_sptrs();
157
165 void set_anatomical_prior_sptr(shared_ptr<TargetT>, int index);
167 void set_anatomical_prior_sptr(shared_ptr<TargetT> arg);
168 void set_anatomical_image_filename(const std::string&, const int index);
169 void set_anatomical_image_filename(const std::string&);
170
171 void set_num_neighbours(const int);
172 void set_num_non_zero_feat(const int);
173 void set_sigma_m(const double, const int index);
175 void set_sigma_m(const double);
176 void set_sigma_p(const double);
177 void set_sigma_dp(const double);
178 void set_sigma_dm(const double);
179 void set_only_2D(const bool);
180 void set_hybrid(const bool);
181 void set_freeze_iterative_kernel_at_subiter_num(const int);
183
185 void ask_parameters() override;
186
187protected:
189 std::string input_filename, kernelised_output_filename_prefix;
190 std::string current_kimage_filename;
191 std::string sens_filenames;
192
194 std::vector<std::string> anatomical_image_filenames;
195
196 std::vector<shared_ptr<TargetT>> anatomical_prior_sptrs, kmnorm_sptrs;
197 shared_ptr<TargetT> kpnorm_sptr;
198 // kernel parameters
199 int num_neighbours, num_non_zero_feat, num_elem_neighbourhood, num_voxels, dimz, dimy, dimx;
200 int freeze_iterative_kernel_at_subiter_num;
201 std::vector<double> sigma_m;
202 bool only_2D;
203 bool hybrid;
204 double sigma_p;
205 double sigma_dp, sigma_dm;
206 BasicCoordinate<3, int> min_ind, max_ind;
207 shared_ptr<TargetT> iterative_kernel_image_frozen_sptr;
208
209 void set_defaults() override;
210 void initialise_keymap() override;
211 bool post_processing() override;
212
214 void compute_kernelised_image(TargetT& kernelised_image_out,
215 const TargetT& image_to_kernelise,
216 const TargetT& current_alpha_estimate);
217
218private:
219 friend void do_sensitivity(const char* const par_filename);
220
222 Succeeded set_up(shared_ptr<TargetT> const& target_image_sptr) override;
223
225 void update_estimate(TargetT& current_image_estimate) override;
226
228 bool still_updating_iterative_kernel();
229
230 std::vector<double> anatomical_sd;
231 mutable Array<3, float> distance;
235 void calculate_norm_matrix(TargetT& normp, const int dimf_row, const int dimf_col, const TargetT& emission);
236
239 void calculate_norm_const_matrix(std::vector<shared_ptr<TargetT>>& normm, const int dimf_row, const int dimf_col);
240
242 void estimate_stand_dev_for_anatomical_image(std::vector<double>& SD);
243# if 0
246// void full_compute_kernelised_image(TargetT& kernelised_image_out,
247// const TargetT& image_to_kernelise,
248// const TargetT& current_alpha_estimate);
249
252// void compact_compute_kernelised_image(TargetT& kernelised_image_out,
253// const TargetT& image_to_kernelise,
254// const TargetT& current_alpha_estimate);
255# endif
256
257 double calc_emission_kernel(const double current_alpha_estimate_zyx,
258 const double current_alpha_estimate_zyx_dr,
259 const double distance_dzdydx,
260 const bool use_compact_implementation,
261 const int l,
262 const int m);
263
264 double calc_anatomical_kernel(const double anatomical_prior_zyx,
265 const double anatomical_prior_zyx_dr,
266 const double distance_dzdydx,
267 const bool use_compact_implementation,
268 const int l,
269 const int m,
270 const int index);
271
272 double calc_kernel_from_precalculated(const double precalculated_norm_zxy,
273 const double sq_sigma_int,
274 const double sq_sigma_dist,
275 const double sq_distance_dzdydx,
276 const double precalc_denom);
277
278 double calc_kernel_compact(const double prior_image_zyx_diff,
279 const double sq_sigma_int,
280 const double sq_sigma_dist,
281 const double sq_distance_dzdydx,
282 const double precalc_denom);
283};
284
285END_NAMESPACE_STIR
286
287#endif
288
289// __KOSMAPOSLReconstruction_h__
defines the stir::CartesianCoordinate3D<coordT> class
declares the stir::IterativeReconstruction class
Declaration of class stir::OSMAPOSLReconstruction.
Declaration of class stir::RegisteredParsingObject.
This class defines multi-dimensional (numeric) arrays.
Definition Array.h:78
class BasicCoordinate<int num_dimensions, typename coordT> defines num_dimensions -dimensional coordi...
Definition BasicCoordinate.h:57
void initialise_keymap() override
Initialise all keywords.
Definition KOSMAPOSLReconstruction.cxx:166
void set_defaults() override
Set defaults before parsing.
Definition KOSMAPOSLReconstruction.cxx:143
const KOSMAPOSLReconstruction & get_parameters() const
accessor for the external parameters
Definition KOSMAPOSLReconstruction.h:140
void compute_kernelised_image(TargetT &kernelised_image_out, const TargetT &image_to_kernelise, const TargetT &current_alpha_estimate)
Function that applies the kernel to the image_to_kernelise.
Definition KOSMAPOSLReconstruction.cxx:757
std::string input_filename
Filename with input projection data.
Definition KOSMAPOSLReconstruction.h:189
KOSMAPOSLReconstruction()
Default constructor (calling set_defaults())
Definition KOSMAPOSLReconstruction.cxx:222
bool post_processing() override
used to check acceptable parameter ranges, etc...
Definition KOSMAPOSLReconstruction.cxx:195
std::vector< std::string > anatomical_image_filenames
Anatomical image filename.
Definition KOSMAPOSLReconstruction.h:194
static const char *const registered_name
Name which will be used when parsing a KOSMAPOSLReconstruction object.
Definition KOSMAPOSLReconstruction.h:126
KOSMAPOSLReconstruction & get_parameters()
accessor for the external parameters
Definition KOSMAPOSLReconstruction.h:137
Implementation of the Ordered Subsets version of Green's MAP One Step Late algorithm.
Definition OSMAPOSLReconstruction.h:78
base class for all ReconstructionsAs there is not a lot of commonality between different reconstructi...
Definition Reconstruction.h:70
Parent class for all leaves in a RegisteredObject hierarchy that do parsing of parameter files.
Definition RegisteredParsingObject.h:78
a class containing an enumeration type that can be used by functions to signal successful operation o...
Definition Succeeded.h:44