Remove automatic zero-padding when specifing run in BIDSPath()

Hello,

I have an BIDS compatible dataset, which I want to load using BIDSPath.

bids_path = BIDSPath(subject=subject_id,session="01", task='act', run=1,
                     datatype='eeg', suffix='eeg',
                     root=bids_root,)

This is the example naming for the files within the dataset:

sub-002_ses-01_task-act_run-1_eeg

Note there, that for run the 1 is specified. As in my code above I have specified run=1, so theoretically it should work. However mne-bids seems to add an automatic-zero padding for the run number and expects:

sub-002_ses-01_task-act_run-01_eeg

Now my questions is whether I have to rename all data within the dataset or do the filename encoding by myself. Or maybe there is an option were I can disable the zero padding.

Using

  • mne 1.5.1
  • mne-bids 0.14

Thank you,
carlo

1 Like

Hello @carlo711 and welcome to the forum!
To me this seems like a problem we need to fix in MNE-BIDS. I don’t think there’s currently a workaround to avoid this problem, sorry.

You definitely shouldn’t have to rename your files.

@sappelhoff WDYT?

Best wishes,
Richard

yes, if we can replicate this issue, we should fix it! Could you please open an issue on the GitHub repo @carlo711?

just a thought, maybe specifying run as a str works: run='1'.

part of the reported behavior is also documented, see: https://github.com/mne-tools/mne-bids/blob/781fc577dc0da0419f7eb5c40d537b51834cb802/mne_bids/path.py#L879-L880

1 Like

Thank you the method with as string worked :slight_smile:
However I got the issue

Please use HDF reader for matlab v7.3 files, e.g. h5py

I resolved it by installing

pip install mat73
pip install pymatreader

This behavior will change with: Do not zero-pad indices in BIDSPath entities anymore; do not warn about prepending missing dots for extensions by alexrockhill · Pull Request #1215 · mne-tools/mne-bids · GitHub

most likely in mne_bids 0.15

1 Like