netneurotools.freesurfer.spin_parcels
- netneurotools.freesurfer.spin_parcels(*, lhannot, rhannot, version='fsaverage', n_rotate=1000, spins=None, drop=None, verbose=False, **kwargs)[source]
Rotate parcels in {lh,rh}annot and re-assigns based on maximum overlap.
Vertex labels are rotated with
netneurotools.stats.gen_spinsamples()
and a new label is assigned to each parcel based on the region maximally overlapping with its boundaries.- Parameters:
{lh (str) – Path to .annot file containing labels to parcels on the {left,right} hemisphere
rh}annot (str) – Path to .annot file containing labels to parcels on the {left,right} hemisphere
version (str, optional) – Specifies which version of fsaverage provided annotation files correspond to. Must be one of {‘fsaverage’, ‘fsaverage3’, ‘fsaverage4’, ‘fsaverage5’, ‘fsaverage6’}. Default: ‘fsaverage’
n_rotate (int, optional) – Number of rotations to generate. Default: 1000
spins (array_like, optional) – Pre-computed spins to use instead of generating them on the fly. If not provided will use other provided parameters to create them. Default: None
drop (list, optional) – Specifies regions in {lh,rh}annot that are not present in data. NaNs will be inserted in place of the these regions in the returned data. If not specified, parcels defined in netneurotools.freesurfer.FSIGNORE are assumed to not be present. Default: None
seed ({int, np.random.RandomState instance, None}, optional) – Seed for random number generation. Default: None
verbose (bool, optional) – Whether to print occasional status messages. Default: False
return_cost (bool, optional) – Whether to return cost array (specified as Euclidean distance) for each coordinate for each rotation. Default: True
kwargs (key-value pairs) – Keyword arguments passed to netneurotools.stats.gen_spinsamples
- Returns:
spinsamples ((N, n_rotate) numpy.ndarray) – Resampling matrix to use in permuting data parcellated with labels from {lh,rh}annot, where N is the number of parcels. Indices of -1 indicate that the parcel was completely encompassed by regions in drop and should be ignored.
cost ((N, n_rotate,) numpy.ndarray) – Cost (specified as Euclidean distance) of re-assigning each coordinate for every rotation in spinsamples. Only provided if return_cost is True.