def _get_artemis123_info(fname):
    'Function for extracting info from artemis123 header files.'
    fname = op.splitext(op.abspath(fname))[0]
    header = (fname + '.txt')
    logger.info('Reading header...')
    chan_keys = ['name', 'scaling', 'FLL_Gain', 'FLL_Mode', 'FLL_HighPass', 'FLL_AutoReset', 'FLL_ResetLock']
    header_info = dict()
    header_info['filter_hist'] = []
    header_info['comments'] = ''
    header_info['channels'] = []
    with open(header, 'r') as fid:
        sectionFlag = 0
        for line in fid:
            if ((not line.strip()) or ((sectionFlag == 2) and line.startswith('DAQ Map'))):
                continue
            if line.startswith('<end'):
                sectionFlag = 0
            elif line.startswith('<start main header>'):
                sectionFlag = 1
            elif line.startswith('<start per channel header>'):
                sectionFlag = 2
            elif line.startswith('<start comments>'):
                sectionFlag = 3
            elif line.startswith('<start length>'):
                sectionFlag = 4
            elif line.startswith('<start filtering history>'):
                sectionFlag = 5
            elif (sectionFlag == 1):
                values = line.strip().split('\t')
                if (len(values) == 1):
                    values.append('')
                header_info[values[0]] = values[1]
            elif (sectionFlag == 2):
                values = line.strip().split('\t')
                if (len(values) != 7):
                    raise IOError((('Error parsing line \n\t:%s\n' % line) + ('from file %s' % header)))
                tmp = dict()
                for (k, v) in zip(chan_keys, values):
                    tmp[k] = v
                header_info['channels'].append(tmp)
            elif (sectionFlag == 3):
                header_info['comments'] = ('%s%s' % (header_info['comments'], line.strip()))
            elif (sectionFlag == 4):
                header_info['num_samples'] = int(line.strip())
            elif (sectionFlag == 5):
                header_info['filter_hist'].append(line.strip())
    for k in ['Temporal Filter Active?', 'Decimation Active?', 'Spatial Filter Active?']:
        if (header_info[k] != 'FALSE'):
            warn(('%s - set to but is not supported' % k))
    if header_info['filter_hist']:
        warn(('Non-Empty Filter histroy found, BUT is not supported' % k))
    info = _empty_info(float(header_info['Rate Out']))
    try:
        date = datetime.datetime.strptime(op.basename(fname).split('_')[2], '%Y-%m-%d-%Hh-%Mm')
        meas_date = calendar.timegm(date.utctimetuple())
    except Exception:
        meas_date = None
    subject_info = {'id': header_info['Subject ID']}
    desc = ''
    for k in ['Purpose', 'Notes']:
        desc += '{} : {}\n'.format(k, header_info[k])
    desc += 'Comments : {}'.format(header_info['comments'])
    info = _empty_info(float(header_info['Rate Out']))
    info.update({'filename': fname, 'meas_date': meas_date, 'description': desc, 'buffer_size_sec': 1.0, 'subject_info': subject_info, 'proj_name': header_info['Project Name']})
    ref_mag_names = ['REF_001', 'REF_002', 'REF_003', 'REF_004', 'REF_005', 'REF_006']
    ref_grad_names = ['REF_007', 'REF_008', 'REF_009', 'REF_010', 'REF_011', 'REF_012']
    loc_dict = _load_mne_locs()
    info['chs'] = []
    info['bads'] = []
    for (i, chan) in enumerate(header_info['channels']):
        t = {'cal': float(chan['scaling']), 'ch_name': chan['name'], 'logno': (i + 1), 'scanno': (i + 1), 'range': 1.0, 'unit_mul': FIFF.FIFF_UNITM_NONE, 'coord_frame': FIFF.FIFFV_COORD_DEVICE}
        t['loc'] = loc_dict.get(chan['name'], np.zeros(12))
        if chan['name'].startswith('MEG'):
            t['coil_type'] = FIFF.FIFFV_COIL_ARTEMIS123_GRAD
            t['kind'] = FIFF.FIFFV_MEG_CH
            t['unit'] = FIFF.FIFF_UNIT_T
            t['unit_mul'] = FIFF.FIFF_UNITM_F
        elif (chan['name'] in ref_mag_names):
            t['coil_type'] = FIFF.FIFFV_COIL_ARTEMIS123_REF_MAG
            t['kind'] = FIFF.FIFFV_REF_MEG_CH
            t['unit'] = FIFF.FIFF_UNIT_T
            t['unit_mul'] = FIFF.FIFF_UNITM_F
        elif (chan['name'] in ref_grad_names):
            t['coil_type'] = FIFF.FIFFV_COIL_ARTEMIS123_REF_GRAD
            t['kind'] = FIFF.FIFFV_REF_MEG_CH
            t['unit'] = FIFF.FIFF_UNIT_T
            t['unit_mul'] = FIFF.FIFF_UNITM_F
        elif chan['name'].startswith('REF'):
            t['coil_type'] = FIFF.FIFFV_COIL_NONE
            t['kind'] = FIFF.FIFFV_MISC_CH
            t['unit'] = FIFF.FIFF_UNIT_V
            info['bads'].append(t['ch_name'])
        elif chan['name'].startswith(('AUX', 'TRG', 'MIO')):
            t['coil_type'] = FIFF.FIFFV_COIL_NONE
            t['unit'] = FIFF.FIFF_UNIT_V
            if chan['name'].startswith('TRG'):
                t['kind'] = FIFF.FIFFV_STIM_CH
            else:
                t['kind'] = FIFF.FIFFV_MISC_CH
        else:
            raise ValueError(('Channel does not match expected' + (' channel Types:"%s"' % chan['name'])))
        t['cal'] *= (10 ** t['unit_mul'])
        t['unit_mul'] = FIFF.FIFF_UNITM_NONE
        info['chs'].append(t)
        if (chan['FLL_ResetLock'] == 'TRUE'):
            info['bads'].append(t['ch_name'])
    info['bads'] = list(set(info['bads']))
    info._update_redundant()
    return (info, header_info)
Function for extracting info from artemis123 header files.
def _get_artemis123_info(fname):
    
    fname = op.splitext(op.abspath(fname))[0]
    header = (fname + '.txt')
    logger.info('Reading header...')
    chan_keys = ['name', 'scaling', 'FLL_Gain', 'FLL_Mode', 'FLL_HighPass', 'FLL_AutoReset', 'FLL_ResetLock']
    header_info = dict()
    header_info['filter_hist'] = []
    header_info['comments'] = 
    header_info['channels'] = []
    with open(header, 'r') as fid:
        sectionFlag = 0
        for line in fid:
            if ((not line.strip()) or ((sectionFlag == 2) and line.startswith('DAQ Map'))):
                continue
            if line.startswith('<end'):
                sectionFlag = 0
            elif line.startswith('<start main header>'):
                sectionFlag = 1
            elif line.startswith('<start per channel header>'):
                sectionFlag = 2
            elif line.startswith('<start comments>'):
                sectionFlag = 3
            elif line.startswith('<start length>'):
                sectionFlag = 4
            elif line.startswith('<start filtering history>'):
                sectionFlag = 5
            elif (sectionFlag == 1):
                values = line.strip().split('\t')
                if (len(values) == 1):
                    values.append()
                header_info[values[0]] = values[1]
            elif (sectionFlag == 2):
                values = line.strip().split('\t')
                if (len(values) != 7):
                    raise IOError((('Error parsing line \n\t:%s\n' % line) + ('from file %s' % header)))
                tmp = dict()
                for (k, v) in zip(chan_keys, values):
                    tmp[k] = v
                header_info['channels'].append(tmp)
            elif (sectionFlag == 3):
                header_info['comments'] = ('%s%s' % (header_info['comments'], line.strip()))
            elif (sectionFlag == 4):
                header_info['num_samples'] = int(line.strip())
            elif (sectionFlag == 5):
                header_info['filter_hist'].append(line.strip())
    for k in ['Temporal Filter Active?', 'Decimation Active?', 'Spatial Filter Active?']:
        if (header_info[k] != 'FALSE'):
            warn(('%s - set to but is not supported' % k))
    if header_info['filter_hist']:
        warn(('Non-Empty Filter histroy found, BUT is not supported' % k))
    info = _empty_info(float(header_info['Rate Out']))
    try:
        date = datetime.datetime.strptime(op.basename(fname).split('_')[2], '%Y-%m-%d-%Hh-%Mm')
        meas_date = calendar.timegm(date.utctimetuple())
    except Exception:
        meas_date = None
    subject_info = {'id': header_info['Subject ID']}
    desc = 
    for k in ['Purpose', 'Notes']:
        desc += '{} : {}\n'.format(k, header_info[k])
    desc += 'Comments : {}'.format(header_info['comments'])
    info = _empty_info(float(header_info['Rate Out']))
    info.update({'filename': fname, 'meas_date': meas_date, 'description': desc, 'buffer_size_sec': 1.0, 'subject_info': subject_info, 'proj_name': header_info['Project Name']})
    ref_mag_names = ['REF_001', 'REF_002', 'REF_003', 'REF_004', 'REF_005', 'REF_006']
    ref_grad_names = ['REF_007', 'REF_008', 'REF_009', 'REF_010', 'REF_011', 'REF_012']
    loc_dict = _load_mne_locs()
    info['chs'] = []
    info['bads'] = []
    for (i, chan) in enumerate(header_info['channels']):
        t = {'cal': float(chan['scaling']), 'ch_name': chan['name'], 'logno': (i + 1), 'scanno': (i + 1), 'range': 1.0, 'unit_mul': FIFF.FIFF_UNITM_NONE, 'coord_frame': FIFF.FIFFV_COORD_DEVICE}
        t['loc'] = loc_dict.get(chan['name'], np.zeros(12))
        if chan['name'].startswith('MEG'):
            t['coil_type'] = FIFF.FIFFV_COIL_ARTEMIS123_GRAD
            t['kind'] = FIFF.FIFFV_MEG_CH
            t['unit'] = FIFF.FIFF_UNIT_T
            t['unit_mul'] = FIFF.FIFF_UNITM_F
        elif (chan['name'] in ref_mag_names):
            t['coil_type'] = FIFF.FIFFV_COIL_ARTEMIS123_REF_MAG
            t['kind'] = FIFF.FIFFV_REF_MEG_CH
            t['unit'] = FIFF.FIFF_UNIT_T
            t['unit_mul'] = FIFF.FIFF_UNITM_F
        elif (chan['name'] in ref_grad_names):
            t['coil_type'] = FIFF.FIFFV_COIL_ARTEMIS123_REF_GRAD
            t['kind'] = FIFF.FIFFV_REF_MEG_CH
            t['unit'] = FIFF.FIFF_UNIT_T
            t['unit_mul'] = FIFF.FIFF_UNITM_F
        elif chan['name'].startswith('REF'):
            t['coil_type'] = FIFF.FIFFV_COIL_NONE
            t['kind'] = FIFF.FIFFV_MISC_CH
            t['unit'] = FIFF.FIFF_UNIT_V
            info['bads'].append(t['ch_name'])
        elif chan['name'].startswith(('AUX', 'TRG', 'MIO')):
            t['coil_type'] = FIFF.FIFFV_COIL_NONE
            t['unit'] = FIFF.FIFF_UNIT_V
            if chan['name'].startswith('TRG'):
                t['kind'] = FIFF.FIFFV_STIM_CH
            else:
                t['kind'] = FIFF.FIFFV_MISC_CH
        else:
            raise ValueError(('Channel does not match expected' + (' channel Types:"%s"' % chan['name'])))
        t['cal'] *= (10 ** t['unit_mul'])
        t['unit_mul'] = FIFF.FIFF_UNITM_NONE
        info['chs'].append(t)
        if (chan['FLL_ResetLock'] == 'TRUE'):
            info['bads'].append(t['ch_name'])
    info['bads'] = list(set(info['bads']))
    info._update_redundant()
    return (info, header_info)