mne.random_parcellation#

mne.random_parcellation(subject, n_parcel, hemi, subjects_dir=None, surface='white', *, rng=None, random_state=None)[source]#

Generate random cortex parcellation by growing labels.

This function generates a number of labels which don’t intersect and cover the whole surface. Regions are growing around randomly chosen seeds.

Parameters:
subjectstr

The FreeSurfer subject name.

n_parcelint

Total number of cortical parcels.

hemistr

Hemisphere id (ie 'lh', 'rh', 'both'). In the case of 'both', both hemispheres are processed with (n_parcel // 2) parcels per hemisphere.

subjects_dirpath-like | None

The path to the directory containing the FreeSurfer subjects reconstructions. If None, defaults to the SUBJECTS_DIR environment variable.

surfacestr

The surface along which to do the computations, defaults to 'white' (the gray-white matter boundary).

rngNone | int | instance of Generator | RandomState

The random number generator (RNG). If None (default), a new numpy.random.Generator seeded from entropy is used. Pass an int or a numpy.random.Generator for reproducible results, or a legacy RandomState to control the random-number stream or for interoperability with third-party code such as scikit-learn that does not accept generators. An integer seed uses numpy.random.default_rng() and therefore produces a different stream than the same integer passed to a legacy random_state or seed parameter.

New in v1.13.

random_stateNone | int | instance of RandomState

Supported for compatibility. New code should use rng. If None, NumPy’s global RandomState is used.

Returns:
labelslist of Label

Random cortex parcellation.