data lost when exporting to .edf

MNE version: 1.4.2
operating system: macOS 12.5

I am trying to do the following:

  1. Read in a .edf file
  2. Select a subset of channels and rename them.
  3. Export to a new .edf file

The code I use to do this is the following, where rawFile is the path to the original .edf and standardFile is the path to the new .edf to be written.

            psgFile = mne.io.read_raw_edf(rawFile)
            psgInfo = psgFile.info
            for channel in psgInfo.ch_names:
                if channel in self.channel_mapping.keys():
                    mne.rename_channels(psgFile.info,{channel:self.channel_mapping[channel]})
                else:
                    psgFile.drop_channels(channel)
            mne.export.export_raw(standardFile,psgFile,overwrite=True)

It seems to work fine, but then I read in my new file as follows:
psgFile2 = mne.io.read_raw_edf(standardFile)

When I look at graphs of psgFile2, all channels are flat lines. Each channel contains a time series with only one value in it, 0.00011273

Any guidance would be greatly appreciated!

Please modify your example so that it uses this EDF file (which is publicly available):

https://osf.io/4g3uw

That way, I can try to reproduce this issue.

1 Like