Bug with EEG resample (mixed sampling frequencies)

Dear françois,

I am having difficulties when I want to run a resample on data made in .EDF.
Some files open properly and I can do my processing afterwards but some files coming from the same analysis group cannot be processed.

Any idea how to solve this error? Thank you for taking the time to answer this question!


Can you please share a short example file?

  • Zip the smallest of your EDF files that causes this error,
  • upload it somewhere and
  • post the download link here


Thank you for the example files.
The problem is the mixed sampling frequencies (EEG=256 Hz, others=32Hz), that are not currently handled correctly in Brainstorm. This is related with the discussion associated with this GitHub commit:

We need to add in the EDF reader a dynamic resampling of all the data channels to the highest sampling rate in the file, so that they can all be processed in Brainstorm. At the moment, Brainstorm sets as bad all the channels with a sampling rate different from the EEG, and ignore them everywhere.

Some processes (like the resampling) are designed to work by groups of channels in order to minimize the size in memory for large files. This leads to reading blocks of channels that all have "wrong" sampling rates, and there it crashes. (I'm not sure why some files would work and others would not)

Two solutions to avoid this crash:

  • Make a copy of the continuous recordings in the database as .bst files: menu File > Export protocol > Copy raw files to database. All the channels with sampling rates other than 256Hz would be explicitly filled with zeros.
  • In the resampling process options, select the option "Process the entire file at once". This would read all the file at once and avoid this problem of selecting only "bad" channels at one iteration. All the non-EEG channels would be set to zero as well.

For being able to keep/view/process the non-EEG channels in Brainstorm, this will have to wait until we improve the EDF file reader.