brainspace.utils.parcellation.reduce_by_labels

brainspace.utils.parcellation.reduce_by_labels(values, labels, weights=None, target_labels=None, red_op='mean', axis=0, dtype=None)[source]

Summarize data in values according to labels.

Parameters:
  • values (1D or 2D ndarray) – Array of values.
  • labels (1D ndarray, shape = (n_lab,)) – Labels used summarize values.
  • weights (1D ndarray, shape = (n_lab,), optional) – Weights associated with labels. Only used when red_op is ‘average’, ‘mean’, ‘sum’ or ‘mode’. Weights are not normalized. Default is None.
  • target_labels (1D ndarray, optional) – Target labels. Arrange new array following the ordering of labels in the target_labels. When None, new array is arranged in ascending order of labels. Default is None.
  • red_op (str or callable, optional) – How to summarize data. If str, options are: {‘min’, ‘max’, ‘sum’, ‘mean’, ‘median’, ‘mode’, ‘average’}. If callable, it should receive a 1D array of values, array of weights (or None) and return a scalar value. Default is ‘mean’.
  • dtype (dtype, optional) – Data type of output array. When None, if red_op in {‘min’, ‘max’, ‘sum’, ‘mode’}, output is same type as values, otherwise output is float. Default is None.
  • axis ({0, 1}, optional) – If axis == 0, apply to each row (reduce number of columns per row). Otherwise, apply to each column (reduce number of rows per column). Default is 0.
Returns:

target_values (ndarray) – Summarized target values.