@verbose
def read_meas_info(fid, tree, verbose=None):
    'Read the measurement info\n\n    Parameters\n    ----------\n    fid : file\n        Open file descriptor.\n    tree : tree\n        FIF tree structure.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n\n    Returns\n    -------\n    info : instance of mne.fiff.meas_info.Info\n       Info on dataset.\n    meas : dict\n        Node in tree that contains the info.\n    '
    meas = dir_tree_find(tree, FIFF.FIFFB_MEAS)
    if (len(meas) == 0):
        raise ValueError('Could not find measurement data')
    if (len(meas) > 1):
        raise ValueError('Cannot read more that 1 measurement data')
    meas = meas[0]
    meas_info = dir_tree_find(meas, FIFF.FIFFB_MEAS_INFO)
    if (len(meas_info) == 0):
        raise ValueError('Could not find measurement info')
    if (len(meas_info) > 1):
        raise ValueError('Cannot read more that 1 measurement info')
    meas_info = meas_info[0]
    dev_head_t = None
    ctf_head_t = None
    meas_date = None
    highpass = None
    lowpass = None
    nchan = None
    sfreq = None
    chs = []
    experimenter = None
    description = None
    proj_id = None
    proj_name = None
    line_freq = None
    p = 0
    for k in range(meas_info['nent']):
        kind = meas_info['directory'][k].kind
        pos = meas_info['directory'][k].pos
        if (kind == FIFF.FIFF_NCHAN):
            tag = read_tag(fid, pos)
            nchan = int(tag.data)
        elif (kind == FIFF.FIFF_SFREQ):
            tag = read_tag(fid, pos)
            sfreq = float(tag.data)
        elif (kind == FIFF.FIFF_CH_INFO):
            tag = read_tag(fid, pos)
            chs.append(tag.data)
            p += 1
        elif (kind == FIFF.FIFF_LOWPASS):
            tag = read_tag(fid, pos)
            lowpass = float(tag.data)
        elif (kind == FIFF.FIFF_HIGHPASS):
            tag = read_tag(fid, pos)
            highpass = float(tag.data)
        elif (kind == FIFF.FIFF_MEAS_DATE):
            tag = read_tag(fid, pos)
            meas_date = tag.data
        elif (kind == FIFF.FIFF_COORD_TRANS):
            tag = read_tag(fid, pos)
            cand = tag.data
            if ((cand['from'] == FIFF.FIFFV_COORD_DEVICE) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                dev_head_t = cand
            elif ((cand['from'] == FIFF.FIFFV_MNE_COORD_CTF_HEAD) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                ctf_head_t = cand
        elif (kind == FIFF.FIFF_EXPERIMENTER):
            tag = read_tag(fid, pos)
            experimenter = tag.data
        elif (kind == FIFF.FIFF_DESCRIPTION):
            tag = read_tag(fid, pos)
            description = tag.data
        elif (kind == FIFF.FIFF_PROJ_ID):
            tag = read_tag(fid, pos)
            proj_id = tag.data
        elif (kind == FIFF.FIFF_PROJ_NAME):
            tag = read_tag(fid, pos)
            proj_name = tag.data
        elif (kind == FIFF.FIFF_LINE_FREQ):
            tag = read_tag(fid, pos)
            line_freq = float(tag.data)
    if (nchan is None):
        raise ValueError('Number of channels in not defined')
    if (sfreq is None):
        raise ValueError('Sampling frequency is not defined')
    if (len(chs) == 0):
        raise ValueError('Channel information not defined')
    if (len(chs) != nchan):
        raise ValueError('Incorrect number of channel definitions found')
    if ((dev_head_t is None) or (ctf_head_t is None)):
        hpi_result = dir_tree_find(meas_info, FIFF.FIFFB_HPI_RESULT)
        if (len(hpi_result) == 1):
            hpi_result = hpi_result[0]
            for k in range(hpi_result['nent']):
                kind = hpi_result['directory'][k].kind
                pos = hpi_result['directory'][k].pos
                if (kind == FIFF.FIFF_COORD_TRANS):
                    tag = read_tag(fid, pos)
                    cand = tag.data
                    if ((cand['from'] == FIFF.FIFFV_COORD_DEVICE) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                        dev_head_t = cand
                    elif ((cand['from'] == FIFF.FIFFV_MNE_COORD_CTF_HEAD) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                        ctf_head_t = cand
    isotrak = dir_tree_find(meas_info, FIFF.FIFFB_ISOTRAK)
    dig = None
    if (len(isotrak) == 0):
        logger.info('Isotrak not found')
    elif (len(isotrak) > 1):
        warn('Multiple Isotrak found')
    else:
        isotrak = isotrak[0]
        dig = []
        for k in range(isotrak['nent']):
            kind = isotrak['directory'][k].kind
            pos = isotrak['directory'][k].pos
            if (kind == FIFF.FIFF_DIG_POINT):
                tag = read_tag(fid, pos)
                dig.append(tag.data)
                dig[(- 1)]['coord_frame'] = FIFF.FIFFV_COORD_HEAD
    acqpars = dir_tree_find(meas_info, FIFF.FIFFB_DACQ_PARS)
    acq_pars = None
    acq_stim = None
    if (len(acqpars) == 1):
        acqpars = acqpars[0]
        for k in range(acqpars['nent']):
            kind = acqpars['directory'][k].kind
            pos = acqpars['directory'][k].pos
            if (kind == FIFF.FIFF_DACQ_PARS):
                tag = read_tag(fid, pos)
                acq_pars = tag.data
            elif (kind == FIFF.FIFF_DACQ_STIM):
                tag = read_tag(fid, pos)
                acq_stim = tag.data
    projs = read_proj(fid, meas_info)
    comps = read_ctf_comp(fid, meas_info, chs)
    bads = read_bad_channels(fid, meas_info)
    if (tree['id'] is not None):
        info = Info(file_id=tree['id'])
    else:
        info = Info(file_id=None)
    subject_info = dir_tree_find(meas_info, FIFF.FIFFB_SUBJECT)
    if (len(subject_info) == 1):
        subject_info = subject_info[0]
        si = dict()
        for k in range(subject_info['nent']):
            kind = subject_info['directory'][k].kind
            pos = subject_info['directory'][k].pos
            if (kind == FIFF.FIFF_SUBJ_ID):
                tag = read_tag(fid, pos)
                si['id'] = int(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_HIS_ID):
                tag = read_tag(fid, pos)
                si['his_id'] = str(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_LAST_NAME):
                tag = read_tag(fid, pos)
                si['last_name'] = str(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_FIRST_NAME):
                tag = read_tag(fid, pos)
                si['first_name'] = str(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_BIRTH_DAY):
                tag = read_tag(fid, pos)
                si['birthday'] = tag.data
            elif (kind == FIFF.FIFF_SUBJ_SEX):
                tag = read_tag(fid, pos)
                si['sex'] = int(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_HAND):
                tag = read_tag(fid, pos)
                si['hand'] = int(tag.data)
    else:
        si = None
    info['subject_info'] = si
    read_extra_meas_info(fid, tree, info)
    if (meas_info['parent_id'] is None):
        if (meas_info['id'] is None):
            if (meas['id'] is None):
                if (meas['parent_id'] is None):
                    info['meas_id'] = info['file_id']
                else:
                    info['meas_id'] = meas['parent_id']
            else:
                info['meas_id'] = meas['id']
        else:
            info['meas_id'] = meas_info['id']
    else:
        info['meas_id'] = meas_info['parent_id']
    info['experimenter'] = experimenter
    info['description'] = description
    info['proj_id'] = proj_id
    info['proj_name'] = proj_name
    if (meas_date is None):
        info['meas_date'] = [info['meas_id']['secs'], info['meas_id']['usecs']]
    else:
        info['meas_date'] = meas_date
    info['nchan'] = nchan
    info['sfreq'] = sfreq
    info['highpass'] = (highpass if (highpass is not None) else 0)
    info['lowpass'] = (lowpass if (lowpass is not None) else (info['sfreq'] / 2.0))
    info['line_freq'] = line_freq
    info['chs'] = chs
    info['ch_names'] = [ch['ch_name'] for ch in chs]
    info['dev_head_t'] = dev_head_t
    info['ctf_head_t'] = ctf_head_t
    if ((dev_head_t is not None) and (ctf_head_t is not None)):
        head_ctf_trans = linalg.inv(ctf_head_t['trans'])
        dev_ctf_trans = np.dot(head_ctf_trans, info['dev_head_t']['trans'])
        info['dev_ctf_t'] = {'from': FIFF.FIFFV_COORD_DEVICE, 'to': FIFF.FIFFV_MNE_COORD_CTF_HEAD, 'trans': dev_ctf_trans}
    else:
        info['dev_ctf_t'] = None
    info['dig'] = dig
    info['bads'] = bads
    info['projs'] = projs
    info['comps'] = comps
    info['acq_pars'] = acq_pars
    info['acq_stim'] = acq_stim
    return (info, meas)
Read the measurement info

Parameters
----------
fid : file
    Open file descriptor.
tree : tree
    FIF tree structure.
verbose : bool, str, int, or None
    If not None, override default verbose level (see mne.verbose).

Returns
-------
info : instance of mne.fiff.meas_info.Info
   Info on dataset.
meas : dict
    Node in tree that contains the info.
@verbose
def read_meas_info(fid, tree, verbose=None):
    'Read the measurement info\n\n    Parameters\n    ----------\n    fid : file\n        Open file descriptor.\n    tree : tree\n        FIF tree structure.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n\n    Returns\n    -------\n    info : instance of mne.fiff.meas_info.Info\n       Info on dataset.\n    meas : dict\n        Node in tree that contains the info.\n    '
    meas = dir_tree_find(tree, FIFF.FIFFB_MEAS)
    if (len(meas) == 0):
        raise ValueError('Could not find measurement data')
    if (len(meas) > 1):
        raise ValueError('Cannot read more that 1 measurement data')
    meas = meas[0]
    meas_info = dir_tree_find(meas, FIFF.FIFFB_MEAS_INFO)
    if (len(meas_info) == 0):
        raise ValueError('Could not find measurement info')
    if (len(meas_info) > 1):
        raise ValueError('Cannot read more that 1 measurement info')
    meas_info = meas_info[0]
    dev_head_t = None
    ctf_head_t = None
    meas_date = None
    highpass = None
    lowpass = None
    nchan = None
    sfreq = None
    chs = []
    experimenter = None
    description = None
    proj_id = None
    proj_name = None
    line_freq = None
    p = 0
    for k in range(meas_info['nent']):
        kind = meas_info['directory'][k].kind
        pos = meas_info['directory'][k].pos
        if (kind == FIFF.FIFF_NCHAN):
            tag = read_tag(fid, pos)
            nchan = int(tag.data)
        elif (kind == FIFF.FIFF_SFREQ):
            tag = read_tag(fid, pos)
            sfreq = float(tag.data)
        elif (kind == FIFF.FIFF_CH_INFO):
            tag = read_tag(fid, pos)
            chs.append(tag.data)
            p += 1
        elif (kind == FIFF.FIFF_LOWPASS):
            tag = read_tag(fid, pos)
            lowpass = float(tag.data)
        elif (kind == FIFF.FIFF_HIGHPASS):
            tag = read_tag(fid, pos)
            highpass = float(tag.data)
        elif (kind == FIFF.FIFF_MEAS_DATE):
            tag = read_tag(fid, pos)
            meas_date = tag.data
        elif (kind == FIFF.FIFF_COORD_TRANS):
            tag = read_tag(fid, pos)
            cand = tag.data
            if ((cand['from'] == FIFF.FIFFV_COORD_DEVICE) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                dev_head_t = cand
            elif ((cand['from'] == FIFF.FIFFV_MNE_COORD_CTF_HEAD) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                ctf_head_t = cand
        elif (kind == FIFF.FIFF_EXPERIMENTER):
            tag = read_tag(fid, pos)
            experimenter = tag.data
        elif (kind == FIFF.FIFF_DESCRIPTION):
            tag = read_tag(fid, pos)
            description = tag.data
        elif (kind == FIFF.FIFF_PROJ_ID):
            tag = read_tag(fid, pos)
            proj_id = tag.data
        elif (kind == FIFF.FIFF_PROJ_NAME):
            tag = read_tag(fid, pos)
            proj_name = tag.data
        elif (kind == FIFF.FIFF_LINE_FREQ):
            tag = read_tag(fid, pos)
            line_freq = float(tag.data)
    if (nchan is None):
        raise ValueError('Number of channels in not defined')
    if (sfreq is None):
        raise ValueError('Sampling frequency is not defined')
    if (len(chs) == 0):
        raise ValueError('Channel information not defined')
    if (len(chs) != nchan):
        raise ValueError('Incorrect number of channel definitions found')
    if ((dev_head_t is None) or (ctf_head_t is None)):
        hpi_result = dir_tree_find(meas_info, FIFF.FIFFB_HPI_RESULT)
        if (len(hpi_result) == 1):
            hpi_result = hpi_result[0]
            for k in range(hpi_result['nent']):
                kind = hpi_result['directory'][k].kind
                pos = hpi_result['directory'][k].pos
                if (kind == FIFF.FIFF_COORD_TRANS):
                    tag = read_tag(fid, pos)
                    cand = tag.data
                    if ((cand['from'] == FIFF.FIFFV_COORD_DEVICE) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                        dev_head_t = cand
                    elif ((cand['from'] == FIFF.FIFFV_MNE_COORD_CTF_HEAD) and (cand['to'] == FIFF.FIFFV_COORD_HEAD)):
                        ctf_head_t = cand
    isotrak = dir_tree_find(meas_info, FIFF.FIFFB_ISOTRAK)
    dig = None
    if (len(isotrak) == 0):
        logger.info('Isotrak not found')
    elif (len(isotrak) > 1):
        warn('Multiple Isotrak found')
    else:
        isotrak = isotrak[0]
        dig = []
        for k in range(isotrak['nent']):
            kind = isotrak['directory'][k].kind
            pos = isotrak['directory'][k].pos
            if (kind == FIFF.FIFF_DIG_POINT):
                tag = read_tag(fid, pos)
                dig.append(tag.data)
                dig[(- 1)]['coord_frame'] = FIFF.FIFFV_COORD_HEAD
    acqpars = dir_tree_find(meas_info, FIFF.FIFFB_DACQ_PARS)
    acq_pars = None
    acq_stim = None
    if (len(acqpars) == 1):
        acqpars = acqpars[0]
        for k in range(acqpars['nent']):
            kind = acqpars['directory'][k].kind
            pos = acqpars['directory'][k].pos
            if (kind == FIFF.FIFF_DACQ_PARS):
                tag = read_tag(fid, pos)
                acq_pars = tag.data
            elif (kind == FIFF.FIFF_DACQ_STIM):
                tag = read_tag(fid, pos)
                acq_stim = tag.data
    projs = read_proj(fid, meas_info)
    comps = read_ctf_comp(fid, meas_info, chs)
    bads = read_bad_channels(fid, meas_info)
    if (tree['id'] is not None):
        info = Info(file_id=tree['id'])
    else:
        info = Info(file_id=None)
    subject_info = dir_tree_find(meas_info, FIFF.FIFFB_SUBJECT)
    if (len(subject_info) == 1):
        subject_info = subject_info[0]
        si = dict()
        for k in range(subject_info['nent']):
            kind = subject_info['directory'][k].kind
            pos = subject_info['directory'][k].pos
            if (kind == FIFF.FIFF_SUBJ_ID):
                tag = read_tag(fid, pos)
                si['id'] = int(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_HIS_ID):
                tag = read_tag(fid, pos)
                si['his_id'] = str(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_LAST_NAME):
                tag = read_tag(fid, pos)
                si['last_name'] = str(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_FIRST_NAME):
                tag = read_tag(fid, pos)
                si['first_name'] = str(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_BIRTH_DAY):
                tag = read_tag(fid, pos)
                si['birthday'] = tag.data
            elif (kind == FIFF.FIFF_SUBJ_SEX):
                tag = read_tag(fid, pos)
                si['sex'] = int(tag.data)
            elif (kind == FIFF.FIFF_SUBJ_HAND):
                tag = read_tag(fid, pos)
                si['hand'] = int(tag.data)
    else:
        si = None
    info['subject_info'] = si
    read_extra_meas_info(fid, tree, info)
    if (meas_info['parent_id'] is None):
        if (meas_info['id'] is None):
            if (meas['id'] is None):
                if (meas['parent_id'] is None):
                    info['meas_id'] = info['file_id']
                else:
                    info['meas_id'] = meas['parent_id']
            else:
                info['meas_id'] = meas['id']
        else:
            info['meas_id'] = meas_info['id']
    else:
        info['meas_id'] = meas_info['parent_id']
    info['experimenter'] = experimenter
    info['description'] = description
    info['proj_id'] = proj_id
    info['proj_name'] = proj_name
    if (meas_date is None):
        info['meas_date'] = [info['meas_id']['secs'], info['meas_id']['usecs']]
    else:
        info['meas_date'] = meas_date
    info['nchan'] = nchan
    info['sfreq'] = sfreq
    info['highpass'] = (highpass if (highpass is not None) else 0)
    info['lowpass'] = (lowpass if (lowpass is not None) else (info['sfreq'] / 2.0))
    info['line_freq'] = line_freq
    info['chs'] = chs
    info['ch_names'] = [ch['ch_name'] for ch in chs]
    info['dev_head_t'] = dev_head_t
    info['ctf_head_t'] = ctf_head_t
    if ((dev_head_t is not None) and (ctf_head_t is not None)):
        head_ctf_trans = linalg.inv(ctf_head_t['trans'])
        dev_ctf_trans = np.dot(head_ctf_trans, info['dev_head_t']['trans'])
        info['dev_ctf_t'] = {'from': FIFF.FIFFV_COORD_DEVICE, 'to': FIFF.FIFFV_MNE_COORD_CTF_HEAD, 'trans': dev_ctf_trans}
    else:
        info['dev_ctf_t'] = None
    info['dig'] = dig
    info['bads'] = bads
    info['projs'] = projs
    info['comps'] = comps
    info['acq_pars'] = acq_pars
    info['acq_stim'] = acq_stim
    return (info, meas)