-
Notifications
You must be signed in to change notification settings - Fork 29
Poisson noise generation script for PETRIC2 #1321
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c6163ed
implemented Python interface for Poisson noise generator (not tested)
evgueni-ovtchinnikov cfb9904
added Poisson noise generation to acquisition_data.py demo
evgueni-ovtchinnikov cda09e9
started working on Poisson noise generation script for PETRIC2
evgueni-ovtchinnikov 8c7e342
attended to Codacy issues
evgueni-ovtchinnikov 859f574
added more command-line options for noise generator script
evgueni-ovtchinnikov 62e84fe
tidied up naming
evgueni-ovtchinnikov 52f3ac6
updated PET/acquisition_data.py demo
evgueni-ovtchinnikov efd1526
fixed typo in PoissonNoiseGenerator
evgueni-ovtchinnikov 8803bed
moved generate_noisy_data.py to examples/Python/PET [ci skip]
evgueni-ovtchinnikov a04695f
removed Poisson noise stuff from examples/Python/PET/acquisition_data…
evgueni-ovtchinnikov ef9b79f
CHANGES.md updated [ci skip]
evgueni-ovtchinnikov df35fb5
implemented reviewer's suggestions
evgueni-ovtchinnikov b3efb53
implemented further reviewer's suggestions
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -1627,22 +1627,40 @@ def get_time_at_which_num_prompts_exceeds_threshold(self, threshold): | |
|
|
||
| class PoissonNoiseGenerator(object): | ||
| """ | ||
| Class that generates Poisson noise. | ||
| Generates noise realisations according to Poisson statistics but allowing for scaling. | ||
|
|
||
| A scaling_factor is used to multiply the input data before generating | ||
| the Poisson random number. This means that a scaling_factor larger than 1 | ||
| will result in less noisy data. | ||
|
||
|
|
||
| If preserve_mean=false, the mean of the output data will | ||
| be equal to <tt>scaling_factor*mean_of_input</tt>, otherwise it | ||
evgueni-ovtchinnikov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| will be equal to mean_of_input, but then the output is no longer Poisson | ||
| distributed. | ||
| """ | ||
|
|
||
| def __init__(self, scaling_factor=1.0, preserve_mean=False): | ||
| self.name = "PoissonNoiseGenerator" | ||
| self.handle = pystir.cSTIR_createPoissonNoiseGenerator(scaling_factor, preserve_mean) | ||
| check_status(self.handle) | ||
| self.scale = scaling_factor | ||
|
|
||
| @property | ||
| def scaling_factor(self): | ||
| return self.scale | ||
| self.scaling_factor = scaling_factor | ||
| self.preserve_mean = preserve_mean | ||
| self.output_handle = None | ||
evgueni-ovtchinnikov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def set_seed(self, s): | ||
| parms.set_int_par(self.handle, self.name, 'seed', s) | ||
|
|
||
| def process(self, acq_data): | ||
| self.output_handle = pystir.cSTIR_generatePoissonNoise(self.handle, acq_data.handle) | ||
| check_status(self.output_handle) | ||
|
|
||
| def get_output(self): | ||
| if self.output_handle is None: | ||
| raise error('Noise generating not done') | ||
| output = AcquisitionData() | ||
| output.handle = self.output_handle | ||
| return output | ||
|
|
||
| def generate_noisy_data(self, acq_data): | ||
| noisy_data = AcquisitionData() | ||
| noisy_data.handle = pystir.cSTIR_generatePoissonNoise(self.handle, acq_data.handle) | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.