Skip to content

Commit

Permalink
added methods for computing prompts only from list-mode data
Browse files Browse the repository at this point in the history
  • Loading branch information
evgueni-ovtchinnikov committed Jun 6, 2024
1 parent d43062e commit 7e44d4e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/xSTIR/cSTIR/cstir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ListmodeToSinograms>(ptr_lm2s);
STIRListmodeData& lm_data = objectFromHandle<STIRListmodeData>(ptr_lmdata);
STIRAcquisitionData& templ = objectFromHandle<STIRAcquisitionData>(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,
Expand Down
3 changes: 3 additions & 0 deletions src/xSTIR/cSTIR/include/sirf/STIR/cstir.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/xSTIR/cSTIR/include/sirf/STIR/stir_x.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<STIRAcquisitionData>& 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,
Expand Down
11 changes: 11 additions & 0 deletions src/xSTIR/pSTIR/STIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7e44d4e

Please sign in to comment.