Skip to content

Commit

Permalink
implemented Python interface to compute_ac_factors (not tested yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgueni-ovtchinnikov committed Apr 24, 2024
1 parent c4b254c commit 83fbbd0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/xSTIR/cSTIR/cstir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/xSTIR/cSTIR/include/sirf/STIR/cstir.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/xSTIR/pSTIR/STIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 83fbbd0

Please sign in to comment.