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,
)
| 2623 | |
| 2624 | @verbose |
| 2625 | def 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) |