Best practice for joining split, but non-compliantly named fif files

Apologies in advance if this question is misplaced - I am new to MEG data and MNE Python :slight_smile:

I have “inherited” MEG Elekta fif files from a single recording, split into three files.
The naming scheme of those files does not comply to MNE Python conventions or BIDS, it is unclear how those file names came to be, and a typical subject directory looks like this:

── Move_correc_SSS_realigneddefault_nonfittoiso
       ├── 1_memento_002_<sub-id>_mc_realigned.fif
       ├── 2_memento_002_<sub-id>-1_mc_realigned.fif
       ├── 3_memento_002_<sub-id>-2_mc_realigned.fif

Loading the first datafile (using MNE 0.23.dev0 on Debian testing) fails to co-load the second and third split. If I understand it correctly, this is due to the fact that the splits are not properly encoded in the metadata of the previous file, and that their file names also do not comply to MNE’s fall-back of an identical file name with a -1/-2 suffix in front of the extension.

raw = mne.io.read_raw_fif('Move_correc_SSS_realigneddefault_nonfittoiso/
   ...: 1_memento_002_ox81_mc_realigned.fif', on_split_missing="warn")
Opening raw data file Move_correc_SSS_realigneddefault_nonfittoiso/1_memento_002_ox81_mc_realigned.fif...
<ipython-input-3-7cbb1c29c355>:1: RuntimeWarning: This filename (Move_correc_SSS_realigneddefault_nonfittoiso/1_memento_002_ox81_mc_realigned.fif) does not conform to MNE naming conventions. All raw files should end with raw.fif, raw_sss.fif, raw_tsss.fif, raw.fif.gz, raw_sss.fif.gz, raw_tsss.fif.gz or _meg.fif
  raw = mne.io.read_raw_fif('Move_correc_SSS_realigneddefault_nonfittoiso/1_memento_002_ox81_mc_realigned.fif', on_split_missing="warn")
    Range : 37000 ... 1633999 =     37.000 ...  1633.999 secs
Ready.
<ipython-input-3-7cbb1c29c355>:1: RuntimeWarning: Split raw file detected but next file /media/adina/elements/backup/memento/data/DMS_MEMENTO/Data_MEG/RawData_MEG_memento/memento_002/Move_correc_SSS_realigneddefault_nonfittoiso/1_memento_002_ox81_mc_realigned-1.fif does not exist. Ensure all files were transferred properly and that split and original files were not manually renamed on disk (split files should be renamed by loading and re-saving with MNE-Python to preserve proper filename linkage).
  raw = mne.io.read_raw_fif('Move_correc_SSS_realigneddefault_nonfittoiso/1_memento_002_ox81_mc_realigned.fif', on_split_missing="warn")

My quite naive question is how to concatenate the three split MEG files in the intended/best way.
Ideally, I want to structure the raw data according to BIDS, but, as far as I understand, this wouldn’t comply to the “fall-back” file name of MNE Python when searching for the next split. Can I (and should I) feed information about the next split into the fif metadata? Or is there a function that lets me append a file to another one “by hand”? If I need to rename files, is it okay to do this from the command line, or is a re-save with MNE Python preferable?

I would be grateful for advice and best practices :slight_smile: Thanks in advance!
Adina

hi,

you should read the three split files separately and use

https://mne.tools/stable/generated/mne.concatenate_raws.html

HTH
Alex

1 Like

… and then you can of course re-save the data, optionally as BIDS-y split files again, via raw.save(..., split_naming=‘bids’)

1 Like

thanks a lot, @richard and @agramfort!