mne.write_labels_to_annot(labels, subject=None, parc=None, overwrite=False, subjects_dir=None, annot_fname=None, colormap='hsv', hemi='both', sort=True, table_name='MNE-Python Colortable', verbose=None)[source]

Create a FreeSurfer annotation from a list of labels.

labelslist with instances of mne.Label

The labels to create a parcellation from.

subjectstr | None

The subject for which to write the parcellation.

parcstr | None

The parcellation name to use.


Overwrite files if they already exist.

subjects_dirstr | None

The path to the freesurfer subjects reconstructions. It corresponds to Freesurfer environment variable SUBJECTS_DIR.

annot_fnamestr | None

Filename of the .annot file. If not None, only this file is written and ‘parc’ and ‘subject’ are ignored.


Colormap to use to generate label colors for labels that do not have a color specified.

hemi‘both’ | ‘lh’ | ‘rh’

The hemisphere(s) for which to write *.annot files (only applies if annot_fname is not specified; default is ‘both’).


If True (default), labels will be sorted by name before writing.

New in version 0.21.0.


The table name to use for the colortable.

New in version 0.21.0.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more). If used, it should be passed as a keyword-argument only.


Vertices that are not covered by any of the labels are assigned to a label named “unknown”.

Examples using mne.write_labels_to_annot