Skip to content

Commit

Permalink
simplified mne testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmidt Fabian committed Jul 31, 2024
1 parent 0014203 commit 97d10c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
22 changes: 3 additions & 19 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,8 @@ def gen_mne_data_raw():

meg_path = data_path / 'MEG' / 'sample'
raw_fname = meg_path / 'sample_audvis_raw.fif'

raw = mne.io.read_raw_fif(raw_fname)
picks = mne.pick_types(raw.info, meg='mag', eeg=False, stim=False, eog=False, exclude='bads')
raw.pick(picks)

yield raw


@pytest.fixture(scope='session')
def gen_mne_data_epoched():
data_path = sample.data_path()

meg_path = data_path / 'MEG' / 'sample'
raw_fname = meg_path / 'sample_audvis_raw.fif'
event_fname = meg_path / 'sample_audvis_filt-0-40_raw-eve.fif'
events = mne.read_events(event_fname)

raw = mne.io.read_raw_fif(raw_fname)
picks = mne.pick_types(raw.info, meg='mag', eeg=False, stim=False, eog=False, exclude='bads')
Expand All @@ -113,19 +101,15 @@ def gen_mne_data_epoched():
tmax = 0.5

# Load real data as the template
event_fname = meg_path / 'sample_audvis_filt-0-40_raw-eve.fif'
events = mne.read_events(event_fname)

epochs = mne.Epochs(
raw,
events,
event_id,
tmin,
tmax,
# picks=picks,
baseline=None,
preload=True,
verbose=False,
)

yield epochs
yield raw, epochs
18 changes: 7 additions & 11 deletions tests/test_mne.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@

@pytest.mark.filterwarnings('ignore:RuntimeWarning')
@pytest.mark.filterwarnings('ignore:UserWarning')
def test_mne_raw(gen_mne_data_raw):
def test_mne(gen_mne_data_raw):
mne_data, epochs = gen_mne_data_raw

# test raw
aperiodic_mne, periodic_mne = irasa_raw(
gen_mne_data_raw, band=(0.25, 50), duration=2, hset_info=(1.0, 2.0, 0.05), as_array=False
mne_data, band=(0.25, 50), duration=2, hset_info=(1.0, 2.0, 0.05), as_array=False
)
aperiodic_mne.get_slopes(fit_func='fixed')
# aperiodic_mne.get_slopes(fit_func='knee', scale=True)
periodic_mne.get_peaks(smoothing_window=2)


@pytest.mark.filterwarnings('ignore:RuntimeWarning')
@pytest.mark.filterwarnings('ignore:UserWarning')
def test_mne_epoched(gen_mne_data_epoched):
aperiodic, periodic = irasa_epochs(gen_mne_data_epoched, band=(0.5, 50), hset_info=(1.0, 2.0, 0.05), as_array=False)

# aperiodic.get_slopes(fit_func='knee', scale=True)
# test epochs
aperiodic, periodic = irasa_epochs(epochs, band=(0.5, 50), hset_info=(1.0, 2.0, 0.05), as_array=False)
aperiodic.get_slopes(fit_func='fixed', scale=True)

periodic.get_peaks(smoothing_window=2)

0 comments on commit 97d10c6

Please sign in to comment.