22# License: BSD-3-Clause
33# Copyright the MNE-Python contributors.
44
5- from ...utils import verbose
6- from ..utils import _data_path_doc , _download_mne_dataset , _get_version , _version_doc
5+ from pathlib import Path
6+
7+ from ...utils import _check_option , logger , verbose
8+ from ..utils import (
9+ _data_path_doc ,
10+ _download_mne_dataset ,
11+ _downloader_params ,
12+ _get_path ,
13+ _get_version ,
14+ _version_doc ,
15+ )
16+
17+ _N170_BASE_URL = "https://data.nemar.org/nm000132/v1.1.1/"
18+ _N170_REGISTRY = {
19+ "sub-001/eeg/sub-001_task-N170_eeg.fdt" : (
20+ "sha256:08406f3c6b4a869dc8f67c9acc233a91993bae1b04b7dee5bc0521677ed8949b"
21+ ),
22+ "sub-001/eeg/sub-001_task-N170_eeg.set" : (
23+ "sha256:9c53dbdc3b469934a5eb6e9f01e59090dd47aeb495b8f21ceca03670991e5b11"
24+ ),
25+ "sub-001/eeg/sub-001_task-N170_events.tsv" : (
26+ "sha256:07c87e728d097b0deb05b17d77bbdbd22ef58105111b0b56e659a767b9421e34"
27+ ),
28+ }
729
830
931@verbose
@@ -25,6 +47,37 @@ def data_path(
2547)
2648
2749
50+ def fetch_file (fname , path = None ):
51+ """Fetch a raw ERP CORE file used by MNE-Python examples.
52+
53+ Parameters
54+ ----------
55+ fname : str
56+ Relative path of the file within the ERP CORE dataset.
57+ path : path-like | None
58+ Parent directory for the ``ERP-CORE-N170`` folder. If ``None``, the
59+ ``MNE_DATASETS_ERP_CORE_PATH`` configuration value is used.
60+
61+ Returns
62+ -------
63+ path : instance of Path
64+ Local path to the requested file.
65+ """
66+ import pooch
67+
68+ _check_option ("fname" , fname , _N170_REGISTRY )
69+ path = _get_path (path , "MNE_DATASETS_ERP_CORE_PATH" , "ERP CORE" )
70+ fetcher = pooch .create (
71+ path = path / "ERP-CORE-N170" ,
72+ base_url = _N170_BASE_URL ,
73+ registry = _N170_REGISTRY ,
74+ retry_if_failed = 2 ,
75+ )
76+ pooch .get_logger ().setLevel (logger .getEffectiveLevel ())
77+ downloader = pooch .HTTPDownloader (** _downloader_params ())
78+ return Path (fetcher .fetch (fname , downloader = downloader , progressbar = True ))
79+
80+
2881def get_version (): # noqa: D103
2982 return _get_version ("erp_core" )
3083
0 commit comments