Saving and loading a raw object as a .fif file, changes the info['bads']

Hello,

I have encountered a super weird behaviour: if I save the raw object after editing info[‘bads’], it is not loaded properly after the save.

The code:

print('rawManualCleanDownsampledFiltered.info[bads]')
print(rawManualCleanDownsampledFiltered.info['bads'])

rawManualCleanDownsampledFiltered.save(fileName, overwrite = True)
dataFromFile  =  mne.io.read_raw_fif(fileName)

print('dataFromFile.info[bads]')
print(dataFromFile.info['bads'])

Output:

rawManualCleanDownsampledFiltered.info[bads]
['EOG2:A1', 'EOG1:A1', 'C4:A1', 'C3:A2', 'Thorax', 'Pos.']
Overwriting existing file.
Overwriting existing file.
Overwriting existing file.
Writing 
/103_after_new_preprocess_before_ICA_eeg.fif
Closing 
/103_after_new_preprocess_before_ICA_eeg.fif
[done]
Opening raw data file
/103_after_new_preprocess_before_ICA_eeg.fif...
Isotrak not found
    Range : 0 ... 4081023 =      0.000 ... 31882.992 secs
Ready.
Reading 0 ... 4081023  =      0.000 ... 31882.992 secs...
dataFromFile.info[bads]
['EOG2', 'A1', 'EOG1', 'A1', 'C4', 'A1', 'C3', 'A2', 'Thorax', 'Pos.']

Could you please prepare a minimal working example (MWE) to replicate your problem, using one of the datasets shipped with MNE-Python, preferably the one called sample?

Also please note that bug reports are often better posted as issues on the MNE-Python GitHub repository: GitHub - mne-tools/mne-python: MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python

1 Like