Saving the preprocessed eeg data in edf format

Hi,
I am facing issue in saving the preprocessed EEG data in EDF format. I read the EEG raw data in EDF format and did filtering, channel picking, average referencing, epoching and BPF. After these preprocessing steps, I tried to save the data in EDF format into a folder but I am continously getting effor. Could you please help me to solve this issue. The code I tried is as;

raw_path=('/Users/sreelakshmiraveendran/Desktop/NIMHANS_data/New device/EDF FILES/EDF/SUB/MANJUSHA^SUB 20.edf') #p1
raw = mne.io.read_raw(raw_path)
eeg_cropped = raw.crop(tmin=1370, tmax=1500)
eeg_data = eeg_cropped.pick_channels(['Fp1', 'Fpz', 'Fp2', 'FT7', 'FT8', 'P3', 'Pz', 'P4', 'P9', 'P10', 'O1', 'O2', 'F3', 'Fz', 'F4', 'F7', 'F8', 'F9', 'F10', 'Cz', 'C3', 'C4', 'T3', 'T4', 'T5', 'T6', 'T9', 'T10'])
avg_ref_data = eeg_data.load_data().set_eeg_reference(ref_channels='average')
avg_ref_data.save(pathlib.Path('out_data')/'avg_ref_data.edf', overwrite=True)

The error:

OSError: The filename (/Users/sreelakshmiraveendran/Desktop/out_data/s_15.edf) for file type raw must end with .fif or .fif.gz
  • MNE-Python version: 0.24.0
  • operating system: Mac OS

According to the error message you are trying to save the data to a .fif (or .fif.gz) file. If you want an EDF file, use raw.export() instead.

2 Likes