eegdash 0.3.4.dev69__py3-none-any.whl → 0.3.4.dev70__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of eegdash might be problematic. Click here for more details.
- eegdash/__init__.py +1 -1
- eegdash/registry.py +103 -39
- {eegdash-0.3.4.dev69.dist-info → eegdash-0.3.4.dev70.dist-info}/METADATA +2 -1
- {eegdash-0.3.4.dev69.dist-info → eegdash-0.3.4.dev70.dist-info}/RECORD +7 -7
- {eegdash-0.3.4.dev69.dist-info → eegdash-0.3.4.dev70.dist-info}/WHEEL +0 -0
- {eegdash-0.3.4.dev69.dist-info → eegdash-0.3.4.dev70.dist-info}/licenses/LICENSE +0 -0
- {eegdash-0.3.4.dev69.dist-info → eegdash-0.3.4.dev70.dist-info}/top_level.txt +0 -0
eegdash/__init__.py
CHANGED
eegdash/registry.py
CHANGED
|
@@ -1,52 +1,39 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import csv
|
|
4
3
|
from pathlib import Path
|
|
5
4
|
from typing import Any, Dict
|
|
6
5
|
|
|
6
|
+
import pandas as pd
|
|
7
|
+
from tabulate import tabulate
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
def register_openneuro_datasets(
|
|
9
11
|
summary_file: str | Path,
|
|
10
12
|
*,
|
|
11
13
|
base_class=None,
|
|
12
14
|
namespace: Dict[str, Any] | None = None,
|
|
15
|
+
add_to_all: bool = True,
|
|
13
16
|
) -> Dict[str, type]:
|
|
14
|
-
"""Dynamically create dataset classes from a summary file.
|
|
15
|
-
|
|
16
|
-
Parameters
|
|
17
|
-
----------
|
|
18
|
-
summary_file : str | Path
|
|
19
|
-
Path to a CSV file where each line starts with the dataset identifier.
|
|
20
|
-
base_class : type | None
|
|
21
|
-
Base class for the generated datasets. If ``None``, defaults to
|
|
22
|
-
:class:`eegdash.api.EEGDashDataset`.
|
|
23
|
-
namespace : dict | None
|
|
24
|
-
Mapping where the new classes will be registered. Defaults to the
|
|
25
|
-
module's global namespace.
|
|
26
|
-
|
|
27
|
-
Returns
|
|
28
|
-
-------
|
|
29
|
-
dict
|
|
30
|
-
Mapping from class names to the generated classes.
|
|
31
|
-
|
|
32
|
-
"""
|
|
17
|
+
"""Dynamically create dataset classes from a summary file."""
|
|
33
18
|
if base_class is None:
|
|
34
19
|
from .api import EEGDashDataset as base_class # lazy import
|
|
35
20
|
|
|
36
21
|
summary_path = Path(summary_file)
|
|
37
22
|
namespace = namespace if namespace is not None else globals()
|
|
23
|
+
module_name = namespace.get("__name__", __name__)
|
|
38
24
|
registered: Dict[str, type] = {}
|
|
39
25
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class_name = dataset_id.upper()
|
|
26
|
+
df = pd.read_csv(summary_path, comment="#", skip_blank_lines=True)
|
|
27
|
+
for _, row_series in df.iterrows():
|
|
28
|
+
row = row_series.tolist()
|
|
29
|
+
dataset_id = str(row[0]).strip()
|
|
30
|
+
if not dataset_id:
|
|
31
|
+
continue
|
|
32
|
+
|
|
33
|
+
class_name = dataset_id.upper()
|
|
49
34
|
|
|
35
|
+
# avoid zero-arg super() here
|
|
36
|
+
def make_init(_dataset: str):
|
|
50
37
|
def __init__(
|
|
51
38
|
self,
|
|
52
39
|
cache_dir: str,
|
|
@@ -54,19 +41,96 @@ def register_openneuro_datasets(
|
|
|
54
41
|
s3_bucket: str | None = None,
|
|
55
42
|
**kwargs,
|
|
56
43
|
):
|
|
57
|
-
q = {"dataset":
|
|
44
|
+
q = {"dataset": _dataset}
|
|
58
45
|
if query:
|
|
59
46
|
q.update(query)
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
# call base_class.__init__ directly
|
|
48
|
+
base_class.__init__(
|
|
49
|
+
self,
|
|
50
|
+
query=q,
|
|
51
|
+
cache_dir=cache_dir,
|
|
52
|
+
s3_bucket=s3_bucket,
|
|
53
|
+
**kwargs,
|
|
62
54
|
)
|
|
63
55
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
return __init__
|
|
57
|
+
|
|
58
|
+
init = make_init(dataset_id)
|
|
59
|
+
|
|
60
|
+
doc = f"""Create an instance for OpenNeuro dataset ``{dataset_id}``.
|
|
61
|
+
|
|
62
|
+
{markdown_table(row_series)}
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
cache_dir : str
|
|
67
|
+
Local cache directory.
|
|
68
|
+
query : dict | None
|
|
69
|
+
Extra Mongo query merged with ``{{'dataset': '{dataset_id}'}}``.
|
|
70
|
+
s3_bucket : str | None
|
|
71
|
+
Optional S3 bucket name.
|
|
72
|
+
**kwargs
|
|
73
|
+
Passed through to {base_class.__name__}.
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
init.__doc__ = doc
|
|
77
|
+
|
|
78
|
+
cls = type(
|
|
79
|
+
class_name,
|
|
80
|
+
(base_class,),
|
|
81
|
+
{
|
|
82
|
+
"_dataset": dataset_id,
|
|
83
|
+
"__init__": init,
|
|
84
|
+
"__doc__": doc,
|
|
85
|
+
"__module__": module_name, #
|
|
86
|
+
},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
namespace[class_name] = cls
|
|
90
|
+
registered[class_name] = cls
|
|
91
|
+
|
|
92
|
+
if add_to_all:
|
|
93
|
+
ns_all = namespace.setdefault("__all__", [])
|
|
94
|
+
if isinstance(ns_all, list) and class_name not in ns_all:
|
|
95
|
+
ns_all.append(class_name)
|
|
71
96
|
|
|
72
97
|
return registered
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def markdown_table(row_series: pd.Series) -> str:
|
|
101
|
+
"""Create a reStructuredText grid table from a pandas Series."""
|
|
102
|
+
if row_series.empty:
|
|
103
|
+
return ""
|
|
104
|
+
|
|
105
|
+
# Prepare the dataframe with user's suggested logic
|
|
106
|
+
df = (
|
|
107
|
+
row_series.to_frame()
|
|
108
|
+
.T.rename(
|
|
109
|
+
columns={
|
|
110
|
+
"n_subjects": "#Subj",
|
|
111
|
+
"nchans_set": "#Chan",
|
|
112
|
+
"n_tasks": "#Classes",
|
|
113
|
+
"sampling_freqs": "Freq(Hz)",
|
|
114
|
+
"duration_hours_total": "Duration(H)",
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
.reindex(
|
|
118
|
+
columns=[
|
|
119
|
+
"dataset",
|
|
120
|
+
"#Subj",
|
|
121
|
+
"#Chan",
|
|
122
|
+
"#Classes",
|
|
123
|
+
"Freq(Hz)",
|
|
124
|
+
"Duration(H)",
|
|
125
|
+
]
|
|
126
|
+
)
|
|
127
|
+
.infer_objects(copy=False)
|
|
128
|
+
.fillna("")
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# Use tabulate for the final rst formatting
|
|
132
|
+
table = tabulate(df, headers="keys", tablefmt="rst", showindex=False)
|
|
133
|
+
|
|
134
|
+
# Indent the table to fit within the admonition block
|
|
135
|
+
indented_table = "\n".join(" " + line for line in table.split("\n"))
|
|
136
|
+
return f"\n\n{indented_table}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: eegdash
|
|
3
|
-
Version: 0.3.4.
|
|
3
|
+
Version: 0.3.4.dev70
|
|
4
4
|
Summary: EEG data for machine learning
|
|
5
5
|
Author-email: Young Truong <dt.young112@gmail.com>, Arnaud Delorme <adelorme@gmail.com>, Aviv Dotan <avivd220@gmail.com>, Oren Shriki <oren70@gmail.com>, Bruno Aristimunha <b.aristimunha@gmail.com>
|
|
6
6
|
License-Expression: GPL-3.0-only
|
|
@@ -38,6 +38,7 @@ Requires-Dist: tqdm
|
|
|
38
38
|
Requires-Dist: xarray
|
|
39
39
|
Requires-Dist: h5io>=0.2.4
|
|
40
40
|
Requires-Dist: pymatreader
|
|
41
|
+
Requires-Dist: tabulate
|
|
41
42
|
Provides-Extra: tests
|
|
42
43
|
Requires-Dist: pytest; extra == "tests"
|
|
43
44
|
Requires-Dist: pytest-cov; extra == "tests"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
eegdash/__init__.py,sha256=
|
|
1
|
+
eegdash/__init__.py,sha256=z1uESq6VO66_4UpTGGFDW06PF_7WagRrULPFrTXrsYI,240
|
|
2
2
|
eegdash/api.py,sha256=OqOZ27GYURSAZwTQHSs0QcW_6Mq1i_5XHP6KMcihb8A,27295
|
|
3
3
|
eegdash/data_config.py,sha256=OS6ERO-jHrnEOfMJUehY7ieABdsRw_qWzOKJ4pzSfqw,1323
|
|
4
4
|
eegdash/data_utils.py,sha256=_dycnPmGfTbYs7bc6edHxUn_m01dLYtp92_k44ffEoY,26475
|
|
@@ -6,7 +6,7 @@ eegdash/dataset.py,sha256=ooLoxMFy2I8BY9gJl6ncTp_Gz-Rq0Z-o4NJyyomxLcU,2670
|
|
|
6
6
|
eegdash/dataset_summary.csv,sha256=EfnPciglkf4Vgc8dDq_1x7Woeeze1II8vOhx60g4yhc,8670
|
|
7
7
|
eegdash/mongodb.py,sha256=GD3WgA253oFgpzOHrYaj4P1mRjNtDMT5Oj4kVvHswjI,2006
|
|
8
8
|
eegdash/preprocessing.py,sha256=7S_TTRKPKEk47tTnh2D6WExBt4cctAMxUxGDjJqq5lU,2221
|
|
9
|
-
eegdash/registry.py,sha256=
|
|
9
|
+
eegdash/registry.py,sha256=cxqX53GYyDvg5DkiqJkvjqHDPI72JTPlI4qVh2sILu8,3873
|
|
10
10
|
eegdash/utils.py,sha256=wU9CBQZLW_LIQIBwhgQm5bU4X-rSsVNPdeF2iE4QGJ4,410
|
|
11
11
|
eegdash/features/__init__.py,sha256=BXNhjvL4_SSFAY1lcP9nyGpkbJNtoOMH4AHlF6OyABo,4078
|
|
12
12
|
eegdash/features/datasets.py,sha256=kU1DO70ArSIy-LF1hHD2NN4iT-kJrI0mVpSkyV_OSeI,18301
|
|
@@ -23,8 +23,8 @@ eegdash/features/feature_bank/dimensionality.py,sha256=j_Ds71Y1AbV2uLFQj8EuXQ4kz
|
|
|
23
23
|
eegdash/features/feature_bank/signal.py,sha256=3Tb8z9gX7iZipxQJ9DSyy30JfdmW58kgvimSyZX74p8,3404
|
|
24
24
|
eegdash/features/feature_bank/spectral.py,sha256=bNB7skusePs1gX7NOU6yRlw_Gr4UOCkO_ylkCgybzug,3319
|
|
25
25
|
eegdash/features/feature_bank/utils.py,sha256=DGh-Q7-XFIittP7iBBxvsJaZrlVvuY5mw-G7q6C-PCI,1237
|
|
26
|
-
eegdash-0.3.4.
|
|
27
|
-
eegdash-0.3.4.
|
|
28
|
-
eegdash-0.3.4.
|
|
29
|
-
eegdash-0.3.4.
|
|
30
|
-
eegdash-0.3.4.
|
|
26
|
+
eegdash-0.3.4.dev70.dist-info/licenses/LICENSE,sha256=asisR-xupy_NrQBFXnx6yqXeZcYWLvbAaiETl25iXT0,931
|
|
27
|
+
eegdash-0.3.4.dev70.dist-info/METADATA,sha256=5jX-LB-ep0hcsCio2zFUKO3201B_0sa5gTbeha0I24k,10364
|
|
28
|
+
eegdash-0.3.4.dev70.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
29
|
+
eegdash-0.3.4.dev70.dist-info/top_level.txt,sha256=zavO69HQ6MyZM0aQMR2zUS6TAFc7bnN5GEpDpOpFZzU,8
|
|
30
|
+
eegdash-0.3.4.dev70.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|