eegdash 0.4.0.dev144__py3-none-any.whl → 0.4.0.dev150__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 CHANGED
@@ -18,4 +18,4 @@ _init_mongo_client()
18
18
 
19
19
  __all__ = ["EEGDash", "EEGDashDataset", "EEGChallengeDataset", "preprocessing"]
20
20
 
21
- __version__ = "0.4.0.dev144"
21
+ __version__ = "0.4.0.dev150"
eegdash/api.py CHANGED
@@ -15,12 +15,9 @@ from pathlib import Path
15
15
  from typing import Any, Mapping
16
16
 
17
17
  import mne
18
- import numpy as np
19
- import xarray as xr
20
18
  from docstring_inheritance import NumpyDocstringInheritanceInitMeta
21
19
  from dotenv import load_dotenv
22
- from joblib import Parallel, delayed
23
- from mne_bids import find_matching_paths, get_bids_path_from_fname, read_raw_bids
20
+ from mne_bids import find_matching_paths
24
21
  from pymongo import InsertOne, UpdateOne
25
22
  from rich.console import Console
26
23
  from rich.panel import Panel
@@ -328,38 +325,6 @@ class EEGDash:
328
325
  f"Conflicting constraints for '{key}': disjoint sets {r_val!r} and {k_val!r}"
329
326
  )
330
327
 
331
- def load_eeg_data_from_bids_file(self, bids_file: str) -> xr.DataArray:
332
- """Load EEG data from a local BIDS-formatted file.
333
-
334
- Parameters
335
- ----------
336
- bids_file : str
337
- Path to a BIDS-compliant EEG file (e.g., ``*_eeg.edf``, ``*_eeg.bdf``,
338
- ``*_eeg.vhdr``, ``*_eeg.set``).
339
-
340
- Returns
341
- -------
342
- xr.DataArray
343
- EEG data with dimensions ``("channel", "time")``.
344
-
345
- """
346
- bids_path = get_bids_path_from_fname(bids_file, verbose=False)
347
- raw_object = read_raw_bids(bids_path=bids_path, verbose=False)
348
- eeg_data = raw_object.get_data()
349
-
350
- fs = raw_object.info["sfreq"]
351
- max_time = eeg_data.shape[1] / fs
352
- time_steps = np.linspace(0, max_time, eeg_data.shape[1]).squeeze() # in seconds
353
-
354
- channel_names = raw_object.ch_names
355
-
356
- eeg_xarray = xr.DataArray(
357
- data=eeg_data,
358
- dims=["channel", "time"],
359
- coords={"time": time_steps, "channel": channel_names},
360
- )
361
- return eeg_xarray
362
-
363
328
  def add_bids_dataset(
364
329
  self, dataset: str, data_dir: str, overwrite: bool = True
365
330
  ) -> None:
@@ -423,39 +388,6 @@ class EEGDash:
423
388
  logger.info("Upserted: %s", result.upserted_count)
424
389
  logger.info("Errors: %s ", result.bulk_api_result.get("writeErrors", []))
425
390
 
426
- def get(self, query: dict[str, Any]) -> list[xr.DataArray]:
427
- """Download and return EEG data arrays for records matching a query.
428
-
429
- Parameters
430
- ----------
431
- query : dict
432
- MongoDB query used to select records.
433
-
434
- Returns
435
- -------
436
- list of xr.DataArray
437
- EEG data for each matching record, with dimensions ``("channel", "time")``.
438
-
439
- Notes
440
- -----
441
- Retrieval runs in parallel. Downloaded files are read and discarded
442
- (no on-disk caching here).
443
-
444
- """
445
- sessions = self.find(query)
446
- results = []
447
- if sessions:
448
- logger.info("Found %s records", len(sessions))
449
- results = Parallel(
450
- n_jobs=-1 if len(sessions) > 1 else 1, prefer="threads", verbose=1
451
- )(
452
- delayed(downloader.load_eeg_from_s3)(
453
- downloader.get_s3path("s3://openneuro.org", session["bidspath"])
454
- )
455
- for session in sessions
456
- )
457
- return results
458
-
459
391
  def _add_request(self, record: dict):
460
392
  """Internal helper method to create a MongoDB insertion request for a record."""
461
393
  return InsertOne(record)
@@ -1016,3 +948,6 @@ class EEGDashDataset(BaseConcatDataset, metaclass=NumpyDocstringInheritanceInitM
1016
948
  )
1017
949
  )
1018
950
  return datasets
951
+
952
+
953
+ __all__ = ["EEGDash", "EEGDashDataset"]
@@ -385,3 +385,11 @@ def enrich_from_participants(
385
385
  extras = participants_extras_from_tsv(bids_root, subject)
386
386
  attach_participants_extras(raw, description, extras)
387
387
  return extras
388
+
389
+
390
+ __all__ = [
391
+ "participants_row_for_subject",
392
+ "participants_extras_from_tsv",
393
+ "attach_participants_extras",
394
+ "enrich_from_participants",
395
+ ]
eegdash/data_utils.py CHANGED
@@ -672,3 +672,6 @@ class EEGBIDSDataset:
672
672
  for list_field in ["name", "type", "units"]:
673
673
  channel_tsv[list_field] = list(channel_tsv[list_field].values())
674
674
  return channel_tsv
675
+
676
+
677
+ __all__ = ["EEGDashBaseDataset", "EEGBIDSDataset", "EEGDashBaseRaw"]
eegdash/downloader.py CHANGED
@@ -10,15 +10,10 @@ between the EEGDash metadata database and the actual EEG data stored in the clou
10
10
  """
11
11
 
12
12
  import re
13
- import tempfile
14
13
  from pathlib import Path
15
14
  from typing import Any
16
- from urllib.parse import urlsplit
17
15
 
18
- import mne
19
- import numpy as np
20
16
  import s3fs
21
- import xarray as xr
22
17
  from fsspec.callbacks import TqdmCallback
23
18
 
24
19
 
@@ -108,80 +103,9 @@ def _filesystem_get(filesystem: s3fs.S3FileSystem, s3path: str, filepath: Path):
108
103
  return filepath
109
104
 
110
105
 
111
- def load_eeg_from_s3(s3path: str):
112
- """Load EEG data from an S3 URI into an ``xarray.DataArray``.
113
-
114
- Preserves the original filename, downloads sidecar files when applicable
115
- (e.g., ``.fdt`` for EEGLAB, ``.vmrk``/``.eeg`` for BrainVision), and uses
116
- MNE's direct readers.
117
-
118
- Parameters
119
- ----------
120
- s3path : str
121
- An S3 URI (should start with "s3://").
122
-
123
- Returns
124
- -------
125
- xr.DataArray
126
- EEG data with dimensions ``("channel", "time")``.
127
-
128
- Raises
129
- ------
130
- ValueError
131
- If the file extension is unsupported.
132
-
133
- """
134
- filesystem = get_s3_filesystem()
135
- # choose a temp dir so sidecars can be colocated
136
- with tempfile.TemporaryDirectory() as tmpdir:
137
- # Derive local filenames from the S3 key to keep base name consistent
138
- s3_key = urlsplit(s3path).path # e.g., "/dsXXXX/sub-.../..._eeg.set"
139
- basename = Path(s3_key).name
140
- ext = Path(basename).suffix.lower()
141
- local_main = Path(tmpdir) / basename
142
-
143
- # Download main file
144
- with (
145
- filesystem.open(s3path, mode="rb") as fsrc,
146
- open(local_main, "wb") as fdst,
147
- ):
148
- fdst.write(fsrc.read())
149
-
150
- # Determine and fetch any required sidecars
151
- sidecars: list[str] = []
152
- if ext == ".set": # EEGLAB
153
- sidecars = [".fdt"]
154
- elif ext == ".vhdr": # BrainVision
155
- sidecars = [".vmrk", ".eeg", ".dat", ".raw"]
156
-
157
- for sc_ext in sidecars:
158
- sc_key = s3_key[: -len(ext)] + sc_ext
159
- sc_uri = f"s3://{urlsplit(s3path).netloc}{sc_key}"
160
- try:
161
- # If sidecar exists, download next to the main file
162
- info = filesystem.info(sc_uri)
163
- if info:
164
- sc_local = Path(tmpdir) / Path(sc_key).name
165
- with (
166
- filesystem.open(sc_uri, mode="rb") as fsrc,
167
- open(sc_local, "wb") as fdst,
168
- ):
169
- fdst.write(fsrc.read())
170
- except Exception:
171
- # Sidecar not present; skip silently
172
- pass
173
-
174
- # Read using appropriate MNE reader
175
- raw = mne.io.read_raw(str(local_main), preload=True, verbose=False)
176
-
177
- data = raw.get_data()
178
- fs = raw.info["sfreq"]
179
- max_time = data.shape[1] / fs
180
- time_steps = np.linspace(0, max_time, data.shape[1]).squeeze()
181
- channel_names = raw.ch_names
182
-
183
- return xr.DataArray(
184
- data=data,
185
- dims=["channel", "time"],
186
- coords={"time": time_steps, "channel": channel_names},
187
- )
106
+ __all__ = [
107
+ "download_s3_file",
108
+ "download_dependencies",
109
+ "get_s3path",
110
+ "get_s3_filesystem",
111
+ ]
eegdash/logging.py CHANGED
@@ -31,3 +31,5 @@ root_logger.setLevel(logging.INFO)
31
31
  logger = logging.getLogger("eegdash")
32
32
 
33
33
  logger.setLevel(logging.INFO)
34
+
35
+ __all__ = ["logger"]
eegdash/mongodb.py CHANGED
@@ -75,3 +75,6 @@ class MongoConnectionManager:
75
75
  except Exception:
76
76
  pass
77
77
  cls._instances.clear()
78
+
79
+
80
+ __all__ = ["MongoConnectionManager"]
eegdash/paths.py CHANGED
@@ -37,3 +37,6 @@ def get_default_cache_dir() -> Path:
37
37
 
38
38
  # 3) Default to a project-local hidden folder
39
39
  return Path.cwd() / ".eegdash_cache"
40
+
41
+
42
+ __all__ = ["get_default_cache_dir"]
eegdash/utils.py CHANGED
@@ -19,3 +19,6 @@ def _init_mongo_client():
19
19
  "mongodb+srv://eegdash-user:mdzoMjQcHWTVnKDq@cluster0.vz35p.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0",
20
20
  set_env=True,
21
21
  )
22
+
23
+
24
+ __all__ = ["_init_mongo_client"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eegdash
3
- Version: 0.4.0.dev144
3
+ Version: 0.4.0.dev150
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
@@ -35,7 +35,6 @@ Requires-Dist: python-dotenv
35
35
  Requires-Dist: s3fs
36
36
  Requires-Dist: scipy
37
37
  Requires-Dist: tqdm
38
- Requires-Dist: xarray
39
38
  Requires-Dist: h5io>=0.2.4
40
39
  Requires-Dist: pymatreader
41
40
  Requires-Dist: eeglabio
@@ -58,6 +57,7 @@ Requires-Dist: sphinx_gallery; extra == "docs"
58
57
  Requires-Dist: sphinx_rtd_theme; extra == "docs"
59
58
  Requires-Dist: pydata-sphinx-theme; extra == "docs"
60
59
  Requires-Dist: sphinx-autobuild; extra == "docs"
60
+ Requires-Dist: sphinx-copybutton; extra == "docs"
61
61
  Requires-Dist: sphinx-sitemap; extra == "docs"
62
62
  Requires-Dist: numpydoc; extra == "docs"
63
63
  Requires-Dist: memory_profiler; extra == "docs"
@@ -1,13 +1,13 @@
1
- eegdash/__init__.py,sha256=mb1qG2Bvohd8m8HMQlfoq8GO9ANnQZ3bnjL8QnJKlFU,704
2
- eegdash/api.py,sha256=OLQbpOoIZpZVJSss3imLFmN6d1Fpwk6tj-yRMQlr00Q,39429
3
- eegdash/bids_eeg_metadata.py,sha256=EFJ1grNcqS0eF0hg45F6St8gFc3Hlzsgccpr-9XTMZk,14153
1
+ eegdash/__init__.py,sha256=E0583aFzz3UAElK7BMSDvWmuTNyiEkhJXjqlNsxg7n0,704
2
+ eegdash/api.py,sha256=vcme_BXxc0KpyLwQfrzV7lojM0s16P7KPq-62Gu9ee4,37241
3
+ eegdash/bids_eeg_metadata.py,sha256=0fA5FDM4OlSS83JziRI7-hPvh-KRvwKBpT1dMeB4znk,14307
4
4
  eegdash/const.py,sha256=-cwrtncqJHZ19lGf2MK-IgKy7hTMfb6H-CeL50Oonyg,7883
5
- eegdash/data_utils.py,sha256=s9FyPpsw32ndBsusL4TQX6rOsLEiN73RneEuXKffaYc,26477
6
- eegdash/downloader.py,sha256=TsoFDmzSBLiTwW_scfju4MXEIq088upHvdEfGw_c8WM,6256
7
- eegdash/logging.py,sha256=Tbz-zXaxvzZkYmrAQTEyFqevzWtM5QZPP6LL7XNy8d0,952
8
- eegdash/mongodb.py,sha256=0QpkAdwQOisbCr0-rd0wPFQiG0IT9h2Ae-CXYdrt65o,2430
9
- eegdash/paths.py,sha256=-bl81r7UyPr-Kq6V6j6h9Mq6dxg5T5EkBVJlOLmQecg,1217
10
- eegdash/utils.py,sha256=05MwB7Y447qkWfxCqgGy2DZUHPV1c1xvr3EUyhD0OHI,723
5
+ eegdash/data_utils.py,sha256=5g88vIuU_KTixWF2BV6wtQTs8ba23OPIMkrsEklmiE8,26548
6
+ eegdash/downloader.py,sha256=ukkol-2Y-8FGgociwJR-3TqBfvbUuCuMt2L6E_6baDY,3638
7
+ eegdash/logging.py,sha256=Jux2A3YM9m2ksETErEfUG7wnB7jpJw6v1JH9tQuYVJc,974
8
+ eegdash/mongodb.py,sha256=oXjiNLf0-46r_0RbxG8Y8wQZl8MIcfGQt4_qieU2MqU,2469
9
+ eegdash/paths.py,sha256=4-ae23KeXMP5yaKAJCNW7pQGV19c00ll0EGElV2rZn8,1255
10
+ eegdash/utils.py,sha256=e7LdirPY0dAfMZNWTbgAguqzu-dq0zo-mtXB9nIzf_c,758
11
11
  eegdash/dataset/__init__.py,sha256=HKDfV2DHBv63BqYLBWDMvU8jbFNRC7DqQbxL7RG1DKQ,863
12
12
  eegdash/dataset/dataset.py,sha256=e_rliu4E-uPtz_miUSzGukUahCHHhyXB2Gu3pm3cyHo,7062
13
13
  eegdash/dataset/dataset_summary.csv,sha256=a5Y21LmBPKLVRt5uKNXO7lSRDjsDmJLzv6-3HryF5JU,23614
@@ -30,8 +30,8 @@ eegdash/features/feature_bank/utils.py,sha256=DGh-Q7-XFIittP7iBBxvsJaZrlVvuY5mw-
30
30
  eegdash/hbn/__init__.py,sha256=hsI5pmIuYDzr--aE5UiToO-P9XL5fVRKahZzdsAodro,794
31
31
  eegdash/hbn/preprocessing.py,sha256=cfsLXnGuUaVJ3NhueDgmdc0w7jflmIi69occuB4bs7M,2609
32
32
  eegdash/hbn/windows.py,sha256=23KyVl0pQn4o40wM3Rsu8nl5tN-REAusU7wcv9L4a5U,10351
33
- eegdash-0.4.0.dev144.dist-info/licenses/LICENSE,sha256=asisR-xupy_NrQBFXnx6yqXeZcYWLvbAaiETl25iXT0,931
34
- eegdash-0.4.0.dev144.dist-info/METADATA,sha256=CgGdbNlkxb0Ako1Q1cwdwEotFGf-CBz2yEZm6WBMmlw,6776
35
- eegdash-0.4.0.dev144.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- eegdash-0.4.0.dev144.dist-info/top_level.txt,sha256=zavO69HQ6MyZM0aQMR2zUS6TAFc7bnN5GEpDpOpFZzU,8
37
- eegdash-0.4.0.dev144.dist-info/RECORD,,
33
+ eegdash-0.4.0.dev150.dist-info/licenses/LICENSE,sha256=asisR-xupy_NrQBFXnx6yqXeZcYWLvbAaiETl25iXT0,931
34
+ eegdash-0.4.0.dev150.dist-info/METADATA,sha256=YbiJANCGZcLMSn2pjX73kOm0QO_pFzYTVifwtVhAZ_A,6804
35
+ eegdash-0.4.0.dev150.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
+ eegdash-0.4.0.dev150.dist-info/top_level.txt,sha256=zavO69HQ6MyZM0aQMR2zUS6TAFc7bnN5GEpDpOpFZzU,8
37
+ eegdash-0.4.0.dev150.dist-info/RECORD,,