mne-bids icon indicating copy to clipboard operation
mne-bids copied to clipboard

Potential incompatibility between MNE 1.8.0 and MNE-BIDS 0.15.0

Open bootstrapbill opened this issue 1 year ago • 2 comments

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?

bootstrapbill avatar Sep 11 '24 20:09 bootstrapbill

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

welcome[bot] avatar Sep 11 '24 20:09 welcome[bot]

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

sappelhoff avatar Sep 12 '24 08:09 sappelhoff

Thanks for your work on this really nice tool!

I would support the fix for this bug being a patch to the current version (e.g. 0.15.1) rather than part of the next minor version milestone, provided the team has the resources to do so.

It is currently breaking the raw_to_bids subcommand as well, so long as an incompatible version of MNE is installed. I found this issue through googling the error but the normal error output isn't informative enough to easily resolve the issue.

berkgercek avatar Nov 13 '24 10:11 berkgercek

Hey all, I will try to push out a release this Saturday!

sappelhoff avatar Nov 13 '24 17:11 sappelhoff

Thanks! I've also found the problem in the upstream repo for MNE and created another issue for that so hopefully it will be fixed at the source as well soon.

berkgercek avatar Nov 14 '24 09:11 berkgercek

@bootstrapbill @berkgercek @thht mne-bids v0.16.0 has been released and is available on PyPI and in a few hours on conda-forge!

🚀 happy bids-ifying!

  • https://github.com/conda-forge/mne-bids-feedstock/pull/32

sappelhoff avatar Nov 16 '24 19:11 sappelhoff