brainspace.gradient.utils.dominant_set¶
-
brainspace.gradient.utils.
dominant_set
(s, k, is_thresh=False, norm=False, copy=True, as_sparse=True)[source]¶ Keep the largest elements for each row. Zero-out the rest.
Parameters: - s (2D ndarray) – Similarity/affinity matrix.
- k (int or float) – If int, keep top k elements for each row. If float, keep top 100*k percent of elements. When float, must be in range (0, 1).
- is_thresh (bool, optional) – If True, k is used as threshold. Keep elements greater than k. Default is False.
- norm (bool, optional) – If True, normalize rows. Default is False.
- copy (bool, optional) – If True, make a copy of the input array. Otherwise, work on original array. Default is True.
- as_sparse (bool, optional) – If True, return a sparse matrix. Otherwise, return the same type of the input array. Default is True.
Returns: output (2D ndarray or sparse matrix) – Dominant set.