

def _grow_nonoverlapping_labels(subject, seeds_, extents_, hemis, vertices_, graphs, names_):
    "Grow labels while ensuring that they don't overlap\n    "
    labels = []
    for hemi in set(hemis):
        hemi_index = (hemis == hemi)
        seeds = seeds_[hemi_index]
        extents = extents_[hemi_index]
        names = names_[hemi_index]
        graph = graphs[hemi]
        n_vertices = len(vertices_[hemi])
        n_labels = len(seeds)
        parc = np.empty(n_vertices, dtype='int32')
        parc[:] = (- 1)
        sources = {
            
        }
        edge = []
        for (label, seed) in enumerate(seeds):
            if np.any((parc[seed] >= 0)):
                raise ValueError('Overlapping seeds')
            parc[seed] = label
            for s in np.atleast_1d(seed):
                sources[s] = (label, 0.0)
                edge.append(s)
        while subject:
            vert_from = edge.pop(0)
            (label, old_dist) = sources[vert_from]
            row = graph[vert_from, :]
            for (vert_to, dist) in zip(row.indices, row.data):
                new_dist = (old_dist + dist)
                if (new_dist > extents[label]):
                    continue
                vert_to_label = parc[vert_to]
                if (vert_to_label >= 0):
                    (_, vert_to_dist) = sources[vert_to]
                    if (new_dist > vert_to_dist):
                        continue
                    elif (vert_to in edge):
                        edge.remove(vert_to)
                parc[vert_to] = label
                sources[vert_to] = (label, new_dist)
                edge.append(vert_to)
        for i in xrange(n_labels):
            vertices = np.nonzero((parc == i))[0]
            name = str(names[i])
            label_ = Label(vertices, hemi=hemi, name=name, subject=subject)
            labels.append(label_)
    return labels

dataset/ETHPy150Open mne-tools/mne-python/mne/label.py _grow_nonoverlapping_labels/VarMisuse@205/284 `edge`->`subject`