示例#1
0
def test_info_no_rename_no_reorder_no_pdf():
    """Test private renaming, reordering and partial construction option."""
    for pdf, config, hs in zip(pdf_fnames, config_fnames, hs_fnames):
        info, bti_info = _get_bti_info(
            pdf_fname=pdf, config_fname=config, head_shape_fname=hs,
            rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
            ecg_ch='E31', eog_ch=('E63', 'E64'),
            rename_channels=False, sort_by_ch_name=False)
        info2, bti_info = _get_bti_info(
            pdf_fname=None, config_fname=config, head_shape_fname=hs,
            rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
            ecg_ch='E31', eog_ch=('E63', 'E64'),
            rename_channels=False, sort_by_ch_name=False)

        assert_equal(info['ch_names'],
                     [ch['ch_name'] for ch in info['chs']])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][:5],
                     ['A22', 'A2', 'A104', 'A241', 'A138'])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][-5:],
                     ['A133', 'A158', 'A44', 'A134', 'A216'])

        info = pick_info(info, pick_types(info, meg=True, stim=True,
                                          resp=True))
        info2 = pick_info(info2, pick_types(info2, meg=True, stim=True,
                                            resp=True))

        assert (info['sfreq'] is not None)
        assert (info['lowpass'] is not None)
        assert (info['highpass'] is not None)
        assert (info['meas_date'] is not None)

        assert_equal(info2['sfreq'], None)
        assert_equal(info2['lowpass'], None)
        assert_equal(info2['highpass'], None)
        assert_equal(info2['meas_date'], None)

        assert_equal(info['ch_names'], info2['ch_names'])
        assert_equal(info['ch_names'], info2['ch_names'])
        for key in ['dev_ctf_t', 'dev_head_t', 'ctf_head_t']:
            assert_array_equal(info[key]['trans'], info2[key]['trans'])

        assert_array_equal(
            np.array([ch['loc'] for ch in info['chs']]),
            np.array([ch['loc'] for ch in info2['chs']]))

    # just check reading data | corner case
    raw1 = read_raw_bti(
        pdf_fname=pdf, config_fname=config, head_shape_fname=None,
        sort_by_ch_name=False, preload=True)
    # just check reading data | corner case
    raw2 = read_raw_bti(
        pdf_fname=pdf, config_fname=config, head_shape_fname=None,
        rename_channels=False,
        sort_by_ch_name=True, preload=True)

    sort_idx = [raw1.bti_ch_labels.index(ch) for ch in raw2.bti_ch_labels]
    raw1._data = raw1._data[sort_idx]
    assert_array_equal(raw1._data, raw2._data)
    assert_array_equal(raw2.bti_ch_labels, raw2.ch_names)
示例#2
0
def test_info_no_rename_no_reorder_no_pdf():
    """Test private renaming, reordering and partial construction option."""
    for pdf, config, hs in zip(pdf_fnames, config_fnames, hs_fnames):
        info, bti_info = _get_bti_info(
            pdf_fname=pdf, config_fname=config, head_shape_fname=hs,
            rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
            ecg_ch='E31', eog_ch=('E63', 'E64'),
            rename_channels=False, sort_by_ch_name=False)
        info2, bti_info = _get_bti_info(
            pdf_fname=None, config_fname=config, head_shape_fname=hs,
            rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
            ecg_ch='E31', eog_ch=('E63', 'E64'),
            rename_channels=False, sort_by_ch_name=False)

        assert_equal(info['ch_names'],
                     [ch['ch_name'] for ch in info['chs']])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][:5],
                     ['A22', 'A2', 'A104', 'A241', 'A138'])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][-5:],
                     ['A133', 'A158', 'A44', 'A134', 'A216'])

        info = pick_info(info, pick_types(info, meg=True, stim=True,
                                          resp=True))
        info2 = pick_info(info2, pick_types(info2, meg=True, stim=True,
                                            resp=True))

        assert_true(info['sfreq'] is not None)
        assert_true(info['lowpass'] is not None)
        assert_true(info['highpass'] is not None)
        assert_true(info['meas_date'] is not None)

        assert_equal(info2['sfreq'], None)
        assert_equal(info2['lowpass'], None)
        assert_equal(info2['highpass'], None)
        assert_equal(info2['meas_date'], None)

        assert_equal(info['ch_names'], info2['ch_names'])
        assert_equal(info['ch_names'], info2['ch_names'])
        for key in ['dev_ctf_t', 'dev_head_t', 'ctf_head_t']:
            assert_array_equal(info[key]['trans'], info2[key]['trans'])

        assert_array_equal(
            np.array([ch['loc'] for ch in info['chs']]),
            np.array([ch['loc'] for ch in info2['chs']]))

    # just check reading data | corner case
    raw1 = read_raw_bti(
        pdf_fname=pdf, config_fname=config, head_shape_fname=None,
        sort_by_ch_name=False, preload=True)
    # just check reading data | corner case
    raw2 = read_raw_bti(
        pdf_fname=pdf, config_fname=config, head_shape_fname=None,
        rename_channels=False,
        sort_by_ch_name=True, preload=True)

    sort_idx = [raw1.bti_ch_labels.index(ch) for ch in raw2.bti_ch_labels]
    raw1._data = raw1._data[sort_idx]
    assert_array_equal(raw1._data, raw2._data)
    assert_array_equal(raw2.bti_ch_labels, raw2.ch_names)
示例#3
0
def test_info_no_rename_no_reorder_no_pdf():
    """ Test private renaming, reordering and partial construction option """
    for pdf, config, hs in zip(pdf_fnames, config_fnames, hs_fnames):
        with warnings.catch_warnings(record=True):  # weight tables
            info, bti_info = _get_bti_info(
                pdf_fname=pdf, config_fname=config, head_shape_fname=hs,
                rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
                ecg_ch='E31', eog_ch=('E63', 'E64'),
                rename_channels=False, sort_by_ch_name=False)
            info2, bti_info = _get_bti_info(
                pdf_fname=None, config_fname=config, head_shape_fname=hs,
                rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
                ecg_ch='E31', eog_ch=('E63', 'E64'),
                rename_channels=False, sort_by_ch_name=False)

        assert_equal(info['ch_names'],
                     [ch['ch_name'] for ch in info['chs']])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][:5],
                     ['A22', 'A2', 'A104', 'A241', 'A138'])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][-5:],
                     ['A133', 'A158', 'A44', 'A134', 'A216'])

        info = pick_info(info, pick_types(info, meg=True, stim=True,
                                          resp=True))
        info2 = pick_info(info2, pick_types(info2, meg=True, stim=True,
                                            resp=True))

        assert_true(info['sfreq'] is not None)
        assert_true(info['lowpass'] is not None)
        assert_true(info['highpass'] is not None)
        assert_true(info['meas_date'] is not None)

        assert_equal(info2['sfreq'], None)
        assert_equal(info2['lowpass'], None)
        assert_equal(info2['highpass'], None)
        assert_equal(info2['meas_date'], None)

        assert_equal(info['ch_names'], info2['ch_names'])
        assert_equal(info['ch_names'], info2['ch_names'])
        for key in ['dev_ctf_t', 'dev_head_t', 'ctf_head_t']:
            assert_array_equal(info[key]['trans'], info2[key]['trans'])

        assert_array_equal(
            np.array([ch['loc'] for ch in info['chs']]),
            np.array([ch['loc'] for ch in info2['chs']]))
示例#4
0
文件: read.py 项目: mne-tools/mne-hcp
def _read_bti_info(raw_fid, config):
    """helper to only access bti info from pdf file"""
    info, bti_info = _get_bti_info(
        pdf_fname=raw_fid, config_fname=config, head_shape_fname=None,
        rotation_x=0.0, translation=(0.0, 0.02, 0.11),
        ecg_ch='E31', eog_ch=('E63', 'E64'),
        convert=False,  # no conversion to neuromag coordinates
        rename_channels=False,  # keep native channel names
        sort_by_ch_name=False)  # do not change native order
    return info
示例#5
0
def _read_bti_info(zf, config):
    """ helper to only access bti info from pdf file """
    raw_fid = None
    info, bti_info = _get_bti_info(
        pdf_fname=raw_fid, config_fname=config, head_shape_fname=None,
        rotation_x=0.0, translation=(0.0, 0.02, 0.11),
        ecg_ch='E31', eog_ch=('E63', 'E64'),
        convert=False,  # no conversion to neuromag coordinates
        rename_channels=False,  # keep native channel names
        sort_by_ch_name=False)  # do not change native order
    return info
示例#6
0
def test_info_no_rename_no_reorder():
    """ Test private renaming and reordering option """
    for pdf, config, hs in zip(pdf_fnames, config_fnames, hs_fnames):
        info, bti_info = _get_bti_info(
            pdf_fname=pdf, config_fname=config, head_shape_fname=hs,
            rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
            ecg_ch='E31', eog_ch=('E63', 'E64'),
            rename_channels=False, sort_by_ch_name=False)
        assert_equal(info['ch_names'],
                     [ch['ch_name'] for ch in info['chs']])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][:5],
                     ['A22', 'A2', 'A104', 'A241', 'A138'])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][-5:],
                     ['A133', 'A158', 'A44', 'A134', 'A216'])
示例#7
0
def test_info_no_rename_no_reorder():
    """ Test private renaming and reordering option """
    for pdf, config, hs in zip(pdf_fnames, config_fnames, hs_fnames):
        with warnings.catch_warnings(record=True):  # weight tables
            info, bti_info = _get_bti_info(
                pdf_fname=pdf, config_fname=config, head_shape_fname=hs,
                rotation_x=0.0, translation=(0.0, 0.02, 0.11), convert=False,
                ecg_ch='E31', eog_ch=('E63', 'E64'),
                rename_channels=False, sort_by_ch_name=False)
        assert_equal(info['ch_names'],
                     [ch['ch_name'] for ch in info['chs']])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][:5],
                     ['A22', 'A2', 'A104', 'A241', 'A138'])
        assert_equal([n for n in info['ch_names'] if n.startswith('A')][-5:],
                     ['A133', 'A158', 'A44', 'A134', 'A216'])
示例#8
0
def test_info_no_rename_no_reorder():
    """ Test private renaming and reordering option """
    for pdf, config, hs in zip(pdf_fnames, config_fnames, hs_fnames):
        info, bti_info = _get_bti_info(
            pdf_fname=pdf,
            config_fname=config,
            head_shape_fname=hs,
            rotation_x=0.0,
            translation=(0.0, 0.02, 0.11),
            convert=False,
            ecg_ch="E31",
            eog_ch=("E63", "E64"),
            rename_channels=False,
            sort_by_ch_name=False,
        )
        assert_equal(info["ch_names"], [ch["ch_name"] for ch in info["chs"]])
        assert_equal([n for n in info["ch_names"] if n.startswith("A")][:5], ["A22", "A2", "A104", "A241", "A138"])
        assert_equal([n for n in info["ch_names"] if n.startswith("A")][-5:], ["A133", "A158", "A44", "A134", "A216"])
示例#9
0
def test_info_no_rename_no_reorder_no_pdf():
    """ Test private renaming, reordering and partial construction option """
    for pdf, config, hs in zip(pdf_fnames, config_fnames, hs_fnames):
        with warnings.catch_warnings(record=True):  # weight tables
            info, bti_info = _get_bti_info(
                pdf_fname=pdf,
                config_fname=config,
                head_shape_fname=hs,
                rotation_x=0.0,
                translation=(0.0, 0.02, 0.11),
                convert=False,
                ecg_ch="E31",
                eog_ch=("E63", "E64"),
                rename_channels=False,
                sort_by_ch_name=False,
            )
            info2, bti_info = _get_bti_info(
                pdf_fname=None,
                config_fname=config,
                head_shape_fname=hs,
                rotation_x=0.0,
                translation=(0.0, 0.02, 0.11),
                convert=False,
                ecg_ch="E31",
                eog_ch=("E63", "E64"),
                rename_channels=False,
                sort_by_ch_name=False,
            )

        assert_equal(info["ch_names"], [ch["ch_name"] for ch in info["chs"]])
        assert_equal([n for n in info["ch_names"] if n.startswith("A")][:5], ["A22", "A2", "A104", "A241", "A138"])
        assert_equal([n for n in info["ch_names"] if n.startswith("A")][-5:], ["A133", "A158", "A44", "A134", "A216"])

        info = pick_info(info, pick_types(info, meg=True, stim=True, resp=True))
        info2 = pick_info(info2, pick_types(info2, meg=True, stim=True, resp=True))

        assert_true(info["sfreq"] is not None)
        assert_true(info["lowpass"] is not None)
        assert_true(info["highpass"] is not None)
        assert_true(info["meas_date"] is not None)

        assert_equal(info2["sfreq"], None)
        assert_equal(info2["lowpass"], None)
        assert_equal(info2["highpass"], None)
        assert_equal(info2["meas_date"], None)

        assert_equal(info["ch_names"], info2["ch_names"])
        assert_equal(info["ch_names"], info2["ch_names"])
        for key in ["dev_ctf_t", "dev_head_t", "ctf_head_t"]:
            assert_array_equal(info[key]["trans"], info2[key]["trans"])

        assert_array_equal(np.array([ch["loc"] for ch in info["chs"]]), np.array([ch["loc"] for ch in info2["chs"]]))

    # just check reading data | corner case
    with warnings.catch_warnings(record=True):  # weight tables
        raw1 = read_raw_bti(
            pdf_fname=pdf, config_fname=config, head_shape_fname=None, sort_by_ch_name=False, preload=True
        )
        # just check reading data | corner case
        raw2 = read_raw_bti(
            pdf_fname=pdf,
            config_fname=config,
            head_shape_fname=None,
            rename_channels=False,
            sort_by_ch_name=True,
            preload=True,
        )

    sort_idx = [raw1.bti_ch_labels.index(ch) for ch in raw2.bti_ch_labels]
    raw1._data = raw1._data[sort_idx]
    assert_array_equal(raw1._data, raw2._data)
    assert_array_equal(raw2.bti_ch_labels, raw2.ch_names)