Skip to content

Commit

Permalink
Update for new MNE syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-introspection committed Feb 8, 2024
1 parent 85d1c0a commit 46ee387
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions hypyp/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def pow(epochs: mne.Epochs, fmin: float, fmax: float, n_fft: int, n_per_seg: int
# computing power spectral density on epochs signal
# average in the 1-second window around event (mean, but can choose 'median')
kwargs = dict(fmin=fmin, fmax=fmax, n_fft=n_fft, n_per_seg=n_per_seg,
tmin=None, tmax=None, method='welch', picks='all', proj=False,
n_jobs=1)
tmin=None, tmax=None, method='welch', picks='all', exclude=[],
proj=False, remove_dc=True, n_jobs=1)
spectrum = EpochsSpectrum(epochs, **kwargs)
psds = spectrum.get_data()
freq_list = spectrum.freqs
Expand Down Expand Up @@ -804,8 +804,8 @@ def xwt(sig1: mne.Epochs, sig2: mne.Epochs,
sfreq = sig1.info['sfreq']
assert sig1.info['sfreq'] == sig2.info['sfreq'], "Sig1 et sig2 should have the same sfreq value."

n_epochs1, n_chans1, n_samples1 = sig1.get_data().shape
n_epochs2, n_chans2, n_samples2 = sig2.get_data().shape
n_epochs1, n_chans1, n_samples1 = sig1.get_data(copy=False).shape
n_epochs2, n_chans2, n_samples2 = sig2.get_data(copy=False).shape

assert n_epochs1 == n_epochs2, "n_epochs1 and n_epochs2 should have the same number of epochs."
assert n_chans1 == n_chans2, "n_chans1 and n_chans2 should have the same number of channels."
Expand Down
6 changes: 3 additions & 3 deletions hypyp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def merge(epoch_S1: mne.Epochs, epoch_S2: mne.Epochs) -> mne.Epochs:

# picking data per epoch
for l in range(0, len(epoch_S1)):
data_S1 = epoch_S1[l].get_data()
data_S2 = epoch_S2[l].get_data()
data_S1 = epoch_S1[l].get_data(copy=True)
data_S2 = epoch_S2[l].get_data(copy=True)

data_S1 = np.squeeze(data_S1, axis=0)
data_S2 = np.squeeze(data_S2, axis=0)
Expand Down Expand Up @@ -338,7 +338,7 @@ def generate_random_epoch(epoch: mne.Epochs, mu: float=0, sigma: float=2.0)-> mn

# Get epochs as a 3D NumPy array of shape (n_epochs, n_channels, n_times)
# Get the arrays’ shape
data_shape = epoch.get_data().shape
data_shape = epoch.get_data(copy=False).shape
i, j, k = data_shape

# Generate a numpy.array with same shape from the normal distribution
Expand Down
9 changes: 5 additions & 4 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# coding=utf-8

import pytest
import random
import numpy as np
import scipy
Expand Down Expand Up @@ -139,7 +140,7 @@ def test_behav_corr(epochs):
p_thresh=0.05,
multiple_corr=False,
verbose=False)
assert corr_tuple.r in [-1, 1]
assert pytest.approx(corr_tuple.r) in [-1, 1]

# test for connectivity values data
# generate artificial group of 2 subjects repeated
Expand Down Expand Up @@ -310,9 +311,9 @@ def test_utils(epochs):
liste = ep_hyper.info['ch_names']
ch_index1 = liste.index(ch_name + '_S1')
ch_index2 = liste.index(ch_name + '_S2')
ep_hyper_data = ep_hyper.get_data()
epo1_data = epochs.epo1.get_data()
epo2_data = epochs.epo2.get_data()
ep_hyper_data = ep_hyper.get_data(copy=True)
epo1_data = epochs.epo1.get_data(copy=True)
epo2_data = epochs.epo2.get_data(copy=True)
for i in range(0, len(ep_hyper_data[ne][ch_index1])):
assert ep_hyper_data[ne][ch_index1][i] == epo1_data[ne][nch][i]
assert ep_hyper_data[ne][ch_index2][i] == epo2_data[ne][nch][i]
Expand Down
12 changes: 6 additions & 6 deletions tutorial/simulations.ipynb

Large diffs are not rendered by default.

0 comments on commit 46ee387

Please sign in to comment.