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

Method split

mne/label.py:721–765  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 15

parse_nameFunction · 0.80
ensure_headers.pyFile · 0.80
mainFunction · 0.80
_update_specifiersFunction · 0.80
_prettify_pinFunction · 0.80
remove_spacesFunction · 0.80

Calls 2

_split_label_contigFunction · 0.85
split_labelFunction · 0.85

Tested by 15

pytest_configureFunction · 0.64
pytest_sessionfinishFunction · 0.64
pytest_runtest_callFunction · 0.64
_explain_exceptionFunction · 0.64
test_sys_info_basicFunction · 0.64
test_sys_info_completeFunction · 0.64
test_run_subprocessFunction · 0.64
remove_tracebackFunction · 0.64
looks_stableFunction · 0.64
test_setup_source_spaceFunction · 0.64