MCPcopy Create free account
hub / github.com/danjgale/surfplot / threshold

Function threshold

surfplot/utils.py:62–85  ·  view source on GitHub ↗

Threshold vertex array Parameters ---------- data : numpy.ndarray Vertex array thresh : float Threshold value. All values below or equal to threshold are set 0. binarize : bool, optional Set all values above threshold to 1. Default: False two_sided :

(data, thresh, binarize=False, two_sided=True)

Source from the content-addressed store, hash-verified

60
61
62def threshold(data, thresh, binarize=False, two_sided=True):
63 """Threshold vertex array
64
65 Parameters
66 ----------
67 data : numpy.ndarray
68 Vertex array
69 thresh : float
70 Threshold value. All values below or equal to threshold are set 0.
71 binarize : bool, optional
72 Set all values above threshold to 1. Default: False
73 two_sided : bool, optional
74 Apply thresholding to both positive and negative values. Default: True
75
76 Returns
77 -------
78 numpy.ndarray
79 Thresholded data
80 """
81 fill = 1 if binarize else data
82 if two_sided:
83 return np.where(np.abs(data) > thresh, fill, 0)
84 else:
85 return np.where(data > thresh, fill, 0)

Callers 2

plot_example_02.pyFile · 0.90
plot_example_02.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected