@verbose
def get_kit_info(rawfile, allow_unknown_format, standardize_names=None, verbose=None):
    'Extract all the information from the sqd/con file.\n\n    Parameters\n    ----------\n    rawfile : str\n        KIT file to be read.\n    allow_unknown_format : bool\n        Force reading old data that is not officially supported. Alternatively,\n        read and re-save the data with the KIT MEG Laboratory application.\n    %(standardize_names)s\n    %(verbose)s\n\n    Returns\n    -------\n    info : instance of Info\n        An Info for the instance.\n    sqd : dict\n        A dict containing all the sqd parameter settings.\n    '
    sqd = dict()
    sqd['rawfile'] = rawfile
    unsupported_format = False
    sqd['dirs'] = dirs = list()
    with open(rawfile, 'rb', buffering=0) as fid:
        dirs.append(_read_dir(fid))
        dirs.extend((_read_dir(fid) for _ in range((dirs[0]['count'] - 1))))
        assert (len(dirs) == dirs[KIT.DIR_INDEX_DIR]['count'])
        fid.seek(dirs[KIT.DIR_INDEX_SYSTEM]['offset'])
        (version, revision) = unpack('2i', fid.read((2 * KIT.INT)))
        if ((version < 2) or ((version == 2) and (revision < 3))):
            version_string = ('V%iR%03i' % (version, revision))
            if allow_unknown_format:
                unsupported_format = True
                logger.warning('Force loading KIT format %s', version_string)
            else:
                raise UnsupportedKITFormat(version_string, ('SQD file format %s is not officially supported. Set allow_unknown_format=True to load it anyways.' % (version_string,)))
        sysid = unpack('i', fid.read(KIT.INT))[0]
        system_name = unpack('128s', fid.read(128))[0].decode()
        model_name = unpack('128s', fid.read(128))[0].decode()
        sqd['nchan'] = channel_count = unpack('i', fid.read(KIT.INT))[0]
        comment = unpack('256s', fid.read(256))[0].decode()
        (create_time, last_modified_time) = unpack('2i', fid.read((2 * KIT.INT)))
        fid.seek((KIT.INT * 3), SEEK_CUR)
        dewar_style = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 3), SEEK_CUR)
        fll_type = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 3), SEEK_CUR)
        trigger_type = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 3), SEEK_CUR)
        adboard_type = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 29), SEEK_CUR)
        if ((version < 2) or ((version == 2) and (revision <= 3))):
            adc_range = float(unpack('i', fid.read(KIT.INT))[0])
        else:
            adc_range = unpack('d', fid.read(KIT.DOUBLE))[0]
        (adc_polarity, adc_allocated, adc_stored) = unpack('3i', fid.read((3 * KIT.INT)))
        system_name = system_name.replace('\x00', '')
        system_name = system_name.strip().replace('\n', '/')
        model_name = model_name.replace('\x00', '')
        model_name = model_name.strip().replace('\n', '/')
        full_version = f'V{version:d}R{revision:03d}'
        logger.debug('SQD file basic information:')
        logger.debug('Meg160 version = %s', full_version)
        logger.debug('System ID      = %i', sysid)
        logger.debug('System name    = %s', system_name)
        logger.debug('Model name     = %s', model_name)
        logger.debug('Channel count  = %i', channel_count)
        logger.debug('Comment        = %s', comment)
        logger.debug('Dewar style    = %i', dewar_style)
        logger.debug('FLL type       = %i', fll_type)
        logger.debug('Trigger type   = %i', trigger_type)
        logger.debug('A/D board type = %i', adboard_type)
        logger.debug('ADC range      = +/-%s[V]', (adc_range / 2.0))
        logger.debug('ADC allocate   = %i[bit]', adc_allocated)
        logger.debug('ADC bit        = %i[bit]', adc_stored)
        description = f'{system_name} ({sysid}) {full_version} {model_name}'
        sqd['dtype'] = np.dtype(getattr(np, f'int{adc_allocated}'))
        if (fll_type not in KIT.FLL_SETTINGS):
            fll_types = sorted(KIT.FLL_SETTINGS.keys())
            use_fll_type = fll_types[(np.searchsorted(fll_types, fll_type) - 1)]
            warn(('Unknown site filter settings (FLL) for system "%s" model "%s" (ID %s), will assume FLL %d->%d, check your data for correctness, including channel scales and filter settings!' % (system_name, model_name, sysid, fll_type, use_fll_type)))
            fll_type = use_fll_type
        chan_dir = dirs[KIT.DIR_INDEX_CHANNELS]
        (chan_offset, chan_size) = (chan_dir['offset'], chan_dir['size'])
        sqd['channels'] = channels = []
        exg_gains = list()
        for i in range(channel_count):
            fid.seek((chan_offset + (chan_size * i)))
            (channel_type,) = unpack('i', fid.read(KIT.INT))
            if ((sysid == 52) and (i < 160) and (channel_type == KIT.CHANNEL_NULL)):
                channel_type = KIT.CHANNEL_MAGNETOMETER_REFERENCE
            if (channel_type in KIT.CHANNELS_MEG):
                if (channel_type not in KIT.CH_TO_FIFF_COIL):
                    raise NotImplementedError(('KIT channel type %i can not be read. Please contact the mne-python developers.' % channel_type))
                channels.append({'type': channel_type, 'loc': np.fromfile(fid, dtype='d', count=5)})
                if (channel_type in KIT.CHANNEL_NAME_NCHAR):
                    fid.seek(16, SEEK_CUR)
                    channels[(- 1)]['name'] = _read_name(fid, channel_type)
            elif (channel_type in KIT.CHANNELS_MISC):
                (channel_no,) = unpack('i', fid.read(KIT.INT))
                fid.seek(4, SEEK_CUR)
                name = _read_name(fid, channel_type)
                channels.append({'type': channel_type, 'no': channel_no, 'name': name})
                if (channel_type in (KIT.CHANNEL_EEG, KIT.CHANNEL_ECG)):
                    offset = (6 if (channel_type == KIT.CHANNEL_EEG) else 8)
                    fid.seek(offset, SEEK_CUR)
                    exg_gains.append(np.fromfile(fid, 'd', 1)[0])
            elif (channel_type == KIT.CHANNEL_NULL):
                channels.append({'type': channel_type})
            else:
                raise IOError(('Unknown KIT channel type: %i' % channel_type))
        exg_gains = np.array(exg_gains)
        fid.seek(dirs[KIT.DIR_INDEX_CALIBRATION]['offset'])
        sensitivity = np.fromfile(fid, dtype='d', count=(channel_count * 2))
        sensitivity.shape = (channel_count, 2)
        (channel_offset, channel_gain) = sensitivity.T
        assert (channel_offset == 0).all()
        fid.seek(dirs[KIT.DIR_INDEX_AMP_FILTER]['offset'])
        amp_data = unpack('i', fid.read(KIT.INT))[0]
        if (fll_type >= 100):
            gain1 = ((amp_data & 28672) >> 12)
            gain2 = ((amp_data & 1879048192) >> 28)
            gain3 = ((amp_data & 117440512) >> 24)
            amp_gain = ((KIT.GAINS[gain1] * KIT.GAINS[gain2]) * KIT.GAINS[gain3])
            hpf = ((amp_data & 1792) >> 8)
            lpf = ((amp_data & 458752) >> 16)
            bef = ((amp_data & 3) >> 0)
        else:
            input_gain = ((amp_data & 6144) >> 11)
            output_gain = ((amp_data & 7) >> 0)
            amp_gain = (KIT.GAINS[input_gain] * KIT.GAINS[output_gain])
            hpf = ((amp_data & 7) >> 4)
            lpf = ((amp_data & 1792) >> 8)
            bef = ((amp_data & 49152) >> 14)
        (hpf_options, lpf_options, bef_options) = KIT.FLL_SETTINGS[fll_type]
        sqd['highpass'] = KIT.HPFS[hpf_options][hpf]
        sqd['lowpass'] = KIT.LPFS[lpf_options][lpf]
        sqd['notch'] = KIT.BEFS[bef_options][bef]
        fid.seek(dirs[KIT.DIR_INDEX_ACQ_COND]['offset'])
        (sqd['acq_type'],) = (acq_type,) = unpack('i', fid.read(KIT.INT))
        (sqd['sfreq'],) = unpack('d', fid.read(KIT.DOUBLE))
        if (acq_type == KIT.CONTINUOUS):
            fid.seek(KIT.INT, SEEK_CUR)
            (sqd['n_samples'],) = unpack('i', fid.read(KIT.INT))
        elif ((acq_type == KIT.EVOKED) or (acq_type == KIT.EPOCHS)):
            (sqd['frame_length'],) = unpack('i', fid.read(KIT.INT))
            (sqd['pretrigger_length'],) = unpack('i', fid.read(KIT.INT))
            (sqd['average_count'],) = unpack('i', fid.read(KIT.INT))
            (sqd['n_epochs'],) = unpack('i', fid.read(KIT.INT))
            if (acq_type == KIT.EVOKED):
                sqd['n_samples'] = sqd['frame_length']
            else:
                sqd['n_samples'] = (sqd['frame_length'] * sqd['n_epochs'])
        else:
            raise IOError(('Invalid acquisition type: %i. Your file is neither continuous nor epoched data.' % (acq_type,)))
        dig_dir = dirs[KIT.DIR_INDEX_DIG_POINTS]
        cor_dir = dirs[KIT.DIR_INDEX_COREG]
        dig = dict()
        hsp = list()
        if ((dig_dir['count'] > 0) and (cor_dir['count'] > 0)):
            fid.seek(dig_dir['offset'])
            for _ in range(dig_dir['count']):
                name = _read_name(fid, n=8).strip()
                name = name.lower()
                rr = np.fromfile(fid, 'd', 3)
                if name:
                    assert (name not in dig)
                    dig[name] = rr
                else:
                    hsp.append(rr)
            elp = [dig.pop(key) for key in ('fidnz', 'fidt9', 'fidt10', 'hpi_1', 'hpi_2', 'hpi_3', 'hpi_4')]
            if (('hpi_5' in dig) and dig['hpi_5'].any()):
                elp.append(dig.pop('hpi_5'))
            elp = np.array(elp)
            hsp = np.array(hsp, float).reshape((- 1), 3)
            assert (elp.shape in ((7, 3), (8, 3)))
            fid.seek(cor_dir['offset'])
            mrk = np.zeros(((elp.shape[0] - 3), 3))
            for _ in range(cor_dir['count']):
                done = np.fromfile(fid, np.int32, 1)[0]
                fid.seek(((16 * KIT.DOUBLE) + (16 * KIT.DOUBLE)), SEEK_CUR)
                marker_count = np.fromfile(fid, np.int32, 1)[0]
                if (not done):
                    continue
                assert (marker_count >= len(mrk))
                for mi in range(len(mrk)):
                    (mri_type, meg_type, mri_done, meg_done) = np.fromfile(fid, np.int32, 4)
                    assert meg_done
                    fid.seek((3 * KIT.DOUBLE), SEEK_CUR)
                    mrk[mi] = np.fromfile(fid, 'd', 3)
                fid.seek(256, SEEK_CUR)
            sqd.update(hsp=hsp, elp=elp, mrk=mrk)
    all_names = set((ch.get('name', '') for ch in channels))
    if ((standardize_names is None) and all_names.difference({'', 'EEG'})):
        standardize_names = True
        warn('standardize_names defaults to True in 0.21 but will change to False in 0.22', DeprecationWarning)
    if unsupported_format:
        if (sysid not in LEGACY_AMP_PARAMS):
            raise IOError(('Legacy parameters for system ID %i unavailable' % (sysid,)))
        (adc_range, adc_stored) = LEGACY_AMP_PARAMS[sysid]
    is_meg = np.array([(ch['type'] in KIT.CHANNELS_MEG) for ch in channels])
    ad_to_volt = (adc_range / (2 ** adc_stored))
    ad_to_tesla = ((ad_to_volt / amp_gain) * channel_gain)
    conv_factor = np.where(is_meg, ad_to_tesla, ad_to_volt)
    is_exg = [(ch['type'] in (KIT.CHANNEL_EEG, KIT.CHANNEL_ECG)) for ch in channels]
    exg_gains /= (2 ** (adc_stored - 14))
    conv_factor[is_exg] = exg_gains
    sqd['conv_factor'] = conv_factor[:, np.newaxis]
    info = _empty_info(float(sqd['sfreq']))
    info.update(meas_date=_stamp_to_dt((create_time, 0)), lowpass=sqd['lowpass'], highpass=sqd['highpass'], kit_system_id=sysid, description=description)
    logger.info('Setting channel info structure...')
    info['chs'] = fiff_channels = []
    channel_index = defaultdict((lambda : 0))
    sqd['eeg_dig'] = OrderedDict()
    for (idx, ch) in enumerate(channels, 1):
        if (ch['type'] in KIT.CHANNELS_MEG):
            ch_name = ch.get('name', '')
            if ((ch_name == '') or standardize_names):
                ch_name = ('MEG %03d' % idx)
            (theta, phi) = np.radians(ch['loc'][3:])
            x = (sin(theta) * cos(phi))
            y = (sin(theta) * sin(phi))
            z = cos(theta)
            vec_z = np.array([x, y, z])
            vec_z /= linalg.norm(vec_z)
            vec_x = np.zeros(vec_z.size, dtype=np.float64)
            if (vec_z[1] < vec_z[2]):
                if (vec_z[0] < vec_z[1]):
                    vec_x[0] = 1.0
                else:
                    vec_x[1] = 1.0
            elif (vec_z[0] < vec_z[2]):
                vec_x[0] = 1.0
            else:
                vec_x[2] = 1.0
            vec_x -= (np.sum((vec_x * vec_z)) * vec_z)
            vec_x /= linalg.norm(vec_x)
            vec_y = np.cross(vec_z, vec_x)
            vecs = np.vstack((ch['loc'][:3], vec_x, vec_y, vec_z))
            vecs = apply_trans(als_ras_trans, vecs)
            unit = FIFF.FIFF_UNIT_T
            loc = vecs.ravel()
        else:
            ch_type_label = KIT.CH_LABEL[ch['type']]
            channel_index[ch_type_label] += 1
            ch_type_index = channel_index[ch_type_label]
            ch_name = ch.get('name', '')
            eeg_name = ch_name.lower()
            if ((ch_name in ('', 'EEG')) or standardize_names):
                ch_name = ('%s %03i' % (ch_type_label, ch_type_index))
            unit = FIFF.FIFF_UNIT_V
            loc = np.zeros(12)
            if (eeg_name and (eeg_name in dig)):
                loc[:3] = sqd['eeg_dig'][eeg_name] = dig[eeg_name]
        fiff_channels.append(dict(cal=KIT.CALIB_FACTOR, logno=idx, scanno=idx, range=KIT.RANGE, unit=unit, unit_mul=KIT.UNIT_MUL, ch_name=ch_name, coord_frame=FIFF.FIFFV_COORD_DEVICE, coil_type=KIT.CH_TO_FIFF_COIL[ch['type']], kind=KIT.CH_TO_FIFF_KIND[ch['type']], loc=loc))
    info._update_redundant()
    return (info, sqd)
Extract all the information from the sqd/con file.

Parameters
----------
rawfile : str
    KIT file to be read.
allow_unknown_format : bool
    Force reading old data that is not officially supported. Alternatively,
    read and re-save the data with the KIT MEG Laboratory application.
%(standardize_names)s
%(verbose)s

Returns
-------
info : instance of Info
    An Info for the instance.
sqd : dict
    A dict containing all the sqd parameter settings.
@verbose
def get_kit_info(rawfile, allow_unknown_format, standardize_names=None, verbose=None):
    'Extract all the information from the sqd/con file.\n\n    Parameters\n    ----------\n    rawfile : str\n        KIT file to be read.\n    allow_unknown_format : bool\n        Force reading old data that is not officially supported. Alternatively,\n        read and re-save the data with the KIT MEG Laboratory application.\n    %(standardize_names)s\n    %(verbose)s\n\n    Returns\n    -------\n    info : instance of Info\n        An Info for the instance.\n    sqd : dict\n        A dict containing all the sqd parameter settings.\n    '
    sqd = dict()
    sqd['rawfile'] = rawfile
    unsupported_format = False
    sqd['dirs'] = dirs = list()
    with open(rawfile, 'rb', buffering=0) as fid:
        dirs.append(_read_dir(fid))
        dirs.extend((_read_dir(fid) for _ in range((dirs[0]['count'] - 1))))
        assert (len(dirs) == dirs[KIT.DIR_INDEX_DIR]['count'])
        fid.seek(dirs[KIT.DIR_INDEX_SYSTEM]['offset'])
        (version, revision) = unpack('2i', fid.read((2 * KIT.INT)))
        if ((version < 2) or ((version == 2) and (revision < 3))):
            version_string = ('V%iR%03i' % (version, revision))
            if allow_unknown_format:
                unsupported_format = True
                logger.warning('Force loading KIT format %s', version_string)
            else:
                raise UnsupportedKITFormat(version_string, ('SQD file format %s is not officially supported. Set allow_unknown_format=True to load it anyways.' % (version_string,)))
        sysid = unpack('i', fid.read(KIT.INT))[0]
        system_name = unpack('128s', fid.read(128))[0].decode()
        model_name = unpack('128s', fid.read(128))[0].decode()
        sqd['nchan'] = channel_count = unpack('i', fid.read(KIT.INT))[0]
        comment = unpack('256s', fid.read(256))[0].decode()
        (create_time, last_modified_time) = unpack('2i', fid.read((2 * KIT.INT)))
        fid.seek((KIT.INT * 3), SEEK_CUR)
        dewar_style = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 3), SEEK_CUR)
        fll_type = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 3), SEEK_CUR)
        trigger_type = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 3), SEEK_CUR)
        adboard_type = unpack('i', fid.read(KIT.INT))[0]
        fid.seek((KIT.INT * 29), SEEK_CUR)
        if ((version < 2) or ((version == 2) and (revision <= 3))):
            adc_range = float(unpack('i', fid.read(KIT.INT))[0])
        else:
            adc_range = unpack('d', fid.read(KIT.DOUBLE))[0]
        (adc_polarity, adc_allocated, adc_stored) = unpack('3i', fid.read((3 * KIT.INT)))
        system_name = system_name.replace('\x00', )
        system_name = system_name.strip().replace('\n', '/')
        model_name = model_name.replace('\x00', )
        model_name = model_name.strip().replace('\n', '/')
        full_version = f'V{version:d}R{revision:03d}'
        logger.debug('SQD file basic information:')
        logger.debug('Meg160 version = %s', full_version)
        logger.debug('System ID      = %i', sysid)
        logger.debug('System name    = %s', system_name)
        logger.debug('Model name     = %s', model_name)
        logger.debug('Channel count  = %i', channel_count)
        logger.debug('Comment        = %s', comment)
        logger.debug('Dewar style    = %i', dewar_style)
        logger.debug('FLL type       = %i', fll_type)
        logger.debug('Trigger type   = %i', trigger_type)
        logger.debug('A/D board type = %i', adboard_type)
        logger.debug('ADC range      = +/-%s[V]', (adc_range / 2.0))
        logger.debug('ADC allocate   = %i[bit]', adc_allocated)
        logger.debug('ADC bit        = %i[bit]', adc_stored)
        description = f'{system_name} ({sysid}) {full_version} {model_name}'
        sqd['dtype'] = np.dtype(getattr(np, f'int{adc_allocated}'))
        if (fll_type not in KIT.FLL_SETTINGS):
            fll_types = sorted(KIT.FLL_SETTINGS.keys())
            use_fll_type = fll_types[(np.searchsorted(fll_types, fll_type) - 1)]
            warn(('Unknown site filter settings (FLL) for system "%s" model "%s" (ID %s), will assume FLL %d->%d, check your data for correctness, including channel scales and filter settings!' % (system_name, model_name, sysid, fll_type, use_fll_type)))
            fll_type = use_fll_type
        chan_dir = dirs[KIT.DIR_INDEX_CHANNELS]
        (chan_offset, chan_size) = (chan_dir['offset'], chan_dir['size'])
        sqd['channels'] = channels = []
        exg_gains = list()
        for i in range(channel_count):
            fid.seek((chan_offset + (chan_size * i)))
            (channel_type,) = unpack('i', fid.read(KIT.INT))
            if ((sysid == 52) and (i < 160) and (channel_type == KIT.CHANNEL_NULL)):
                channel_type = KIT.CHANNEL_MAGNETOMETER_REFERENCE
            if (channel_type in KIT.CHANNELS_MEG):
                if (channel_type not in KIT.CH_TO_FIFF_COIL):
                    raise NotImplementedError(('KIT channel type %i can not be read. Please contact the mne-python developers.' % channel_type))
                channels.append({'type': channel_type, 'loc': np.fromfile(fid, dtype='d', count=5)})
                if (channel_type in KIT.CHANNEL_NAME_NCHAR):
                    fid.seek(16, SEEK_CUR)
                    channels[(- 1)]['name'] = _read_name(fid, channel_type)
            elif (channel_type in KIT.CHANNELS_MISC):
                (channel_no,) = unpack('i', fid.read(KIT.INT))
                fid.seek(4, SEEK_CUR)
                name = _read_name(fid, channel_type)
                channels.append({'type': channel_type, 'no': channel_no, 'name': name})
                if (channel_type in (KIT.CHANNEL_EEG, KIT.CHANNEL_ECG)):
                    offset = (6 if (channel_type == KIT.CHANNEL_EEG) else 8)
                    fid.seek(offset, SEEK_CUR)
                    exg_gains.append(np.fromfile(fid, 'd', 1)[0])
            elif (channel_type == KIT.CHANNEL_NULL):
                channels.append({'type': channel_type})
            else:
                raise IOError(('Unknown KIT channel type: %i' % channel_type))
        exg_gains = np.array(exg_gains)
        fid.seek(dirs[KIT.DIR_INDEX_CALIBRATION]['offset'])
        sensitivity = np.fromfile(fid, dtype='d', count=(channel_count * 2))
        sensitivity.shape = (channel_count, 2)
        (channel_offset, channel_gain) = sensitivity.T
        assert (channel_offset == 0).all()
        fid.seek(dirs[KIT.DIR_INDEX_AMP_FILTER]['offset'])
        amp_data = unpack('i', fid.read(KIT.INT))[0]
        if (fll_type >= 100):
            gain1 = ((amp_data & 28672) >> 12)
            gain2 = ((amp_data & 1879048192) >> 28)
            gain3 = ((amp_data & 117440512) >> 24)
            amp_gain = ((KIT.GAINS[gain1] * KIT.GAINS[gain2]) * KIT.GAINS[gain3])
            hpf = ((amp_data & 1792) >> 8)
            lpf = ((amp_data & 458752) >> 16)
            bef = ((amp_data & 3) >> 0)
        else:
            input_gain = ((amp_data & 6144) >> 11)
            output_gain = ((amp_data & 7) >> 0)
            amp_gain = (KIT.GAINS[input_gain] * KIT.GAINS[output_gain])
            hpf = ((amp_data & 7) >> 4)
            lpf = ((amp_data & 1792) >> 8)
            bef = ((amp_data & 49152) >> 14)
        (hpf_options, lpf_options, bef_options) = KIT.FLL_SETTINGS[fll_type]
        sqd['highpass'] = KIT.HPFS[hpf_options][hpf]
        sqd['lowpass'] = KIT.LPFS[lpf_options][lpf]
        sqd['notch'] = KIT.BEFS[bef_options][bef]
        fid.seek(dirs[KIT.DIR_INDEX_ACQ_COND]['offset'])
        (sqd['acq_type'],) = (acq_type,) = unpack('i', fid.read(KIT.INT))
        (sqd['sfreq'],) = unpack('d', fid.read(KIT.DOUBLE))
        if (acq_type == KIT.CONTINUOUS):
            fid.seek(KIT.INT, SEEK_CUR)
            (sqd['n_samples'],) = unpack('i', fid.read(KIT.INT))
        elif ((acq_type == KIT.EVOKED) or (acq_type == KIT.EPOCHS)):
            (sqd['frame_length'],) = unpack('i', fid.read(KIT.INT))
            (sqd['pretrigger_length'],) = unpack('i', fid.read(KIT.INT))
            (sqd['average_count'],) = unpack('i', fid.read(KIT.INT))
            (sqd['n_epochs'],) = unpack('i', fid.read(KIT.INT))
            if (acq_type == KIT.EVOKED):
                sqd['n_samples'] = sqd['frame_length']
            else:
                sqd['n_samples'] = (sqd['frame_length'] * sqd['n_epochs'])
        else:
            raise IOError(('Invalid acquisition type: %i. Your file is neither continuous nor epoched data.' % (acq_type,)))
        dig_dir = dirs[KIT.DIR_INDEX_DIG_POINTS]
        cor_dir = dirs[KIT.DIR_INDEX_COREG]
        dig = dict()
        hsp = list()
        if ((dig_dir['count'] > 0) and (cor_dir['count'] > 0)):
            fid.seek(dig_dir['offset'])
            for _ in range(dig_dir['count']):
                name = _read_name(fid, n=8).strip()
                name = name.lower()
                rr = np.fromfile(fid, 'd', 3)
                if name:
                    assert (name not in dig)
                    dig[name] = rr
                else:
                    hsp.append(rr)
            elp = [dig.pop(key) for key in ('fidnz', 'fidt9', 'fidt10', 'hpi_1', 'hpi_2', 'hpi_3', 'hpi_4')]
            if (('hpi_5' in dig) and dig['hpi_5'].any()):
                elp.append(dig.pop('hpi_5'))
            elp = np.array(elp)
            hsp = np.array(hsp, float).reshape((- 1), 3)
            assert (elp.shape in ((7, 3), (8, 3)))
            fid.seek(cor_dir['offset'])
            mrk = np.zeros(((elp.shape[0] - 3), 3))
            for _ in range(cor_dir['count']):
                done = np.fromfile(fid, np.int32, 1)[0]
                fid.seek(((16 * KIT.DOUBLE) + (16 * KIT.DOUBLE)), SEEK_CUR)
                marker_count = np.fromfile(fid, np.int32, 1)[0]
                if (not done):
                    continue
                assert (marker_count >= len(mrk))
                for mi in range(len(mrk)):
                    (mri_type, meg_type, mri_done, meg_done) = np.fromfile(fid, np.int32, 4)
                    assert meg_done
                    fid.seek((3 * KIT.DOUBLE), SEEK_CUR)
                    mrk[mi] = np.fromfile(fid, 'd', 3)
                fid.seek(256, SEEK_CUR)
            sqd.update(hsp=hsp, elp=elp, mrk=mrk)
    all_names = set((ch.get('name', ) for ch in channels))
    if ((standardize_names is None) and all_names.difference({, 'EEG'})):
        standardize_names = True
        warn('standardize_names defaults to True in 0.21 but will change to False in 0.22', DeprecationWarning)
    if unsupported_format:
        if (sysid not in LEGACY_AMP_PARAMS):
            raise IOError(('Legacy parameters for system ID %i unavailable' % (sysid,)))
        (adc_range, adc_stored) = LEGACY_AMP_PARAMS[sysid]
    is_meg = np.array([(ch['type'] in KIT.CHANNELS_MEG) for ch in channels])
    ad_to_volt = (adc_range / (2 ** adc_stored))
    ad_to_tesla = ((ad_to_volt / amp_gain) * channel_gain)
    conv_factor = np.where(is_meg, ad_to_tesla, ad_to_volt)
    is_exg = [(ch['type'] in (KIT.CHANNEL_EEG, KIT.CHANNEL_ECG)) for ch in channels]
    exg_gains /= (2 ** (adc_stored - 14))
    conv_factor[is_exg] = exg_gains
    sqd['conv_factor'] = conv_factor[:, np.newaxis]
    info = _empty_info(float(sqd['sfreq']))
    info.update(meas_date=_stamp_to_dt((create_time, 0)), lowpass=sqd['lowpass'], highpass=sqd['highpass'], kit_system_id=sysid, description=description)
    logger.info('Setting channel info structure...')
    info['chs'] = fiff_channels = []
    channel_index = defaultdict((lambda : 0))
    sqd['eeg_dig'] = OrderedDict()
    for (idx, ch) in enumerate(channels, 1):
        if (ch['type'] in KIT.CHANNELS_MEG):
            ch_name = ch.get('name', )
            if ((ch_name == ) or standardize_names):
                ch_name = ('MEG %03d' % idx)
            (theta, phi) = np.radians(ch['loc'][3:])
            x = (sin(theta) * cos(phi))
            y = (sin(theta) * sin(phi))
            z = cos(theta)
            vec_z = np.array([x, y, z])
            vec_z /= linalg.norm(vec_z)
            vec_x = np.zeros(vec_z.size, dtype=np.float64)
            if (vec_z[1] < vec_z[2]):
                if (vec_z[0] < vec_z[1]):
                    vec_x[0] = 1.0
                else:
                    vec_x[1] = 1.0
            elif (vec_z[0] < vec_z[2]):
                vec_x[0] = 1.0
            else:
                vec_x[2] = 1.0
            vec_x -= (np.sum((vec_x * vec_z)) * vec_z)
            vec_x /= linalg.norm(vec_x)
            vec_y = np.cross(vec_z, vec_x)
            vecs = np.vstack((ch['loc'][:3], vec_x, vec_y, vec_z))
            vecs = apply_trans(als_ras_trans, vecs)
            unit = FIFF.FIFF_UNIT_T
            loc = vecs.ravel()
        else:
            ch_type_label = KIT.CH_LABEL[ch['type']]
            channel_index[ch_type_label] += 1
            ch_type_index = channel_index[ch_type_label]
            ch_name = ch.get('name', )
            eeg_name = ch_name.lower()
            if ((ch_name in (, 'EEG')) or standardize_names):
                ch_name = ('%s %03i' % (ch_type_label, ch_type_index))
            unit = FIFF.FIFF_UNIT_V
            loc = np.zeros(12)
            if (eeg_name and (eeg_name in dig)):
                loc[:3] = sqd['eeg_dig'][eeg_name] = dig[eeg_name]
        fiff_channels.append(dict(cal=KIT.CALIB_FACTOR, logno=idx, scanno=idx, range=KIT.RANGE, unit=unit, unit_mul=KIT.UNIT_MUL, ch_name=ch_name, coord_frame=FIFF.FIFFV_COORD_DEVICE, coil_type=KIT.CH_TO_FIFF_COIL[ch['type']], kind=KIT.CH_TO_FIFF_KIND[ch['type']], loc=loc))
    info._update_redundant()
    return (info, sqd)