Test that resampling and filter + decimate are similar.
()
| 14 | |
| 15 | @testing.requires_testing_data |
| 16 | def test_decimate(): |
| 17 | """Test that resampling and filter + decimate are similar.""" |
| 18 | raw = mne.io.read_raw_fif(ms_fname, allow_maxshield="yes") |
| 19 | raw.pick("eeg").load_data() |
| 20 | assert raw.info["sfreq"] == 1200 |
| 21 | with pytest.warns(RuntimeWarning, match="indicates a low-pass"): |
| 22 | mne.make_fixed_length_epochs(raw).decimate(6) |
| 23 | raw.filter(None, 40.0) |
| 24 | epo = mne.make_fixed_length_epochs(raw, preload=True).decimate(6) |
| 25 | assert not hasattr(epo, "first") # only Evoked should have this |
| 26 | others = dict( |
| 27 | epo_1=mne.make_fixed_length_epochs(raw, preload=False).decimate(6), |
| 28 | epo_2=mne.make_fixed_length_epochs(raw, preload=True).decimate(2).decimate(3), |
| 29 | epo_3=mne.make_fixed_length_epochs(raw, preload=False).decimate(2).decimate(3), |
| 30 | ) |
| 31 | for key, other in others.items(): |
| 32 | assert_allclose( |
| 33 | epo.get_data(copy=False), |
| 34 | other.get_data(copy=False), |
| 35 | err_msg=key, |
| 36 | ) |
| 37 | assert_allclose(epo.times, other.times, err_msg=key) |
| 38 | evo = epo.average() |
| 39 | epo_full = mne.make_fixed_length_epochs(raw, preload=True) |
| 40 | others = dict( |
| 41 | evo_1=epo_full.average().decimate(6), |
| 42 | evo_2=epo_full.average().decimate(2).decimate(3), |
| 43 | ) |
| 44 | for key, other in others.items(): |
| 45 | assert_allclose(evo.data, other.data, err_msg=key) |
| 46 | assert_allclose(evo.times, other.times, err_msg=key) |