reading bdf+ files?

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Mon Mar 8 09:27:24 CET 2010

Hi Thomas,

On 5 Mar 2010, at 17:02, Thomas Hartmann wrote:

> hi,
> i try to read bdf+ files created using edflib (
> )
> although the file looks good in the reader, fieldtrip complains
> about "channels with different sampling rate not supported". i
> debugged the code. the error occurs because bdf+ files have an
> additional channel storeing events. this one seems to have a
> different samplerate.
> i disabled these checks which resulted in a new error-message:
> "One ore more output arguments not assigned during call to
> "read_24bit"."
> is the support of fieldtrip restricted to bdf and not bdf+-files? or
> is there something wrong with the lib i use to write the file?

I don't know the details of the bdf+ format, but do know the bdf
format. Probably bdf+ is plain bdf with an annotation channel. Are you
using annotations? The biosemi system does not, it uses a non-standard
trigger channel sampled at the same frequency as all other channels
(i.e. "non standard" meaning that it does not comply with the
published papers on edf and edf+). Having a trigger channel at the
same sampling rate makes the implementation of software and hardware
and interpretation of the data much simpler.

In general data is desribed as Nchan X Nsamples matrix. If one of the
channels has another sampling rate, it does not fit in this matrix,
that is why varying sampling rates over channels are not supported. If
the event/status/trigger channel is represented as a continuously
sampled channel (like in bdf), it is read along with all other
channels. The same limitation applies to edf and edf+. The annotation
channel is difficult to deal with and in the read_biosemi_bdf
implementation not supported.

The bdf format has small blocks (usually one second long) in which the
channels are stored like
ch1_1 ch1_2 ch1_3 ... ch2_1 ch2_2 ch2_3 ...
i.e. all samples of one channel as a vector, and then the next
channel. This allows for variable sampling rates, whereas a
multiplexed representation would not. Specific for the bdf format is
that the samples are represented as 24 bit (where 32 bit is more
usual). The read_24bit mex file reads such a block and converts the 24
bit values to doubles. The reason for having it in a mex file is that
the conversion from 24 bits to double is much more efficient.

best regards

The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also and

More information about the fieldtrip mailing list