Split the Label into two or more parts. Parameters ---------- parts : int >= 2 | tuple of str | str Number of labels to create (default is 2), or tuple of strings specifying label names for new labels (from posterior to anterior), or 'cont
(self, parts=2, subject=None, subjects_dir=None, freesurfer=False)
| 719 | |
| 720 | @fill_doc |
| 721 | def split(self, parts=2, subject=None, subjects_dir=None, freesurfer=False): |
| 722 | """Split the Label into two or more parts. |
| 723 | |
| 724 | Parameters |
| 725 | ---------- |
| 726 | parts : int >= 2 | tuple of str | str |
| 727 | Number of labels to create (default is 2), or tuple of strings |
| 728 | specifying label names for new labels (from posterior to anterior), |
| 729 | or 'contiguous' to split the label into connected components. |
| 730 | If a number or 'contiguous' is specified, names of the new labels |
| 731 | will be the input label's name with div1, div2 etc. appended. |
| 732 | %(subject_label)s |
| 733 | %(subjects_dir)s |
| 734 | freesurfer : bool |
| 735 | By default (``False``) ``split_label`` uses an algorithm that is |
| 736 | slightly optimized for performance and numerical precision. Set |
| 737 | ``freesurfer`` to ``True`` in order to replicate label splits from |
| 738 | FreeSurfer's ``mris_divide_parcellation``. |
| 739 | |
| 740 | Returns |
| 741 | ------- |
| 742 | labels : list of Label, shape (n_parts,) |
| 743 | The labels, starting from the lowest to the highest end of the |
| 744 | projection axis. |
| 745 | |
| 746 | Notes |
| 747 | ----- |
| 748 | If using 'contiguous' split, you must ensure that the label being split |
| 749 | uses the same triangular resolution as the surface mesh files in |
| 750 | ``subjects_dir`` Also, some small fringe labels may be returned that |
| 751 | are close (but not connected) to the large components. |
| 752 | |
| 753 | The spatial split finds the label's principal eigen-axis on the |
| 754 | spherical surface, projects all label vertex coordinates onto this |
| 755 | axis, and divides them at regular spatial intervals. |
| 756 | """ |
| 757 | if isinstance(parts, str) and parts == "contiguous": |
| 758 | return _split_label_contig(self, subject, subjects_dir) |
| 759 | elif isinstance(parts, tuple | int): |
| 760 | return split_label(self, parts, subject, subjects_dir, freesurfer) |
| 761 | else: |
| 762 | raise ValueError( |
| 763 | "Need integer, tuple of strings, or string " |
| 764 | f"('contiguous'). Got {type(parts)})" |
| 765 | ) |
| 766 | |
| 767 | def get_vertices_used(self, vertices=None): |
| 768 | """Get the source space's vertices inside the label. |