Open Ephys data format (version 0.4)

Headers

All headers are 1024 bytes long, and are written as a MATLAB-compatible string. Therefore, loading the header (regardless of its content), can be done with three lines of code:

  hdr = fread(fid, 1024, 'char*1');
eval(char(hdr'));
info.header = header;



This is actually pretty handy, since any changes to the header format (which will probably happen often) won't affect the code for reading data files. However, note that reading files using this method also creates a security risk if there is any doubt as to the origin of the file, since reading the header involves executing a portion of the file as MATLAB code. Therefore, be careful if you are working with files in one of these formats that you did not create yourself.

The current header format uses ASCII encoding, and defines MATLAB struct with the following fields and values:

For those not using MATLAB, each header entry is on a separate line with the following format:

Continuous data files (.continuous)

Each continuous channel within each processor has its own file, titled "XXX_CHY.continuous", where XXX = the processor ID #, and Y = the channel number. For each record, it saves:

This makes up a record of 2070 bytes (= 8 + 2 + 2 + 2048 + 10).

If a file is opened or closed in the middle of a record, the leading or trailing samples are set to zero.

 Event files (.events)

Non-spike events are saved in a different format. Events generated by all channels are dumped into the file "all_channels.events" with the following data for each event:

Spike files (.spikes)

Data from each electrode is saved in a separate file. The filename is based on the name of the electrode itself, but without spaces (e.g., "Tetrode1.spikes").

Each record contains an individual spike event (saved for one or more channels), and is written in the following format, defined in SpikeObject::packSpike():

Since the samples are saved as unsigned integers, converting them to microvolts involves subtracting
32768, dividing by the gain, and multiplying by 1000.

Reading data into MATLAB

Here's some example code for loading the first record from a data file called `102_CH1.continuous`:

fid = fopen('102_CH1.continuous');
hdr = fread(fid, 1024, 'char*1');
timestamp = fread(fid, 1, 'int64',0,'l');
N = fread(fid, 1, 'uint16',0,'l');
recordingNumber = fread(fid, 1, 'uint16', 0, 'l');
samples = fread(fid, N, 'int16',0,'b');
recordmarker = fread(fid, 10, 'char*1');
fclose(fid);
figure; plot(samples);


See the analysis-tools repository for additional MATLAB and Python code.