brainspace.utils.parcellation.map_to_labels

brainspace.utils.parcellation.map_to_labels(source_val, target_lab, mask=None, fill=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_val,)) – Source array of values.
  • target_lab (ndarray, shape = (n_lab,)) – Target labels.
  • mask (ndarray, shape = (n_lab,), optional) – If mask is not None, only consider target labels in mask. Default is None.
  • fill (float, optional) – Value used to fill elements outside the mask. Only used if mask is not None. Default is 0.
  • source_lab (ndarray, shape = (n_val,), 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_lab,)) – Target array with corresponding source values.