MCPcopy Create free account
hub / github.com/casperdcl/brainweb / noise

Function noise

brainweb/utils.py:435–448  ·  view source on GitHub ↗

@param n : float, noise fraction (0, inf) @param sigma : float, smoothing of noise component @return[out] im : array like im with +-n *100%im noise added

(im, n, warn_zero=True, sigma=1)

Source from the content-addressed store, hash-verified

433
434
435def noise(im, n, warn_zero=True, sigma=1):
436 """
437 @param n : float, noise fraction (0, inf)
438 @param sigma : float, smoothing of noise component
439 @return[out] im : array like im with +-n *100%im noise added
440 """
441 if n < 0:
442 raise ValueError("Noise must be positive")
443 elif n == 0:
444 if warn_zero:
445 log.warn("zero noise")
446 return im
447 r = gaussian_filter(np.random.random(im.shape), sigma=sigma, mode='constant')
448 return im * (1 + n * (2 * r - 1))
449
450
451def toPetMmr(im, pad=True, dtype=np.float32, outres="mMR", modes=None,

Callers 1

get_mmrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected