mne-tools / mne-bids

MNE-BIDS is a Python package that allows you to read and write BIDS-compatible datasets with the help of MNE-Python.
https://mne.tools/mne-bids/
BSD 3-Clause "New" or "Revised" License
132 stars 87 forks source link

Potential incompatibility between MNE 1.8.0 and MNE-BIDS 0.15.0 #1306

Open bootstrapbill opened 1 month ago

bootstrapbill commented 1 month ago

Description of the problem

When calling write_raw_bids() I ran into the following error:

TypeError: 'datetime.date' object is not subscriptable

After some digging I realised that this is due to the switch in MNE 1.8.0 to storing subject birthdays as a date object instead of a tuple. But, in MNE-BIDS 0.15.0 a tuple is still expected.

I can see this bug has already been fixed here: https://github.com/mne-tools/mne-bids/pull/1278#issue-2414361488, but since that's currently only in the development version the latest stable releases of MNE and MNE-BIDS are incompatible (at least in this specific situation), right?

Steps to reproduce

import os.path as op
import datetime
import mne
from mne.datasets import sample

from mne_bids import (
    BIDSPath,
    write_raw_bids,
)

data_path = sample.data_path()

event_id = {
    "Auditory/Left": 1,
    "Auditory/Right": 2,
    "Visual/Left": 3,
    "Visual/Right": 4,
    "Smiley": 5,
    "Button": 32,
}

raw_fname = op.join(data_path, "MEG", "sample", "sample_audvis_raw.fif")
events_fname = op.join(data_path, "MEG", "sample", "sample_audvis_raw-eve.fif")
output_path = op.join(data_path, "..", "MNE-sample-data-bids")

raw = mne.io.read_raw(raw_fname)

raw.info["line_freq"] = 60

# add birthday following mne 1.8.0 specifications
raw.info['subject_info'] = {'birthday': datetime.date(1999,1,1)}

task = "audiovisual"

bids_path = BIDSPath(
    subject="01", session="01", task=task, run="1", datatype="meg", root=output_path
)

write_raw_bids(
    raw=raw,
    bids_path=bids_path,
    events=events_fname,
    event_id=event_id,
    overwrite=True,
)

Expected results

Expect write_raw_bids() to run as normal.

Actual results

TypeError: 'datetime.date' object is not subscriptable

Additional information

I'm not sure what the protocol is here, can the fix be backported? Or could this potential incompatibility be flagged in the documentation until the next release is rolled out? I've checked and the issue can easily be circumvented by either downgrading MNE (to 1.7.1) or installing the current development version of MNE-BIDS, so one of those solutions could be recommended?

welcome[bot] commented 1 month ago

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

sappelhoff commented 1 month ago

Thanks for the report! You are right -- we should probably make a release to fix this.