MCPcopy
hub / github.com/mne-tools/mne-python / write_labels_to_annot

Function write_labels_to_annot

mne/label.py:2625–2880  ·  view source on GitHub ↗

r"""Create a FreeSurfer annotation from a list of labels. Parameters ---------- labels : list with instances of mne.Label The labels to create a parcellation from. %(subject)s parc : str | None The parcellation name to use. overwrite : bool Overwrite

(
    labels,
    subject=None,
    parc=None,
    overwrite=False,
    subjects_dir=None,
    annot_fname=None,
    colormap="hsv",
    hemi="both",
    sort=True,
    table_name=_DEFAULT_TABLE_NAME,
    verbose=None,
)

Source from the content-addressed store, hash-verified

2623
2624@verbose
2625def write_labels_to_annot(
2626 labels,
2627 subject=None,
2628 parc=None,
2629 overwrite=False,
2630 subjects_dir=None,
2631 annot_fname=None,
2632 colormap="hsv",
2633 hemi="both",
2634 sort=True,
2635 table_name=_DEFAULT_TABLE_NAME,
2636 verbose=None,
2637):
2638 r"""Create a FreeSurfer annotation from a list of labels.
2639
2640 Parameters
2641 ----------
2642 labels : list with instances of mne.Label
2643 The labels to create a parcellation from.
2644 %(subject)s
2645 parc : str | None
2646 The parcellation name to use.
2647 overwrite : bool
2648 Overwrite files if they already exist.
2649 %(subjects_dir)s
2650 annot_fname : str | None
2651 Filename of the ``.annot file``. If not None, only this file is written
2652 and the arguments ``parc`` and ``subject`` are ignored.
2653 colormap : str
2654 Colormap to use to generate label colors for labels that do not
2655 have a color specified.
2656 hemi : ``'both'`` | ``'lh'`` | ``'rh'``
2657 The hemisphere(s) for which to write \*.annot files (only applies if
2658 annot_fname is not specified; default is 'both').
2659 sort : bool
2660 If True (default), labels will be sorted by name before writing.
2661
2662 .. versionadded:: 0.21.0
2663 table_name : str
2664 The table name to use for the colortable.
2665
2666 .. versionadded:: 0.21.0
2667 %(verbose)s
2668
2669 See Also
2670 --------
2671 read_labels_from_annot
2672
2673 Notes
2674 -----
2675 Vertices that are not covered by any of the labels are assigned to a label
2676 named ``"unknown"``.
2677 """
2678 logger.info("Writing labels to parcellation...")
2679
2680 subjects_dir = get_subjects_dir(subjects_dir)
2681 if subjects_dir is not None:
2682 subjects_dir = str(subjects_dir)

Callers 4

test_annot_ioFunction · 0.90
test_fetch_parcellationsFunction · 0.90

Calls 12

get_subjects_dirFunction · 0.85
_get_annot_fnameFunction · 0.85
warnFunction · 0.85
_n_colorsFunction · 0.85
read_surfaceFunction · 0.85
setFunction · 0.85
_write_annotFunction · 0.85
infoMethod · 0.80
countMethod · 0.80
insertMethod · 0.80
appendMethod · 0.45
sumMethod · 0.45

Tested by 3

test_annot_ioFunction · 0.72
test_fetch_parcellationsFunction · 0.72