nimare.utils
.unique_rows
- unique_rows(ar, return_counts=False)[source]
Remove repeated rows from a 2D array.
In particular, if given an array of coordinates of shape (Npoints, Ndim), it will remove repeated points.
- Parameters:
ar (2-D ndarray) – The input array.
return_counts (
bool
, optional) – If True, also return the number of times each unique item appears in ar.
- Returns:
ar_out (2-D ndarray) – A copy of the input array with repeated rows removed.
unique_counts (
np.ndarray
, optional) – The number of times each of the unique values comes up in the original array. Only provided if return_counts is True.
:raises ValueError : if ar is not two-dimensional.:
Notes
The function will generate a copy of ar if it is not C-contiguous, which will negatively affect performance for large input arrays.
This is taken from skimage. See
skimage.util.unique_rows()
.Examples
>>> ar = np.array([[1, 0, 1], ... [0, 1, 0], ... [1, 0, 1]], np.uint8) >>> unique_rows(ar) array([[0, 1, 0], [1, 0, 1]], dtype=uint8)
License
Copyright (C) 2019, the scikit-image team All rights reserved.