Skip to content

Commit

Permalink
cope with non-TOF multfactors for TOF data
Browse files Browse the repository at this point in the history
This currently doesn't work for all examples though (some problems in
`partitioner`
  • Loading branch information
KrisThielemans committed Sep 25, 2024
1 parent 086bcda commit b1e17b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion SIRF_data_preparation/create_initial_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def scale_initial_image(acquired_data, additive_term, mult_factors, template_ima
WARNING: assumes that obj_fun has been set_up already
"""
data_sum = (acquired_data.sum() - (additive_term * mult_factors).sum())
sensitivity_factors = STIR.AcquisitionSensitivityModel(mult_factors)
sensitivity_factors.set_up(acquired_data)
background = sensitivity_factors.forward(additive_term)
data_sum = acquired_data.sum() - background.sum()
if data_sum <= 0 or math.isinf(data_sum) or math.isnan(data_sum):
raise ValueError("Something wrong with input data. Sum of (prompts-background) is negative:"
f" sum prompts: {acquired_data.sum()}, sum corrected: {data_sum}")
Expand Down
11 changes: 9 additions & 2 deletions main_OSEM.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,16 @@ def __init__(self, data: Dataset, num_subsets: int = 7, update_objective_interva

acquisition_model_subset = STIR.AcquisitionModelUsingParallelproj()
acquisition_model_subset.set_additive_term(additive_term_subset)
acquisition_model_subset.set_up(prompts_subset, self.x)
if prompts_subset.dimensions()[0] > 1 and multiplicative_factors_subset.dimensions()[0] == 1:
# non-TOF multiplicative factors for TOF data
acquisition_model_subset.set_up(multiplicative_factors_subset, self.x)
subset_sensitivity = acquisition_model_subset.backward(multiplicative_factors_subset)
acquisition_model_subset.set_up(prompts_subset, self.x)
else:
assert prompts_subset.dimensions()[0] == multiplicative_factors_subset.dimensions()[0]
acquisition_model_subset.set_up(prompts_subset, self.x)
subset_sensitivity = acquisition_model_subset.backward(multiplicative_factors_subset)

subset_sensitivity = acquisition_model_subset.backward(multiplicative_factors_subset)
# add a small number to avoid NaN in division
subset_sensitivity += subset_sensitivity.max() * 1e-6

Expand Down

0 comments on commit b1e17b2

Please sign in to comment.