Skip to content

Commit 85ca277

Browse files
Merge pull request #173 from sccn/develop
Increase the version and releasing
2 parents b3b47d3 + 170c476 commit 85ca277

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-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: 6 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",
@@ -63,6 +61,7 @@ Issues = "https://github.com/sccn/EEG-Dash-Data/issues"
6361
tests = [
6462
'pytest',
6563
'pytest-cov',
64+
'pytest-sugar',
6665
'codecov',
6766
'pytest_cases',
6867
'pytest-benchmark',
@@ -90,10 +89,15 @@ docs = [
9089
"graphviz",
9190
]
9291

92+
digestion = [
93+
"pybids",
94+
]
95+
9396
all = [
9497
"eegdash[docs]",
9598
"eegdash[dev]",
9699
"eegdash[tests]",
100+
"eegdash[digestion]",
97101
]
98102

99103
[tool.setuptools]

0 commit comments

Comments
 (0)