From 7e44d4e79aca8c08d3a402e59ed891af411f25b9 Mon Sep 17 00:00:00 2001 From: Evgueni Ovtchinnikov Date: Thu, 6 Jun 2024 14:32:03 +0000 Subject: [PATCH] added methods for computing prompts only from list-mode data --- src/xSTIR/cSTIR/cstir.cpp | 17 +++++++++++++++++ src/xSTIR/cSTIR/include/sirf/STIR/cstir.h | 3 +++ src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h | 16 ++++++++++++++++ src/xSTIR/pSTIR/STIR.py | 11 +++++++++++ 4 files changed, 47 insertions(+) diff --git a/src/xSTIR/cSTIR/cstir.cpp b/src/xSTIR/cSTIR/cstir.cpp index 1ff102d04..98629ce47 100644 --- a/src/xSTIR/cSTIR/cstir.cpp +++ b/src/xSTIR/cSTIR/cstir.cpp @@ -480,6 +480,23 @@ void* cSTIR_convertListmodeToSinograms(void* ptr) CATCH; } +extern "C" +void* cSTIR_promptsFromListmode(void* ptr_lm2s, void* ptr_lmdata, + const float start, const float stop, + void* ptr_templ, void* ptr_sino, const char* prefix) +{ + try { + ListmodeToSinograms& lm2s = objectFromHandle(ptr_lm2s); + STIRListmodeData& lm_data = objectFromHandle(ptr_lmdata); + STIRAcquisitionData& templ = objectFromHandle(ptr_templ); + SPTR_FROM_HANDLE(STIRAcquisitionData, sptr_sino, ptr_sino); + lm2s.prompts_from_listmode(lm_data, start, stop, templ, sptr_sino, prefix); + HANDLE_FROM_SPTR(STIRAcquisitionData, sptr_sino, ptr_sino); + return new DataHandle; + } + CATCH; +} + extern "C" void* cSTIR_promptsAndRandomsFromListmode(void* ptr_lm2s, void* ptr_lmdata, const float start, const float stop, diff --git a/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h b/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h index 64dcc819e..f424828ee 100644 --- a/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h +++ b/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h @@ -63,6 +63,9 @@ extern "C" { (void* ptr_lm2s, const char* flag, int v); void* cSTIR_setupListmodeToSinogramsConverter(void* ptr); void* cSTIR_convertListmodeToSinograms(void* ptr); + void* cSTIR_promptsFromListmode(void* ptr_lm2s, void* ptr_lmdata, + const float start, const float stop, + void* ptr_templ, void* ptr_sino, const char* prefix); void* cSTIR_promptsAndRandomsFromListmode(void* ptr_lm2s, void* ptr_lmdata, const float start, const float stop, void* ptr_templ, void* ptr_sino, void* ptr_rand, const char* prefix); diff --git a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h index 02cadfcb2..e23ee3627 100644 --- a/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h +++ b/src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h @@ -716,6 +716,22 @@ The actual algorithm is described in /// Returns -1 if not found. float get_time_at_which_num_prompts_exceeds_threshold(const unsigned long threshold) const; + void prompts_from_listmode( + const STIRListmodeData& lm_data, + double start, double stop, + const STIRAcquisitionData& acq_data_template, + std::shared_ptr& prompts_sptr, + const std::string prompts_prefix = "prompts") + { + set_input(lm_data); + set_output(prompts_prefix); + set_template(acq_data_template); + set_time_interval(start, stop); + set_up(); + process_data(); + prompts_sptr = get_output(); + } + void prompts_and_randoms_from_listmode( const STIRListmodeData& lm_data, double start, double stop, diff --git a/src/xSTIR/pSTIR/STIR.py b/src/xSTIR/pSTIR/STIR.py index 18a466c97..e079068c9 100644 --- a/src/xSTIR/pSTIR/STIR.py +++ b/src/xSTIR/pSTIR/STIR.py @@ -1599,6 +1599,17 @@ def get_time_at_which_num_prompts_exceeds_threshold(self, threshold): pyiutil.deleteDataHandle(h) return v + def prompts_from_listmode(self, lm_data, start, stop, templ, prefix="prompts"): + """Returns proampts computed from listmode raw data + + """ + assert_validity(lm_data, ListmodeData) + assert_validity(templ, AcquisitionData) + sino = AcquisitionData(templ) + try_calling(pystir.cSTIR_promptsFromListmode(self.handle, lm_data.handle, \ + start, stop, templ.handle, sino.handle, prefix)) + return sino, rand + def prompts_and_randoms_from_listmode(self, lm_data, start, stop, templ, prefix="prompts"): """Returns proampts and randoms' estimates computed from listmode raw data