Skip to content
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

Bug fix float overflow in estimate_sigma #504

Merged
merged 2 commits into from
Dec 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dipy/denoise/noise_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def piesno(data, N=1, alpha=0.01, l=100, itermax=100, eps=1e-5, return_mask=Fals
eps : float
Tolerance for the convergence criterion. Convergence is
reached if two subsequent estimates are smaller than eps.

return_mask : bool
If True, return a mask identyfing all the pure noise voxel
that were found.
Expand Down Expand Up @@ -145,9 +145,9 @@ def piesno(data, N=1, alpha=0.01, l=100, itermax=100, eps=1e-5, return_mask=Fals

if return_mask:
return sigma[pos], mask[pos]

return sigma[pos]


def estimate_sigma(arr, disable_background_masking=False):
"""Standard deviation estimation from local patches
Expand Down Expand Up @@ -187,8 +187,8 @@ def estimate_sigma(arr, disable_background_masking=False):
mask = arr[..., 0].astype(np.bool)
else:
mask = np.ones_like(arr[..., 0], dtype=np.bool)
conv_out = np.zeros(arr[...,0].shape, dtype=np.float32)

conv_out = np.zeros(arr[..., 0].shape, dtype=np.float64)
for i in range(sigma.size):
convolve(arr[..., i], k, output=conv_out)
mean_block = np.sqrt(6/7) * (arr[..., i] - 1/6 * conv_out)
Expand Down