Skip to content

Commit

Permalink
Merge pull request mne-tools#4365 from mmagnuski/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeilepp authored Jul 3, 2017
2 parents 8bf97d2 + e054610 commit cbcbc43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ BUG

- Fix :func:`mne.io.read_raw_brainvision` to read vectorized data correctly by `Jaakko Leppakangas`_ and `Phillip Alday`_

- Fix :func:`mne.connectivity.spectral_connectivity` so that if ``n_jobs > 1`` it does not ignore last ``n_epochs % n_jobs`` epochs by `Mikołaj Magnuski`_

API
~~~

Expand Down
2 changes: 2 additions & 0 deletions mne/connectivity/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ def _get_n_epochs(epochs, n):
if len(epochs_out) >= n:
yield epochs_out
epochs_out = list()
if 0 < len(epochs_out) < n:
yield epochs_out


def _check_method(method):
Expand Down
10 changes: 8 additions & 2 deletions mne/connectivity/tests/test_spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from nose.tools import assert_true, assert_raises

from mne.connectivity import spectral_connectivity
from mne.connectivity.spectral import _CohEst
from mne.connectivity.spectral import _CohEst, _get_n_epochs

from mne import SourceEstimate
from mne.utils import run_tests_if_main, slow_test
Expand Down Expand Up @@ -215,6 +215,12 @@ def test_spectral_connectivity():
freq_idx = np.searchsorted(freqs2, freqs3[i])
con2_avg = np.mean(con2[j][:, freq_idx], axis=1)
assert_array_almost_equal(con2_avg, con3[j][:, i])

# test _get_n_epochs
full_list = list(range(10))
out_lens = np.array([len(x) for x in _get_n_epochs(full_list, 4)])
assert_true((out_lens == np.array([4, 4, 2])).all())
out_lens = np.array([len(x) for x in _get_n_epochs(full_list, 11)])
assert_true(len(out_lens) > 0)
assert_true(out_lens[0] == 10)

run_tests_if_main()

0 comments on commit cbcbc43

Please sign in to comment.