

def _get_annot_fname(annot_fname, subject, hemi, parc, subjects_dir):
    'Helper function to get the .annot filenames and hemispheres'
    if (annot_fname is not None):
        hemis = [op.basename(annot_fname)[:2]]
        if (hemis[0] not in ['lh', 'rh']):
            raise ValueError('Could not determine hemisphere from filename, filename has to start with "lh" or "rh".')
        annot_fname = [annot_fname]
    else:
        if (hemi not in ['lh', 'rh', 'both']):
            raise ValueError('hemi has to be "lh", "rh", or "both"')
        if (hemi == 'both'):
            hemis = ['lh', 'rh']
        else:
            hemis = [hemi]
        subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
        dst = op.join(subjects_dir, subject, 'label', ('%%s.%s.annot' % parc))
        annot_fname = [(dst % hemi_) for hemi_ in hemis]
    return (annot_fname, hemis)

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