From 58b408dc5aaca84230b2fef02859090940ebab04 Mon Sep 17 00:00:00 2001 From: robbietuk Date: Mon, 28 Oct 2024 12:35:09 -0700 Subject: [PATCH 1/4] Scatter estimation forward projector setter --- src/include/stir/scatter/ScatterEstimation.h | 8 ++++++ src/scatter_buildblock/ScatterEstimation.cxx | 28 +++++++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/include/stir/scatter/ScatterEstimation.h b/src/include/stir/scatter/ScatterEstimation.h index 785cd3b25..0c398d60e 100644 --- a/src/include/stir/scatter/ScatterEstimation.h +++ b/src/include/stir/scatter/ScatterEstimation.h @@ -39,6 +39,7 @@ #include "stir/stir_math.h" #include "stir/FilePath.h" +#include START_NAMESPACE_STIR @@ -170,6 +171,11 @@ class ScatterEstimation : public ParsingObject void set_recompute_mask_image(bool arg); void set_recompute_mask_projdata(bool arg); + //! Sets the forward projector for the scatter estimation + void set_forward_projector_sptr(const shared_ptr projector_sptr); + //!Get the forward projector used for the scatter estimation + shared_ptr get_forward_projector_sptr() const; + inline void set_scatter_simulation_method_sptr(const shared_ptr); inline void set_num_iterations(int); @@ -275,6 +281,8 @@ class ScatterEstimation : public ParsingObject //! The file name for the attenuation coefficients. //! If they are to be recalculated they will be stored here, if set. std::string atten_coeff_filename; + //! ForwardProjector + shared_ptr forward_projector_sptr; //! \details the set of parameters to obtain a mask from the attenuation image /*! The attenuation image will be thresholded to find a plausible mask for where there diff --git a/src/scatter_buildblock/ScatterEstimation.cxx b/src/scatter_buildblock/ScatterEstimation.cxx index 07772ae99..d11a2dd94 100644 --- a/src/scatter_buildblock/ScatterEstimation.cxx +++ b/src/scatter_buildblock/ScatterEstimation.cxx @@ -449,6 +449,18 @@ ScatterEstimation::set_recompute_mask_projdata(bool arg) this->recompute_mask_projdata = arg; } +void +ScatterEstimation::set_forward_projector_sptr(const shared_ptr projector_sptr) +{ + this->forward_projector_sptr = projector_sptr; +} + +shared_ptr +ScatterEstimation::get_forward_projector_sptr() const +{ + return forward_projector_sptr; +} + bool ScatterEstimation::already_setup() const { @@ -1235,30 +1247,32 @@ ScatterEstimation::project_mask_image() } } - shared_ptr forw_projector_sptr; - shared_ptr PM(new ProjMatrixByBinUsingRayTracing()); - forw_projector_sptr.reset(new ForwardProjectorByBinUsingProjMatrixByBin(PM)); + if (!this->forward_projector_sptr) + { + shared_ptr PM(new ProjMatrixByBinUsingRayTracing()); + forward_projector_sptr.reset(new ForwardProjectorByBinUsingProjMatrixByBin(PM)); + } info(boost::format("ScatterEstimation: Forward projector used for the calculation of " "the tail mask: %1%") - % forw_projector_sptr->parameter_info()); + % forward_projector_sptr->parameter_info()); shared_ptr mask_projdata; if (run_in_2d_projdata) { - forw_projector_sptr->set_up(this->input_projdata_2d_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); + forward_projector_sptr->set_up(this->input_projdata_2d_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); mask_projdata.reset(new ProjDataInMemory(this->input_projdata_2d_sptr->get_exam_info_sptr(), this->input_projdata_2d_sptr->get_proj_data_info_sptr())); } else { - forw_projector_sptr->set_up(this->input_projdata_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); + forward_projector_sptr->set_up(this->input_projdata_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); mask_projdata.reset(new ProjDataInMemory(this->input_projdata_sptr->get_exam_info_sptr(), this->input_projdata_sptr->get_proj_data_info_sptr())); } - forw_projector_sptr->forward_project(*mask_projdata, *this->mask_image_sptr); + forward_projector_sptr->forward_project(*mask_projdata, *this->mask_image_sptr); // add 1 to be able to use create_tail_mask_from_ACFs (which expects ACFs, // so complains if the threshold is too low) From 4fb46c0989b91903a622bb09cfcac1e7e7ce1f38 Mon Sep 17 00:00:00 2001 From: robbietuk Date: Mon, 28 Oct 2024 12:39:49 -0700 Subject: [PATCH 2/4] Add forward projector parsing key --- src/scatter_buildblock/ScatterEstimation.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scatter_buildblock/ScatterEstimation.cxx b/src/scatter_buildblock/ScatterEstimation.cxx index d11a2dd94..e555eef14 100644 --- a/src/scatter_buildblock/ScatterEstimation.cxx +++ b/src/scatter_buildblock/ScatterEstimation.cxx @@ -112,6 +112,10 @@ ScatterEstimation::initialise_keymap() this->parser.add_key("mask projdata filename", &this->mask_projdata_filename); this->parser.add_key("tail fitting parameter filename", &this->tail_mask_par_filename); // END MASK + + // Forward projector for mask projection + this->parser.add_parsing_key("forward projector type", &this->forward_projector_sptr); + this->parser.add_key("background projdata filename", &this->back_projdata_filename); this->parser.add_parsing_key("Normalisation type", &this->norm_3d_sptr); this->parser.add_key("attenuation correction factors filename", &this->atten_coeff_filename); From 160367b037e18ccc21c8284021831ce8dee3dbd6 Mon Sep 17 00:00:00 2001 From: robbietuk Date: Wed, 27 Nov 2024 08:00:18 -0800 Subject: [PATCH 3/4] Refactor rename all forward projector for mask members --- src/include/stir/scatter/ScatterEstimation.h | 10 ++++----- src/scatter_buildblock/ScatterEstimation.cxx | 22 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/include/stir/scatter/ScatterEstimation.h b/src/include/stir/scatter/ScatterEstimation.h index 0c398d60e..c5001fb30 100644 --- a/src/include/stir/scatter/ScatterEstimation.h +++ b/src/include/stir/scatter/ScatterEstimation.h @@ -39,7 +39,7 @@ #include "stir/stir_math.h" #include "stir/FilePath.h" -#include +#include "stir/recon_buildblock/ForwardProjectorByBin.h" START_NAMESPACE_STIR @@ -172,9 +172,9 @@ class ScatterEstimation : public ParsingObject void set_recompute_mask_projdata(bool arg); //! Sets the forward projector for the scatter estimation - void set_forward_projector_sptr(const shared_ptr projector_sptr); - //!Get the forward projector used for the scatter estimation - shared_ptr get_forward_projector_sptr() const; + void set_forward_projector_for_mask_sptr(const shared_ptr projector_sptr); + //! Get the forward projector used for the scatter estimation mask calculation + shared_ptr get_forward_projector_for_mask_sptr() const; inline void set_scatter_simulation_method_sptr(const shared_ptr); @@ -282,7 +282,7 @@ class ScatterEstimation : public ParsingObject //! If they are to be recalculated they will be stored here, if set. std::string atten_coeff_filename; //! ForwardProjector - shared_ptr forward_projector_sptr; + shared_ptr forward_projector_for_mask_sptr; //! \details the set of parameters to obtain a mask from the attenuation image /*! The attenuation image will be thresholded to find a plausible mask for where there diff --git a/src/scatter_buildblock/ScatterEstimation.cxx b/src/scatter_buildblock/ScatterEstimation.cxx index e555eef14..b2b80df56 100644 --- a/src/scatter_buildblock/ScatterEstimation.cxx +++ b/src/scatter_buildblock/ScatterEstimation.cxx @@ -114,7 +114,7 @@ ScatterEstimation::initialise_keymap() // END MASK // Forward projector for mask projection - this->parser.add_parsing_key("forward projector type", &this->forward_projector_sptr); + this->parser.add_parsing_key("forward projector for mask type", &this->forward_projector_for_mask_sptr); this->parser.add_key("background projdata filename", &this->back_projdata_filename); this->parser.add_parsing_key("Normalisation type", &this->norm_3d_sptr); @@ -454,15 +454,15 @@ ScatterEstimation::set_recompute_mask_projdata(bool arg) } void -ScatterEstimation::set_forward_projector_sptr(const shared_ptr projector_sptr) +ScatterEstimation::set_forward_projector_for_mask_sptr(const shared_ptr projector_sptr) { - this->forward_projector_sptr = projector_sptr; + this->forward_projector_for_mask_sptr = projector_sptr; } shared_ptr -ScatterEstimation::get_forward_projector_sptr() const +ScatterEstimation::get_forward_projector_for_mask_sptr() const { - return forward_projector_sptr; + return forward_projector_for_mask_sptr; } bool @@ -1251,32 +1251,32 @@ ScatterEstimation::project_mask_image() } } - if (!this->forward_projector_sptr) + if (!this->forward_projector_for_mask_sptr) { shared_ptr PM(new ProjMatrixByBinUsingRayTracing()); - forward_projector_sptr.reset(new ForwardProjectorByBinUsingProjMatrixByBin(PM)); + forward_projector_for_mask_sptr.reset(new ForwardProjectorByBinUsingProjMatrixByBin(PM)); } info(boost::format("ScatterEstimation: Forward projector used for the calculation of " "the tail mask: %1%") - % forward_projector_sptr->parameter_info()); + % forward_projector_for_mask_sptr->parameter_info()); shared_ptr mask_projdata; if (run_in_2d_projdata) { - forward_projector_sptr->set_up(this->input_projdata_2d_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); + forward_projector_for_mask_sptr->set_up(this->input_projdata_2d_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); mask_projdata.reset(new ProjDataInMemory(this->input_projdata_2d_sptr->get_exam_info_sptr(), this->input_projdata_2d_sptr->get_proj_data_info_sptr())); } else { - forward_projector_sptr->set_up(this->input_projdata_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); + forward_projector_for_mask_sptr->set_up(this->input_projdata_sptr->get_proj_data_info_sptr(), this->mask_image_sptr); mask_projdata.reset(new ProjDataInMemory(this->input_projdata_sptr->get_exam_info_sptr(), this->input_projdata_sptr->get_proj_data_info_sptr())); } - forward_projector_sptr->forward_project(*mask_projdata, *this->mask_image_sptr); + forward_projector_for_mask_sptr->forward_project(*mask_projdata, *this->mask_image_sptr); // add 1 to be able to use create_tail_mask_from_ACFs (which expects ACFs, // so complains if the threshold is too low) From 7d03d6c34ac1656a6d099401b48b91610e2aa98a Mon Sep 17 00:00:00 2001 From: robbietuk Date: Wed, 27 Nov 2024 13:20:13 -0800 Subject: [PATCH 4/4] [ci skip] Release notes --- documentation/release_6.3.htm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/documentation/release_6.3.htm b/documentation/release_6.3.htm index 90a30cf56..263b58c69 100644 --- a/documentation/release_6.3.htm +++ b/documentation/release_6.3.htm @@ -33,6 +33,9 @@

New functionality

  • stir_timings has now an extra option to parse a par-file for a projector-pair.
  • +
  • + Added the ability to set a forward projector for mask projection in the ScatterEstimation class. +