

def get_tris(self, tris, vertices=None):
    "Get the source space's triangles inside the label\n\n        Parameters\n        ----------\n        tris : ndarray of int, shape (n_tris, 3)\n            The set of triangles corresponding to the vertices in a\n            source space.\n        vertices : ndarray of int, shape (n_vertices,) | None\n            The set of vertices to compare the label to. If None, equals to\n            ``np.arange(10242)``. Defaults to None.\n\n        Returns\n        -------\n        label_tris : ndarray of int, shape (n_tris, 3)\n            The subset of tris used by the label\n        "
    vertices_ = self.get_vertices_used(vertices)
    selection = np.all(in1d(tris, vertices_).reshape(tris.shape), axis=1)
    label_tris = tris[selection]
    if (len(np.unique(label_tris)) < len(vertices_)):
        logger.info('Surprising label structure. Trying to repair triangles.')
        dropped_vertices = np.setdiff1d(vertices_, label_tris)
        n_dropped = len(dropped_vertices)
        assert (n_dropped == (len(vertices_) - len(np.unique(label_tris))))
        add_tris = (dropped_vertices + np.zeros((len(dropped_vertices), 3), dtype=int).T)
        label_tris = np.r_[(label_tris, add_tris.T)]
        assert (len(np.unique(label_tris)) == len(vertices_))
    return label_tris

dataset/ETHPy150Open mne-tools/mne-python/mne/label.py Label.get_tris/original