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)
| 60 | |
| 61 | |
| 62 | def 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) |
no outgoing calls
no test coverage detected