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
131 stars 85 forks source link

BUG: Error when writing calibration for empty-room file #1188

Closed larsoner closed 10 months ago

larsoner commented 10 months ago

I tried writing a fine cal file for empty-room data and got:

    write_meg_calibration(this_path / "sss_cal.dat", bids_path=bp)
  File "<decorator-gen-420>", line 12, in write_meg_calibration
  File "/home/larsoner/python/mne-bids/mne_bids/write.py", line 2616, in write_meg_calibration
    out_path = BIDSPath(
               ^^^^^^^^^
  File "/home/larsoner/python/mne-bids/mne_bids/path.py", line 367, in __init__
    self.update(
  File "/home/larsoner/python/mne-bids/mne_bids/path.py", line 1017, in update
    raise e
  File "/home/larsoner/python/mne-bids/mne_bids/path.py", line 1011, in update
    self._check()
  File "/home/larsoner/python/mne-bids/mne_bids/path.py", line 1077, in _check
    _check_empty_room_basename(self)
  File "/home/larsoner/python/mne-bids/mne_bids/utils.py", line 341, in _check_empty_room_basename
    raise ValueError(msg)
ValueError: task must be "noise" if subject is "emptyroom", but received: None

This is because in write_meg_calibration it does:

    out_path = BIDSPath(
        subject=bids_path.subject,
        session=bids_path.session,
        acquisition="calibration",
        suffix="meg",
        extension=".dat",
        datatype="meg",
        root=bids_path.root,
    )

So it copies the subject ("emptyroom") but not the task ("noise").

It seems like either the logic should be reworked here a bit, or an informative error should be raised if you try to write fine cal for empy room data.

hoechenberger commented 10 months ago

Absolutely, we shouldn't expect task-noise when writing empty-room fine-calibration and cross-talk

sappelhoff commented 10 months ago

agreed, these files shouldn't even have a task entity: https://bids-specification.readthedocs.io/en/latest/appendices/meg-file-formats.html#cross-talk-and-fine-calibration-files