Пример #1
0
def test_equalize_channels():
    """Test equalization of channels for instances of Info."""
    info1 = create_info(['CH1', 'CH2', 'CH3'], sfreq=1.)
    info2 = create_info(['CH4', 'CH2', 'CH1'], sfreq=1.)
    info1, info2 = equalize_channels([info1, info2])

    assert info1.ch_names == ['CH1', 'CH2']
    assert info2.ch_names == ['CH1', 'CH2']
Пример #2
0
def test_equalize_channels():
    """Test equalization of channels for instances of Forward."""
    fwd1 = read_forward_solution(fname_meeg)
    fwd1.pick_channels(['EEG 001', 'EEG 002', 'EEG 003'])
    fwd2 = fwd1.copy().pick_channels(['EEG 002', 'EEG 001'], ordered=True)
    fwd1, fwd2 = equalize_channels([fwd1, fwd2])
    assert fwd1.ch_names == ['EEG 001', 'EEG 002']
    assert fwd2.ch_names == ['EEG 001', 'EEG 002']
Пример #3
0
def test_equalize_channels():
    """Test equalization of channels for instances of CrossSpectralDensity."""
    csd1 = _make_csd()
    csd2 = csd1.copy().pick_channels(['CH2', 'CH1'], ordered=True)
    csd1, csd2 = equalize_channels([csd1, csd2])

    assert csd1.ch_names == ['CH1', 'CH2']
    assert csd2.ch_names == ['CH1', 'CH2']
Пример #4
0
def test_equalize_channels():
    """Test equalization of channels for instances of Covariance."""
    cov1 = make_ad_hoc_cov(
        create_info(['CH1', 'CH2', 'CH3', 'CH4'], sfreq=1.0, ch_types='eeg'))
    cov2 = make_ad_hoc_cov(
        create_info(['CH5', 'CH1', 'CH2'], sfreq=1.0, ch_types='eeg'))
    cov1, cov2 = equalize_channels([cov1, cov2])
    assert cov1.ch_names == ['CH1', 'CH2']
    assert cov2.ch_names == ['CH1', 'CH2']
Пример #5
0
def test_equalize_channels():
    """Test equalizing channels and their ordering."""
    # This function only tests the generic functionality of equalize_channels.
    # Additional tests for each instance type are included in the accompanying
    # test suite for each type.
    pytest.raises(TypeError,
                  equalize_channels, ['foo', 'bar'],
                  match='Instances to be modified must be an instance of')

    raw = RawArray([[1.], [2.], [3.], [4.]],
                   create_info(['CH1', 'CH2', 'CH3', 'CH4'], sfreq=1.))
    epochs = EpochsArray([[[1.], [2.], [3.]]],
                         create_info(['CH5', 'CH2', 'CH1'], sfreq=1.))
    cov = make_ad_hoc_cov(
        create_info(['CH2', 'CH1', 'CH8'], sfreq=1., ch_types='eeg'))
    cov['bads'] = ['CH1']
    ave = EvokedArray([[1.], [2.]], create_info(['CH1', 'CH2'], sfreq=1.))

    raw2, epochs2, cov2, ave2 = equalize_channels([raw, epochs, cov, ave],
                                                  copy=True)

    # The Raw object was the first in the list, so should have been used as
    # template for the ordering of the channels. No bad channels should have
    # been dropped.
    assert raw2.ch_names == ['CH1', 'CH2']
    assert_array_equal(raw2.get_data(), [[1.], [2.]])
    assert epochs2.ch_names == ['CH1', 'CH2']
    assert_array_equal(epochs2.get_data(), [[[3.], [2.]]])
    assert cov2.ch_names == ['CH1', 'CH2']
    assert cov2['bads'] == cov['bads']
    assert ave2.ch_names == ave.ch_names
    assert_array_equal(ave2.data, ave.data)

    # All objects should have been copied, except for the Evoked object which
    # did not have to be touched.
    assert raw is not raw2
    assert epochs is not epochs2
    assert cov is not cov2
    assert ave is ave2

    # Test in-place operation
    raw2, epochs2 = equalize_channels([raw, epochs], copy=False)
    assert raw is raw2
    assert epochs is epochs2