

@verbose
def write_label(filename, label, verbose=None):
    "Write a FreeSurfer label\n\n    Parameters\n    ----------\n    filename : string\n        Path to label file to produce.\n    label : Label\n        The label object to save.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n\n    Notes\n    -----\n    Note that due to file specification limitations, the Label's subject and\n    color attributes are not saved to disk.\n\n    See Also\n    --------\n    write_labels_to_annot\n    "
    hemi = label.hemi
    (path_head, name) = op.split(filename)
    if name.endswith('.label'):
        name = name[:(- 6)]
    if (not (name.startswith(hemi) or name.endswith(hemi))):
        name += ('-' + hemi)
    filename = (op.join(path_head, name) + '.label')
    logger.info(('Saving label to : %s' % filename))
    with open(filename, 'wb') as fid:
        n_vertices = len(label.vertices)
        data = np.zeros((n_vertices, 5), dtype=np.float)
        data[:, 0] = label.vertices
        data[:, 1:4] = (1000.0 * label.pos)
        data[:, 4] = label.values
        fid.write(b(('#%s\n' % label.comment)))
        fid.write(b(('%d\n' % n_vertices)))
        for d in data:
            fid.write(b(('%d %f %f %f %f\n' % tuple(d))))
    return label

dataset/ETHPy150Open mne-tools/mne-python/mne/label.py write_label/original