Skip to content

Commit

Permalink
Merge branch 'main' into min-mne-1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hoechenberger authored May 28, 2023
2 parents 0fe8f75 + a3bf0b0 commit f32b746
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Detailed list of changes
- Fix ``raw_to_bids`` CLI tool to properly recognize boolean and numeric values for the ``line_freq`` and ``overwrite`` parameters, by `Stefan Appelhoff`_ (:gh:`1125`)
- Fix :func:`~mne_bids.copyfiles.copyfile_eeglab` to prevent data type conversion leading to an ``eeg_checkset`` failure when trying to load the file in EEGLAB, by `Laetitia Fesselier`_ (:gh:`1122`)
- Improve compatibility with latest MNE-Python, by `Eric Larson`_ (:gh:`1128`)
- Working with :class:`~mne_bids.BIDSPath` would sometimes inadvertently create new directories, contaminating the BIDS dataset, by `Richard Höchenberger`_ (:gh:`1139`)

:doc:`Find out what was new in previous releases <whats_new_previous_releases>`

Expand Down
5 changes: 3 additions & 2 deletions mne_bids/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,9 @@ def _get_matching_bidspaths_from_filesystem(bids_path):
datatype = _infer_datatype(root=bids_root,
sub=sub, ses=ses)

data_dir = BIDSPath(subject=sub, session=ses, datatype=datatype,
root=bids_root).mkdir().directory
data_dir = BIDSPath(
subject=sub, session=ses, datatype=datatype, root=bids_root
).directory

# For BTI data, just return the directory with a '.pdf' extension
# to facilitate reading in mne-bids
Expand Down
8 changes: 8 additions & 0 deletions mne_bids/tests/test_path.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test for the MNE BIDSPath functions."""
# Authors: Adam Li <[email protected]>
# Richard Höchenberger <[email protected]>
#
# License: BSD-3-Clause
import os
Expand Down Expand Up @@ -1258,3 +1259,10 @@ def test_deprecation():
"""Test deprecated behavior."""
with pytest.warns(FutureWarning, match='This will raise an exception'):
BIDSPath(extension='vhdr') # no leading period


def test_dont_create_dirs_on_fpath_access(tmp_path):
"""Regression test: don't create directories when accessing .fpath."""
bp = BIDSPath(subject='01', datatype='eeg', root=tmp_path)
bp.fpath # accessing .fpath is required for this regression test
assert not (tmp_path / 'sub-01').exists()

0 comments on commit f32b746

Please sign in to comment.