diff --git a/src/xSTIR/cSTIR/cstir.cpp b/src/xSTIR/cSTIR/cstir.cpp index 0f0665474..453d7184a 100644 --- a/src/xSTIR/cSTIR/cstir.cpp +++ b/src/xSTIR/cSTIR/cstir.cpp @@ -649,6 +649,22 @@ void* cSTIR_createPETAttenuationModel(const void* ptr_img, const void* ptr_am) CATCH; } +extern "C" +void* cSTIR_computeACF(const void* ptr_sino, const void* ptr_mumap, void* ptr_acf, void* ptr_iacf) +{ + try { + SPTR_FROM_HANDLE(STIRAcquisitionData, sptr_sino, ptr_sino); + SPTR_FROM_HANDLE(STIRImageData, sptr_mumap, ptr_mumap); + SPTR_FROM_HANDLE(STIRAcquisitionData, sptr_acf, ptr_acf); + SPTR_FROM_HANDLE(STIRAcquisitionData, sptr_iacf, ptr_iacf); + PETAttenuationModel::compute_ac_factors(sptr_sino, sptr_mumap, sptr_acf, sptr_iacf); + HANDLE_FROM_SPTR(STIRAcquisitionData, sptr_acf, ptr_acf); + HANDLE_FROM_SPTR(STIRAcquisitionData, sptr_iacf, ptr_iacf); + return (void*) new DataHandle; + } + CATCH; +} + extern "C" void* cSTIR_chainPETAcquisitionSensitivityModels (const void* ptr_first, const void* ptr_second) diff --git a/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h b/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h index b654f9150..eee504885 100644 --- a/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h +++ b/src/xSTIR/cSTIR/include/sirf/STIR/cstir.h @@ -78,6 +78,8 @@ extern "C" { (const void* ptr_src, const char* src); void* cSTIR_createPETAttenuationModel (const void* ptr_img, const void* ptr_am); + void* cSTIR_computeACF + (const void* ptr_sino, const void* ptr_mumap, void* ptr_acf, void* ptr_iacf); void* cSTIR_chainPETAcquisitionSensitivityModels (const void* ptr_first, const void* ptr_second); void* cSTIR_setupAcquisitionSensitivityModel(void* ptr_sm, void* ptr_ad); diff --git a/src/xSTIR/pSTIR/STIR.py b/src/xSTIR/pSTIR/STIR.py index 753db3f14..ac3e672e2 100644 --- a/src/xSTIR/pSTIR/STIR.py +++ b/src/xSTIR/pSTIR/STIR.py @@ -1735,6 +1735,15 @@ def invert(self, ad): check_status(fd.handle) return fd + @staticmethod + def compute_attenuation_correction_factors(sinograms, mu_map): + ''''Returns attenuation correction factor and its inverse + '''' + acf = AcquisitionData(sinograms) + iacf = AcquisitionData(sinograms) + try_calling(pystir.cSTIR_computeACF(sinograms.handle, mu_map.handle, acf.handle, iacf.handle)) + return acf, iacf + def __del__(self): """del.""" if self.handle is not None: