-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Moving SyneRBI-Challenge nema-data utilities to SIRF #1241
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
c25c1e0
started moving Challenge nema-data utilities to SIRF
evgueni-ovtchinnikov a2691ac
reimplemented two nema data processing functions in SIRF (C++)
evgueni-ovtchinnikov df408d2
moved the functions of the previous commit to more sensible places
evgueni-ovtchinnikov f7c417d
added C++ code for testing ScatterEstimator in test7.cpp
evgueni-ovtchinnikov e6300c7
rewrote all my Challenge functions in C++, hit incompatible proj data…
evgueni-ovtchinnikov ab00641
fixed incompatible proj data bug
evgueni-ovtchinnikov a5e8ba0
added simpler set up for PETAcquisitionSensitivityModel
evgueni-ovtchinnikov c4b254c
implemented Python interface for sinograms_and_randoms_from_listmode
evgueni-ovtchinnikov 83fbbd0
implemented Python interface to compute_ac_factors (not tested yet)
evgueni-ovtchinnikov ea6a736
fixed typos in STIR.py lines 1740 and 1741
evgueni-ovtchinnikov de8e615
interfaced all C++ nema-data utilities in SIRF into Python
evgueni-ovtchinnikov e40bdc1
made some corrections/amendments suggested by KT
evgueni-ovtchinnikov 4db5527
attended to Codacy issues
evgueni-ovtchinnikov 8866464
removed hardwired prompts prefix from prompts and randoms computation…
evgueni-ovtchinnikov 61a60f9
documented the type of objects returned by compute_attenuation_factor…
evgueni-ovtchinnikov a7b4756
removed unused import of existing_filepath from test_data_preparation.py
evgueni-ovtchinnikov 413808f
compute_ac_factors now gets PETAcquisitionModel as an argument
evgueni-ovtchinnikov b5a4b8d
removed commented-out member function of ListmodeToSinograms
evgueni-ovtchinnikov 1b30b55
attended to reviewers remarks on computing attenuation factors
evgueni-ovtchinnikov d2585d9
simplified compute_ac_factors methods (C++/C/Python)
evgueni-ovtchinnikov 85ebbde
attended to reviewer's comments and suggestions
evgueni-ovtchinnikov d43062e
updated CHANGES.md
evgueni-ovtchinnikov 7e44d4e
added methods for computing prompts only from list-mode data
evgueni-ovtchinnikov fc7eda8
corrected the return of prompts_from_listmpde [ci skip]
evgueni-ovtchinnikov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
evgueni-ovtchinnikov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from sirf.Utilities import examples_data_path | ||
|
||
import importlib | ||
pet = importlib.import_module('sirf.STIR') | ||
|
||
data_path = examples_data_path('PET') + '/mMR' | ||
print('Finding files in %s...' % data_path) | ||
|
||
#save_path = "~/tmp/data" | ||
#print('Saving files in %s...' % save_path) | ||
|
||
f_listmode = os.path.join(data_path, "list.l.hdr"); | ||
f_template = os.path.join(data_path, "mMR_template_span11_small.hs"); | ||
f_attn = os.path.join(data_path, "mu_map.hv"); | ||
f_norm = os.path.join(data_path, "norm.n.hdr"); | ||
|
||
# engine's messages go to files, except error messages, which go to stdout | ||
_ = pet.MessageRedirector('info.txt', 'warn.txt') | ||
|
||
# select acquisition data storage scheme | ||
pet.AcquisitionData.set_storage_scheme('memory') | ||
|
||
# read acquisition data template | ||
acq_data_template = pet.AcquisitionData(f_template) | ||
|
||
listmode_data = pet.ListmodeData(f_listmode) | ||
|
||
# create listmode-to-sinograms converter object | ||
lm2sino = pet.ListmodeToSinograms() | ||
lm_data = pet.ListmodeData(f_listmode) | ||
prompts, randoms = lm2sino.prompts_and_randoms_from_listmode(lm_data, 0, 10, acq_data_template) | ||
print('data shape: %s' % repr(prompts.shape)) | ||
print('prompts norm: %f' % prompts.norm()) | ||
print('randoms norm: %f' % randoms.norm()) | ||
#prompts.write(os.path.join(save_path, 'prompts.hs')) | ||
#randoms.write(os.path.join(save_path, 'randoms.hs')) | ||
|
||
attn_image = pet.ImageData(f_attn) | ||
attn, acf, iacf = pet.AcquisitionSensitivityModel.compute_attenuation_factors(prompts, attn_image) | ||
print('norm of the attenuation correction factor: %f' % acf.norm()) | ||
print('norm of the inverse of the attenuation correction factor: %f' % iacf.norm()) | ||
#acf.write(os.path.join(save_path, 'acf.hs')) | ||
#iacf.write(os.path.join(save_path, 'iacf.hs')) | ||
#exit() | ||
|
||
asm = pet.AcquisitionSensitivityModel(f_norm) | ||
se = pet.ScatterEstimator() | ||
se.set_input(prompts) | ||
se.set_attenuation_image(attn_image) | ||
se.set_randoms(randoms) | ||
se.set_asm(asm) | ||
se.set_attenuation_correction_factors(iacf) | ||
se.set_num_iterations(4) | ||
se.set_OSEM_num_subsets(7) | ||
se.set_output_prefix("scatter") | ||
se.set_up() | ||
se.process() | ||
scatter = se.get_output() | ||
print('norm of the scatter estimate: %f' % scatter.norm()) | ||
|
||
multfact = acf.clone() | ||
asm.set_up(acf) | ||
asm.unnormalise(multfact) | ||
print(multfact.norm()) | ||
|
||
background = randoms + scatter | ||
print('norm of the backgrount term: %f' % background.norm()) | ||
|
||
asm_mf = pet.AcquisitionSensitivityModel(multfact) | ||
asm_mf.set_up(background) | ||
asm_mf.normalise(background) | ||
print('norm of the additive term: %f' % background.norm()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't make sense to users.