brainspace.utils.parcellation.map_to_labels

brainspace.utils.parcellation.map_to_labels(source_val, target_lab, mask=None, fill=0, axis=0, source_lab=None)[source]

Map data in source to target according to their labels.

Target labels are sorted in ascending order, such that the smallest label indexes the value at position 0 in source_val. If source_lab is specified, any label in target_lab must be in source_lab.

Parameters:
  • source_val (ndarray, shape = (n_values,) or (n_samples, n_values)) – Source array of values.
  • target_lab (ndarray, shape = (n_labels,)) – Target labels.
  • mask (int or ndarray, shape = (n_labels,), optional) – If mask is not None, only consider target labels in mask. If int, it indicates the label denoting label to discard. Default is None.
  • fill (float, optional) – Value used to fill elements outside the mask. Only used if mask is not None. Default is 0.
  • axis ({0, 1}, optional) – If axis == 0, map rows. Otherwise, map columns. Default is 0.
  • source_lab (ndarray, shape = (n_values,), optional) – Source labels for source values. If None, use unique labels in target_lab in ascending order. Default is None.
Returns:

target_val (ndarray, shape = (n_labels,) or (n_samples, n_labels)) – Target array with corresponding source values.