Skip to content

Commit

Permalink
RF: This seems to work.
Browse files Browse the repository at this point in the history
For some reason.
  • Loading branch information
arokem committed Nov 9, 2012
1 parent aef6822 commit 650a97c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dipy/sims/phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def add_noise(vol, snr=20, noise_type='gaussian'):
noise1 = np.random.normal(0, sigma, size=vol.shape)
noise2 = np.random.normal(0, sigma, size=vol.shape)
# This is the same as abs(vol + complex(noise1, noise2))
return np.sqrt((vol + noise1)**2 + noise2**2)
return vol + np.sqrt(7/3.) * np.sqrt(noise1**2 + noise2**2)


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions dipy/sims/tests/test_phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ def test_noise():

for SNR in [0.1, 1, 10, 100]:
for noise_type in ['gaussian', 'rician']:
print noise_type
vol_w_noise = add_noise(vol, SNR, noise_type=noise_type)
noise = vol_w_noise - vol
est_SNR = np.mean(vol)/np.std(noise)
# And tolerance needs to be pretty lax...
assert_array_almost_equal(est_SNR, SNR, decimal=2)
assert_array_almost_equal(est_SNR, SNR, decimal=1)


if __name__ == "__main__":
Expand Down

0 comments on commit 650a97c

Please sign in to comment.