Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Sleep tutorial #5718

Merged
merged 83 commits into from Jan 14, 2019
Merged
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
320b1db
init tutorial sleep
Slasnista Nov 16, 2018
4f77514
Add whats new
massich Nov 16, 2018
26f0d30
Add sleep tuto into the documentation index
massich Nov 16, 2018
36ff2d9
Comment the entire tuto to check that it compiles
massich Nov 16, 2018
7799c65
Add sleep-edf to datasets_index
massich Nov 16, 2018
3ae311d
proof of concept ok for sleep data
agramfort Dec 8, 2018
7b3c76f
add fetch with test and update example
agramfort Dec 9, 2018
6e328a3
update doc
agramfort Dec 9, 2018
24a7601
more
agramfort Dec 9, 2018
ca4f8c3
oups
agramfort Dec 9, 2018
4e06a27
preprocessing annotations
Slasnista Dec 12, 2018
04746d7
update hypnogram figure
Slasnista Dec 12, 2018
a5dcf76
simplifying stuff
agramfort Dec 20, 2018
d66fe10
Even simpler solution
massich Dec 20, 2018
917f25f
typo
massich Dec 20, 2018
630a6db
Use md5 as default
massich Dec 20, 2018
efa58d6
deprecate md5
massich Dec 20, 2018
75d5489
skip docstring test
massich Dec 20, 2018
911bbc5
deprecate md5sum
massich Dec 20, 2018
0d17bfc
feature extraction + model training
Slasnista Dec 21, 2018
9203944
rebase What's new
massich Dec 21, 2018
44831df
training + prediction
Slasnista Dec 21, 2018
fd5713e
more narrative version + shpinx things
massich Dec 21, 2018
adbf4ea
wip (use FunctionTransformer)
massich Dec 21, 2018
f86ee8d
simplify
agramfort Dec 22, 2018
efb8b7a
don't forget to normalize psds
agramfort Dec 28, 2018
bbb62c9
move bob below and add narrative
agramfort Dec 28, 2018
c4060f1
FIX: doc
massich Jan 2, 2019
33e7baa
ENH: fit directly epochs to sklearn.pipeline
massich Jan 2, 2019
3160065
fix travis [skip ci]
massich Jan 4, 2019
c424aa4
wip: doc iteration
massich Jan 4, 2019
58a918f
simplify PSD plot
massich Jan 4, 2019
791938f
doc pass
massich Jan 4, 2019
6ccb679
add labels to the PSD
massich Jan 4, 2019
3be5041
minor
massich Jan 6, 2019
c375afb
wip
massich Jan 6, 2019
ca1e4f7
Fix: typo
massich Jan 7, 2019
edd4572
WIP: update fetcher
massich Jan 7, 2019
58b544c
physionet annotations have 8 different labels not 7
massich Jan 7, 2019
7120c23
wip
massich Jan 7, 2019
0261f7c
ENH: Split physionet fetcher into .age .temazepam
massich Jan 7, 2019
6859e68
FIX: use hash_type instead of hashtype
massich Jan 7, 2019
311e9cc
wip
massich Jan 7, 2019
4373d47
wip
massich Jan 7, 2019
6bdd897
wip
massich Jan 7, 2019
09f23a9
wip
massich Jan 8, 2019
a8deb39
wip
massich Jan 8, 2019
def1a35
cosmit
massich Jan 8, 2019
00f23f3
start with temazepam dataset
massich Jan 8, 2019
2388cc6
wip in temazepan
massich Jan 9, 2019
1cee686
finish temazepam fetcher
massich Jan 10, 2019
c2af0e4
doc physionet's age
massich Jan 10, 2019
ddd2769
Add temazepam records
massich Jan 10, 2019
fb5bf17
Merge master's whats new
massich Jan 10, 2019
1b129a0
add sklearn's classificaiton report
massich Jan 10, 2019
40b7b23
refactor fetchers
massich Jan 10, 2019
daf7c16
refactor data_path
massich Jan 10, 2019
d4db9dd
move records
massich Jan 11, 2019
3a8ac9a
ups missing file
massich Jan 11, 2019
1768367
clean up
massich Jan 11, 2019
0c9919e
nitpick
massich Jan 11, 2019
0619d32
link sklearn
massich Jan 11, 2019
3cb0caa
pep8
massich Jan 11, 2019
f877d08
cosmit
agramfort Jan 13, 2019
281938f
iter of sleep fetchers
agramfort Jan 13, 2019
0b223c2
fix
agramfort Jan 13, 2019
7270adf
doc fixes
agramfort Jan 13, 2019
712aba8
fix CIs
agramfort Jan 13, 2019
102199b
Merge branch 'master' into sleep_tutorial
massich Jan 14, 2019
594c80f
minor review
massich Jan 14, 2019
dcb9c89
use pytest tmpdirs
massich Jan 14, 2019
871d2de
mock _fetch_file to avoid downloading and speed up the testing
massich Jan 14, 2019
ee6b3f8
wip
massich Jan 14, 2019
cacecdb
add mock packages to environment.yml
massich Jan 14, 2019
0ed6f79
ENH: refactor mocked object call inspection
massich Jan 14, 2019
e3e38e3
TST: no longer requries good network
massich Jan 14, 2019
7e1655e
add mock dependencies in travis
massich Jan 14, 2019
8bddae2
old stuff we forgot
massich Jan 14, 2019
129b903
fix docstring
massich Jan 14, 2019
cc77141
update requriements for 3.7 travis
massich Jan 14, 2019
ef08992
just pytest-mock should be explicitely listed and don't list test lev…
agramfort Jan 14, 2019
f70e639
missing
agramfort Jan 14, 2019
f934da3
these tests are not slow. Just need good network
agramfort Jan 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions mne/datasets/sleep_physionet/tests/test_physionet.py
Expand Up @@ -24,6 +24,10 @@ def physionet_tmpdir(tmpdir_factory):
return str(tmpdir_factory.mktemp('physionet_files'))


def _fake_fetch_file(url, path, print_destination, hash_, hash_type):
pass


def _keep_basename_only(path_structure):
return np.vectorize(op.basename)(np.array(path_structure))

Expand All @@ -42,8 +46,11 @@ def test_run_update_age_records(tmpdir):


@requires_good_network
def test_sleep_physionet_age(physionet_tmpdir):
def test_sleep_physionet_age(physionet_tmpdir, mocker):
"""Test Sleep Physionet URL handling."""
mocker.patch('mne.datasets.sleep_physionet._utils._fetch_file',
side_effect=_fake_fetch_file)

params = {'path': physionet_tmpdir, 'update_path': False}

with pytest.raises(ValueError, match='Only subjects 0 to 19 are'):
Expand Down Expand Up @@ -78,14 +85,25 @@ def test_run_update_temazepam_records(tmpdir):


@requires_good_network
def test_sleep_physionet_temazepam(physionet_tmpdir):
def test_sleep_physionet_temazepam(physionet_tmpdir, mocker):
"""Test Sleep Physionet URL handling."""
mm = mocker.patch('mne.datasets.sleep_physionet._utils._fetch_file',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get how this can work. mocker is not imported. Your mocker function does not write any file to disk

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean that the mocker is not imported? pytest-mock exposes this fixture called mocker which takes care of setting it up and tearing down.

And I'm aware that I'm writing nothing. But _fetch_one delegates all the writing to the original _ferch_file and I'm bypassing this so _fetch_one works just as expected despite _fake_fetch_fle does not write a thing.

side_effect=_fake_fetch_file)

params = {'path': physionet_tmpdir, 'update_path': False}

paths = temazepam.fetch_data(subjects=[0], **params)
assert_array_equal(_keep_basename_only(paths),
[['ST7011J0-PSG.edf', 'ST7011JP-Hypnogram.edf']])

EXPECTED_URL = 'https://physionet.org/pn4/sleep-edfx//ST7011JP-Hypnogram.edf'
EXPECTED_PATH = physionet_tmpdir + '/physionet-sleep-data/ST7011JP-Hypnogram.edf'
mm.assert_called_with(EXPECTED_URL,
EXPECTED_PATH,
hash_='ff28e5e01296cefed49ae0c27cfb3ebc42e710bf',
hash_type='sha1',
print_destination=False)

with pytest.raises(ValueError, match='Only subjects 0 to 21 are'):
paths = temazepam.fetch_data(subjects=[22], **params)

Expand Down