From 51911cc3695f8c9826972e6656fd13b01b5cfaec Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Wed, 10 Jul 2024 20:29:16 +0100 Subject: [PATCH 1/5] first steps to expose mask functions for Scatter --- src/xSTIR/cSTIR/cstir_p.cpp | 17 +++++++++++++++++ src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/src/xSTIR/cSTIR/cstir_p.cpp b/src/xSTIR/cSTIR/cstir_p.cpp index 7f3d29781..6233e971b 100644 --- a/src/xSTIR/cSTIR/cstir_p.cpp +++ b/src/xSTIR/cSTIR/cstir_p.cpp @@ -843,6 +843,23 @@ sirf::cSTIR_setScatterEstimatorParameter SPTR_FROM_HANDLE(STIRImageData, sptr_id, hv); obj.set_attenuation_image_sptr(sptr_id); } + else if (sirf::iequals(name, "setMaskImage")) + { + SPTR_FROM_HANDLE(STIRImageData, sptr_id, hv); + obj.set_mask_image_sptr(sptr_id); + } + else if (sirf::iequals(name, "setMaskAcqData")) + { + SPTR_FROM_HANDLE(STIRAcquisitionData, sptr_pd, hv); + obj.set_mask_acq_data_sptr(sptr_pd); + } +#if STIR_VERSION >= 060200 + else if (sirf::iequals(name, "setRecomputeMaskImage")) + { + bool value = dataFromHandle(hv); + obj.set_recompute_mask_image(value); + } +#endif else if (sirf::iequals(name, "setAttenuationCorrectionFactors")) { SPTR_FROM_HANDLE(STIRAcquisitionData, sptr_ad, hv); diff --git a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h index 649c5fd51..629663934 100644 --- a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h +++ b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h @@ -902,6 +902,14 @@ The actual algorithm is described in stir::ScatterEstimation::set_attenuation_image_sptr(arg->data_sptr()); #endif } + void set_mask_image_sptr(std::shared_ptr arg) + { + stir::ScatterEstimation::set_mask_image_sptr(arg->data_sptr()); + } + void set_mask_acq_data_sptr(std::shared_ptr arg) + { + stir::ScatterEstimation::set_mask_proj_data_sptr(arg->data()); + } //! Set prefix for filenames with scatter estimates. /*! From 24540cfa256e4f34cf8045968255bdd447c7dcf1 Mon Sep 17 00:00:00 2001 From: NicoleJurjew Date: Tue, 16 Jul 2024 10:49:46 +0100 Subject: [PATCH 2/5] expose stir-method set_recompute_mask_image to cSTIR --- src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h index 629663934..b2fad7266 100644 --- a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h +++ b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h @@ -910,6 +910,10 @@ The actual algorithm is described in { stir::ScatterEstimation::set_mask_proj_data_sptr(arg->data()); } + void set_recompute_mask_image(bool arg) + { + stir::ScatterEstimation::set_recompute_mask_image(arg); + } //! Set prefix for filenames with scatter estimates. /*! From f3fabf85238782637306c018ac0216ea21f482b7 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Tue, 16 Jul 2024 12:21:31 +0100 Subject: [PATCH 3/5] add ScatterEstimation::set_recompute_mask_image if STIR is recent enough --- src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h index b2fad7266..c719e1b87 100644 --- a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h +++ b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h @@ -910,10 +910,12 @@ The actual algorithm is described in { stir::ScatterEstimation::set_mask_proj_data_sptr(arg->data()); } - void set_recompute_mask_image(bool arg) +#if STIR_VERSION >= 060200 + void set_recompute_mask_image(bool arg) { stir::ScatterEstimation::set_recompute_mask_image(arg); } +#endif //! Set prefix for filenames with scatter estimates. /*! From 490058801ff4653438a195ffcc984447666d5fe0 Mon Sep 17 00:00:00 2001 From: NicoleJurjew Date: Fri, 4 Oct 2024 16:49:23 +0100 Subject: [PATCH 4/5] add methods to use mask image or acq-data for scatter estimation to SIRF-object ScatterEstimator --- src/xSTIR/pSTIR/STIR.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/xSTIR/pSTIR/STIR.py b/src/xSTIR/pSTIR/STIR.py index 8e1e4fd5c..2584ff5f7 100644 --- a/src/xSTIR/pSTIR/STIR.py +++ b/src/xSTIR/pSTIR/STIR.py @@ -3608,6 +3608,15 @@ def set_attenuation_correction_factors(self, arg): assert_validity(arg, AcquisitionData) parms.set_parameter(self.handle, self.name, 'setAttenuationCorrectionFactors', arg.handle) + def set_mask_image(self, image): + assert_validity(image, ImageData) + parms.set_parameter(self.handle, self.name, 'setMaskImage', image.handle) + + def set_mask_acq_data(self, arg): + assert_validity(arg, AcquisitionData) + parms.set_parameter(self.handle, self.name, 'setMaskAcqData', arg.handle) + + def set_input(self, acq_data): assert_validity(acq_data, AcquisitionData) parms.set_parameter(self.handle, self.name, 'setInput', acq_data.handle) From f90ee5e059159fe19599c0a4323461f66d4b8599 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Fri, 22 Nov 2024 14:52:12 +0000 Subject: [PATCH 5/5] update CHANGES.md [ci skip] --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index ee28ca907..f6699f444 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ * SIRF/STIR - prior value returned as double + - ScatterEstimation has extra methods that allow setting masks for the tail-fitting ## v3.8.0