Possible bug in BIDS split namig

Hi,

I’ve observed a strange behaviour (not sure if a bug) when saving Raw files, and a split is required. This only happens with the BIDS split naming version and if the BIDS naming convention is not followed, so that’s why it may be the expected behaviour.

When running this super-simple code snippet:

raw.save(rf'D:\path\path\path\{new_name}.fif', split_size='2GB', split_naming='bids', verbose='Error'),

with new_name having the following format:

0001-11_F_45_HC (that is, ID-ID_Sex_Age_Group)

The naming in the splits are:

  • 0001-11_F_45_split-01_HC
  • 0001-11_F_45_split-02_HC
  • 0001-11_F_45_split-03_HC

and I expected them to be:

  • 0001-11_F_45_HC_split-01
  • 0001-11_F_45_HC_split-02
  • 0001-11_F_45_HC_split-03

Is this the expected behaviour or is it a bug?
The easier workaround is to use the neuromag naming convention but the BIDS one fits better some additional funtions that I have developed

  • MNE version: 1.8.0
  • operating system: Windows 10

Hi and welcome to the forum!

The file name doesn’t conform to BIDS. By the spec, the last bit represents the modality; that’s why the split modality goes before that.

I have to say I’m not sure why MNE supports something called “BIDS split naming” if it doesn’t check whether the filename is even BIDS-compatible in the first place … this probably should not be part of the public API at all.

What is your opinion on this, @sappelhoff?

Best wishes,
Richard

This behavior seems unexpected to me, too.

I think we added the BIDS split naming back then to make something possible in mne-bids. I don’t remember why we made it part of the public API, instead of another route.

1 Like

Perhaps we’re relying on this in MNE-BIDS-Pipeline too, I would have to check…

@larsoner Any thoughts on this one?

Now that it’s in the public API it’s probably worth keeping there. Especially since people could potentially have legitimate use cases where they want to write their own BIDS-filename-formatted data, or even don’t care about the BIDS-ness but prefer how the BIDS option operates. To me we should just update the docs to say what the option will actually do, and note that it’s there primarily for compat with MNE-BIDS. I don’t think we should check BIDS path validity in MNE-Python.

1 Like

agreed!

That would be fine by me, too.

1 Like

The problem is likely that the check here was not triggered: mne-python/mne/_fiff/utils.py at 2983d2a19148e8760b67de399e85c91a3e040de7 · mne-tools/mne-python · GitHub