From 363b9baad70186c2c28fa67bd3001e40551af9e5 Mon Sep 17 00:00:00 2001 From: bruAristimunha Date: Sat, 11 Oct 2025 13:46:23 +0200 Subject: [PATCH 1/2] updating dep --- eegdash/data_utils.py | 14 +++++++++++--- pyproject.toml | 7 +++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/eegdash/data_utils.py b/eegdash/data_utils.py index 199d94d2..d90a0cae 100644 --- a/eegdash/data_utils.py +++ b/eegdash/data_utils.py @@ -22,10 +22,10 @@ import mne_bids import numpy as np import pandas as pd -from bids import BIDSLayout from joblib import Parallel, delayed from mne._fiff.utils import _read_segments_file from mne.io import BaseRaw +from mne.utils.check import _soft_import from mne_bids import BIDSPath from braindecode.datasets import BaseDataset @@ -348,6 +348,14 @@ def __init__( data_dir=None, # location of bids dataset dataset="", # dataset name ): + bids_lib = _soft_import("bids", purpose="digestion of datasets", strict=False) + + if bids_lib is None: + raise ImportError( + "The 'pybids' package is required to use EEGBIDSDataset. " + "Please install it via 'pip install eegdash[digestion]'." + ) + if data_dir is None or not os.path.exists(data_dir): raise ValueError("data_dir must be specified and must exist") self.bidsdir = Path(data_dir) @@ -359,7 +367,7 @@ def __init__( raise AssertionError( f"BIDS directory '{dir_name}' does not correspond to dataset '{self.dataset}'" ) - self.layout = BIDSLayout(data_dir) + self.layout = bids_lib.BIDSLayout(data_dir) # get all recording files in the bids directory self.files = self._get_recordings(self.layout) @@ -379,7 +387,7 @@ def check_eeg_dataset(self) -> bool: """ return self.get_bids_file_attribute("modality", self.files[0]).lower() == "eeg" - def _get_recordings(self, layout: BIDSLayout) -> list[str]: + def _get_recordings(self, layout) -> list[str]: """Get a list of all EEG recording files in the BIDS layout.""" files = [] for ext, exts in self.RAW_EXTENSIONS.items(): diff --git a/pyproject.toml b/pyproject.toml index 39e52b8e..2424ab0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,11 +40,9 @@ dependencies = [ "numba", "numpy", "pandas", - "pybids", "pymongo", "python-dotenv", "s3fs", - "scipy", "tqdm", "h5io >= 0.2.4", "pymatreader", @@ -90,10 +88,15 @@ docs = [ "graphviz", ] +digestion = [ + "pybids", +] + all = [ "eegdash[docs]", "eegdash[dev]", "eegdash[tests]", + "eegdash[digestion]", ] [tool.setuptools] From 765eb66a3d62fe1900e6f807f5296a5ce01d8b93 Mon Sep 17 00:00:00 2001 From: bruAristimunha Date: Sat, 11 Oct 2025 13:50:59 +0200 Subject: [PATCH 2/2] including sugar --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 2424ab0a..dcca104b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,7 @@ Issues = "https://github.com/sccn/EEG-Dash-Data/issues" tests = [ 'pytest', 'pytest-cov', + 'pytest-sugar', 'codecov', 'pytest_cases', 'pytest-benchmark',