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

Class BiHemiLabel

mne/label.py:987–1084  ·  view source on GitHub ↗

A freesurfer/MNE label with vertices in both hemispheres. Parameters ---------- lh : Label Label for the left hemisphere. rh : Label Label for the right hemisphere. name : None | str Name for the label. color : None | color Label color and alp

Source from the content-addressed store, hash-verified

985
986
987class BiHemiLabel:
988 """A freesurfer/MNE label with vertices in both hemispheres.
989
990 Parameters
991 ----------
992 lh : Label
993 Label for the left hemisphere.
994 rh : Label
995 Label for the right hemisphere.
996 name : None | str
997 Name for the label.
998 color : None | color
999 Label color and alpha (e.g., ``(1., 0., 0., 1.)`` for red).
1000 Note that due to file specification limitations, the color isn't saved
1001 to or loaded from files written to disk.
1002
1003 Attributes
1004 ----------
1005 lh : Label
1006 Label for the left hemisphere.
1007 rh : Label
1008 Label for the right hemisphere.
1009 name : None | str
1010 A name for the label. It is OK to change that attribute manually.
1011 subject : str | None
1012 The name of the subject.
1013 """
1014
1015 def __init__(self, lh, rh, name=None, color=None):
1016 if lh.subject != rh.subject:
1017 raise ValueError(
1018 f"lh.subject ({lh.subject}) and rh.subject ({rh.subject}) must agree"
1019 )
1020 self.lh = lh
1021 self.rh = rh
1022 self.name = name
1023 self.subject = lh.subject
1024 self.color = color
1025 self.hemi = "both"
1026
1027 def __repr__(self): # noqa: D105
1028 name = "unknown, " if self.subject is None else self.subject + ", "
1029 name += repr(self.name) if self.name is not None else "unnamed"
1030 return (
1031 f"<BiHemiLabel | {name}, "
1032 f"lh : {len(self.lh)} vertices, rh : {self.rh} vertices>"
1033 )
1034
1035 def __len__(self):
1036 """Return the number of vertices.
1037
1038 Returns
1039 -------
1040 n_vertices : int
1041 The number of vertices.
1042 """
1043 return len(self.lh) + len(self.rh)
1044

Callers 4

test_tfr_multi_labelFunction · 0.90
__add__Method · 0.85
__add__Method · 0.85
__sub__Method · 0.85

Calls

no outgoing calls

Tested by 1

test_tfr_multi_labelFunction · 0.72