-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
BUG: Fix bug with BIDS split saving #12451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
+1 for proposal 4, raise an exception |
|
+1 for iv as well, with raising a clearly written exception |
* upstream/main: [pre-commit.ci] pre-commit autoupdate (mne-tools#12453) MAINT: Fix CIs for PyQt6 (mne-tools#12452)
|
Okay pushed a test fix. Also removed our dependency on pytest-harvest since what we use it for is very basic (hardly added any new code for us to avoid using it) and it's not fully pytest 8.0.0 + python12 compatible anyway. @sappelhoff feel free to review when you have a chance! |
| @@ -0,0 +1 @@ | |||
| from .base import fetch_infant_template | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snuck this in there because with latest pytest dev I was getting some weird error about submodule nesting... this makes _infant somehow appear as a more proper module so that it doesn't complain.
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
sappelhoff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks!
Co-authored-by: Stefan Appelhoff <stefan.appelhoff@mailbox.org>
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com> Co-authored-by: Stefan Appelhoff <stefan.appelhoff@mailbox.org>
In mne-tools/mne-bids-pipeline#852 there is a bug where BIDSPath-based files were being written as:
This is because a mne-bids-pipeline naively did something like:
but it needed to have
split=Nonein theupdatecall to avoid the double_split-01_split-01.This is because currently MNE-Python takes
fname, converts it to apathlib.Path(automatically via dunderBIDSPath.__fspath__, which is an alias forstr(BIDSPath.fpath)), then checks to see if splits need to be done, and if so appends_split-01while writing. So you end up with a filename..._split-01_split-01_epo.fif.So far this PR just exposes the issue (true TDD!). My proposed solution is to:
Try to detect
mne_bids.BIDSPathinstances before converting to a path.If
bids_path.split is not None, do one of:bids_path.split, thereby still writing_split-01_split-01_epo.fif(backward compatible change; filename is invalid BIDS I think)bids_path.split = None, thereby writing_split-01_epo.fifor_epo.fifinstead depending on the data size (backward incompatible change)bids_path.split not in (None, "01"), and replace bids_path.split = None` (backward incompatible change; seems fragile because the warning behavior depends on stuff like the size of the data being saved to disk)@sappelhoff @hoechenberger any opinion on which is best here? I'm inclined toward option (iv) / raising an error because it forces the user in their code to do a
.update(split=None)when writing a file, which makes things more explicit for them (i.e., makes it clear a_epo.fifor a_split-01_epo.fifcould be written depending on the file size).