def test_overlapping_trial_offsets(raw_info_targets):
    raw, info, targets = raw_info_targets
    base_ds = BaseDataset(raw, info)
    windower = EventWindower(trial_start_offset_samples=-2000,
                             trial_stop_offset_samples=1000,
                             supercrop_size_samples=1000,
                             supercrop_stride_samples=1000)
    with pytest.raises(AssertionError, match='trials overlap not implemented'):
        windower(base_ds)
def test_stride_has_no_effect(raw_info_targets):
    raw, info, targets = raw_info_targets
    base_ds = BaseDataset(raw, info)
    windower = EventWindower(trial_start_offset_samples=0,
                             trial_stop_offset_samples=1000,
                             supercrop_size_samples=1000,
                             supercrop_stride_samples=1000)
    windows = windower(base_ds)
    description = windows.events[:, -1]
    assert len(description) == len(targets)
    np.testing.assert_array_equal(description, targets)
def test_dropping_last_incomplete_supercrop(raw_info_targets):
    raw, info, targets = raw_info_targets
    base_ds = BaseDataset(raw, info)
    windower = EventWindower(trial_start_offset_samples=-250,
                             trial_stop_offset_samples=250,
                             supercrop_size_samples=250,
                             supercrop_stride_samples=300,
                             drop_samples=True)
    windows = windower(base_ds)
    description = windows.events[:, -1]
    assert len(description) == len(targets)
    np.testing.assert_array_equal(description, targets)
def test_shifting_last_supercrop_back_in(raw_info_targets):
    raw, info, targets = raw_info_targets
    base_ds = BaseDataset(raw, info)
    windower = EventWindower(trial_start_offset_samples=-250,
                             trial_stop_offset_samples=250,
                             supercrop_size_samples=250,
                             supercrop_stride_samples=300)
    windows = windower(base_ds)
    description = windows.events[:, -1]
    assert len(description) == len(targets) * 2
    np.testing.assert_array_equal(description[0::2], targets)
    np.testing.assert_array_equal(description[1::2], targets)
def test_maximally_overlapping_supercrops(raw_info_targets):
    raw, info, targets = raw_info_targets
    base_ds = BaseDataset(raw, info)
    windower = EventWindower(trial_start_offset_samples=-2,
                             trial_stop_offset_samples=1000,
                             supercrop_size_samples=1000,
                             supercrop_stride_samples=1)
    windows = windower(base_ds)
    description = windows.events[:, -1]
    assert len(description) == len(targets) * 3
    np.testing.assert_array_equal(description[0::3], targets)
    np.testing.assert_array_equal(description[1::3], targets)
    np.testing.assert_array_equal(description[2::3], targets)