ASCII to EDF format converter

The Approach

The main goal of this post is to explain how to convert OpenBCI datasets in EDF format files in a simple, easy and straightforward way. Many researchers and programmers have shared their files and software, either on an individual basis or in the framework of a larger group or project. In the name of all EDF users, I sincerely acknowledge their contributions: they make life a lot easier. This page aims to list all freely available EDF(+) files and software, including ours. Your contribution, too, will be very much appreciated.

The EDF/EDF+ format

EDF and EDF+ are the standard file formats for EEG and PSG recordings but are also used for EMG, Evoked Potentials, and ECG.

EDF is a straightforward and flexible standard format for exchange and storage of (bio)physical signals. The signals can have any (and different) physical dimensions and sampling frequencies. Programming an EDF import/export unit typically takes a week. EDF was published in 1992 in Electroencephalography and Clinical Neurophysiology, 82: 391-393.

EDF+ is an improved specification of EDF. It is compatible to EDF except that an EDF+ file may contain interrupted recordings. EDF+ also accommodates annotations and analysis results. Software development is limited mainly to implementing the annotations and typically takes another week. EDF+ was published in 2003 in Clinical Neurophysiology 114(9):1755-1761.

Detailed specifications, free software and files, and a list of compatible equipment and software are on EdfPlus.


The Specification

One data file contains one continuous digitized polygraphic recording. A data file consists of a header record followed by data records. The variable-length header record identifies the patient and specifies the technical characteristics of the recorded signals. The data files contain consecutive fixed-duration epochs of the polygraphic recording.

The first 256 bytes of the header record specify the version number of this format, local patient and recording identification, time information about the recording, the number of data records and finally the number of signals (ns) in each data record. Then for each signal another 256 bytes follow in the header record, each specifying the type of signal (e.g. EEG, body temperature, etc.), amplitude calibration and the number of samples in each data record (from which the sampling frequency can be derived since the duration of a data record is also known). In this way, the format allows for different gains and sampling frequencies for each signal. The header record contains 256 + (ns x 256) bytes. Figure 1 shows it’s detailed format and figure 2 shows an example.

The information in the ASCII strings must be left justified and filled out with spaces. Midnight time is 00 00 00. The duration of each data record is recommended to be a whole number of seconds and its size (number of bytes) is recommended not to exceed 61,440. Only if a 1 sec data record exceeds this size limit, the duration is recommended to be smaller than 1 sec (e.g. 0.01).

The digital minimum and maximum of each signal should specify the extreme values that can occur in the data records. These often are the extreme output values of the A/D converter. The physical (usually also physiological) minimum and maximum of this signal
should correspond to these digital extremes and be expressed in the also specified physical dimension of the signal. These four extreme values determine offset and amplification of the signal.

Following the header record, each of the subsequent data records contains ‘duration’ seconds of ‘ns’ signals, with each signal being represented by the specified (in the header) number of samples. To reduce data size and adapt to commonly used software for
acquisition, processing and graphical display of polygraphic signals, each sample value is represented as a 2-byte integer in 2’s complement format.

Gains, electrode montages, and filters should remain fixed during the recording. Of course, these may all be digitally modified during the replay of the digitized recording.

Figure 1. A detailed digital format of the header record (upper block, ASCII’s only) and of each subsequent data record (lower block, integers only). Note that each one of the ns signals is characterized separately in the header.
Figure 2. Header record of a 24 h recording of EEG and body temperature sampled at 500 Hz and 0.1 Hz, respectively. Note that the offsets of EEG and body temperature are 35 uV and 37.3°C, while the gains are 4.31/uV and 706.2/°C, respectively. In this example, each 30 sec data record contains 15,000 samples of the EEG followed by three samples of the body temperature signal.


EDFbrowser is a free, open-source, multiplatform, universal viewer and toolbox intended for, but not limited to, time series storage files like EEG, EMG, ECG, BioImpedance, etc. EDF files are imported, and montages can be constructed from the individual signals with a high level of customization.



  • Easy to install, just one executable, no special requirements. So, no Octave or Matlab is needed to run the platform.
  • EDFbrowser is one of the fastest, if not, the fastest EDF viewer available.
  • Supported file formats: EDF, EDF+, BDF, BDF+.
  • Different file format conversions.
  • Reads from a streaming file.

More information

You can find more information about the EDFbrowser here:

  • The EDFbrowser online manual- link.
  • The EDF format description – link.
  • The BDF+ format description – link.
  • The EDF+ website – link.
  • The EDF group where you can ask questions about EDF/EDF+ – link.
  • Some EDF files for testing purposes with screenshots – link.
  • A description of the file format used by EDFbrowser for store montages – link.

ASCII to EDF/BDF format converter

This tool converts an ASCII-file (“.csv” or .”txt” file) to EDF or BDF. The following rules apply (you can find them in the EDFbrowser manual page):

  • The data in the ASCII-file must be presented in their physical dimension (i.e. uV, bpm, mmHg, etc.).
  • The data in the ASCII-file must be organized in columns and rows.
  • A row must contain values from different signals/channels acquired the same sample time.
  • A column must represent a continuous sampled signal/channel.
  • All signals/channels must have the same sample frequency.
  • The time interval between two consecutive samples of the same signal/channel must have a stable value (fixed sample rate).


STEP 1: Download EDFBrowser.

You can either download the latest version of EDFBrowser from their website or GitHub. Check on the EDFBrowser website for more information about how to download the platform accordingly to your Operation System (OS).

STEP 2. Get your file ready.

The idea is to open the OpenBCI file in MATLAB, extract the relevant information with EEG data, filter the data, and save it as a “.txt” or “.csv” file. Therefore, I created a MATLAB script that does this automatically. You can download the script here. Besides, you can follow the instructions step by step in “Loading OpenBCI datasets in EEGLAB” post.

1.5 - eegdata
Figure 3. EEG data saved from my MATLAB script. It should look like this. The channel information is stored in columns (not rows).

STEP 3. Upload the ASCII file.

Once we the files are ready to be uploaded to the EDFBrowser, we open the platform and select “Tools > Convert ASCII to EDF/BDF“.

Figure 4. Open EDFBrowser and select Tools > Convert ASCII to EDF/BDF.

A window (Figure 5) will pop-up, and you will have to enter the following parameters:

  • The character that separates the different columns (i.e. “tab”, “,”(comma), “;”(semicolon), ” “(space), etc.).
  • The number of columns.
  • The line at which the data starts. Some ASCII-files contain headers, so use this entry to tell the converter to skip n-lines before interpreting the data.
  • Sample frequency.
  • Subject (the name of the subject).
  • Recording (a description about the type of recording/acquisition).
  • Start date and time of the recording/acquisition.
  • Signals: For every column in the ASCII-file, there is a row in the signals table. Every row has a checkbox and four input fields:
    • Label (name of the signal/channel i.e. FP1, SaO2, Heartrate, etc.)
    • Physical maximum (the maximum physical value that can occur, i.e. the maximum input level of the acquisition equipment. A standard value in EEG applications is 3000 uV). The physical minimum will be equal to the physical maximum. For example, if you enter 3000, the range will be from +3000 to -3000.
    • Physical dimension (i.e. uV, %, mmHg, bpm).
    • The multiplier is normally 1.0. Some programs exports their ASCII-data expressed in Volts while the signal is in the microVolt range. By changing the multiplier, you can add gain to the signal before converting. For example, if the ASCII-data is expressed in Volts and the signal is in the microVolt range (EEG), set the physical maximum to 3000, set the physical dimension to “uV” and set the multiplier to 1000000.

Note: It is important to enter the right value in the “physical maximum” field. If you to choose this value too small, the top of the signal will be cut off. If you choose this value too big, small values of the signal will not be visible, and the signal will look coarse. The ideal value for the “physical maximum” is just above (or equal to) the maximum value that can occur, i.e. the maximum possible output of the sensor or ADC, either positive or negative.
Therefore, it’s better to set the checkbox “Auto detect physical maximum”. That way you don’t need to enter the values in the column “Physical maximum”.

Note 2: The maximum physical value that the converter can handle, is limited to 9999999. Values above will be clipped to 9999999 and values below -9999999 will be clipped at -9999999. If you expect higher values in your ASCII-file, use the multiplier. For example,
set the multiplier to 0.1, 0.01 or 0.001, etc.

Note 3: If you think that, later, you want to make derivations (for example P4 – C4 in EEG applications), make sure that the signals have the same value in the maximum physical field. Also, do not set the checkbox “Auto detect physical maximum”.

Figure 5. ASCII to EDF/BDF converter menu.

It is possible to exclude columns, by unchecking the corresponding row in the signals table, this can be useful when a column contains a time/date stamp or when you don’t want to include a particular signal in the EDF/BDF-file.

  • Click on the “save button” to save the entered parameters in a template.
  • Click on the “load button” to load parameters from a template.
  • Click on the “start button” to start the conversion.

If you select “Start” it will ask you to choose the file that you want to convert. Afterward, you will have to type the name of the EDF file and navigate to the directory where you want to save the file. A message such as the one below will pop if the conversion was successfully done and the EDF file is ready to be used. Congratulations!

Figure 6. Message from the EDFBrowser.

STEP 4: Use the EDF file.

For this step, we used the EEG data filtered from my MATLAB script instead of using the non-filtered data. However, you can import the raw data directly and apply filters either with EDFBrowser or EEGLAB afterward.


You can plot the data with the EDFBrowser itself. To do so, go to “File > Open” and select the EDF/BDF file that you saved. A window will appear such as the one showed below. If you want to plot the data (Figure 8), select “Add signal(s)“.

Figure 7. Plot EDF files menu.

EDFBrowser has a menu on the very top of the platform. You can change different parameters, such as the signals that you want to plot, the time scale, the amplitude, you can also filter the data, and playback the EDF file in different velocities.

Figure 8. EEG data plotted in EDFBroswer.


EEGLAB (MATLAB Toolbox) accepts the EDF/BDF format from EDFBrowser. To import the data you must select “File > Import Data > Using EEGLAB functions and plugins > From EDF/EDF+/GDF files (BIOSIG toolbox)“.

Figure 9. EEGLAB menu to import data.

If you want to visualize the data, you can do it by selecting “Plot > Plot Signal“. Likewise, you can change different parameters in the Settings tab.

Figure 10. EEG data plotted in EEGLAB.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s