Skip to content

Commit 363b9ba

Browse files
updating dep
1 parent a8e3ce9 commit 363b9ba

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

eegdash/data_utils.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
import mne_bids
2323
import numpy as np
2424
import pandas as pd
25-
from bids import BIDSLayout
2625
from joblib import Parallel, delayed
2726
from mne._fiff.utils import _read_segments_file
2827
from mne.io import BaseRaw
28+
from mne.utils.check import _soft_import
2929
from mne_bids import BIDSPath
3030

3131
from braindecode.datasets import BaseDataset
@@ -348,6 +348,14 @@ def __init__(
348348
data_dir=None, # location of bids dataset
349349
dataset="", # dataset name
350350
):
351+
bids_lib = _soft_import("bids", purpose="digestion of datasets", strict=False)
352+
353+
if bids_lib is None:
354+
raise ImportError(
355+
"The 'pybids' package is required to use EEGBIDSDataset. "
356+
"Please install it via 'pip install eegdash[digestion]'."
357+
)
358+
351359
if data_dir is None or not os.path.exists(data_dir):
352360
raise ValueError("data_dir must be specified and must exist")
353361
self.bidsdir = Path(data_dir)
@@ -359,7 +367,7 @@ def __init__(
359367
raise AssertionError(
360368
f"BIDS directory '{dir_name}' does not correspond to dataset '{self.dataset}'"
361369
)
362-
self.layout = BIDSLayout(data_dir)
370+
self.layout = bids_lib.BIDSLayout(data_dir)
363371

364372
# get all recording files in the bids directory
365373
self.files = self._get_recordings(self.layout)
@@ -379,7 +387,7 @@ def check_eeg_dataset(self) -> bool:
379387
"""
380388
return self.get_bids_file_attribute("modality", self.files[0]).lower() == "eeg"
381389

382-
def _get_recordings(self, layout: BIDSLayout) -> list[str]:
390+
def _get_recordings(self, layout) -> list[str]:
383391
"""Get a list of all EEG recording files in the BIDS layout."""
384392
files = []
385393
for ext, exts in self.RAW_EXTENSIONS.items():

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ dependencies = [
4040
"numba",
4141
"numpy",
4242
"pandas",
43-
"pybids",
4443
"pymongo",
4544
"python-dotenv",
4645
"s3fs",
47-
"scipy",
4846
"tqdm",
4947
"h5io >= 0.2.4",
5048
"pymatreader",
@@ -90,10 +88,15 @@ docs = [
9088
"graphviz",
9189
]
9290

91+
digestion = [
92+
"pybids",
93+
]
94+
9395
all = [
9496
"eegdash[docs]",
9597
"eegdash[dev]",
9698
"eegdash[tests]",
99+
"eegdash[digestion]",
97100
]
98101

99102
[tool.setuptools]

0 commit comments

Comments
 (0)