Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Open Ephys data format (version 0.4)

...

All headers are 1024 bytes long, and are written as a MatlabMATLAB-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 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 defines MATLAB struct with the following fields and values:

  • format = 'Open Ephys Data Format'
  • version = 0.4
  • header_bytes = 1024
  • description = '(String describing the header)'
  • date_created = 'dd-Mmm-yyyy hhmmss'
  • channel = '(String with channel name)'
  • channelType = '(String describing the channel type)'
  • sampleRate = (integer sampling rate)
  • blockLength = 1024
  • bufferSize = 1024
  • bitVolts = (floating point value of volts/bit)

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

...

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:

...

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:

...

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`102_CH1.continuous`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 MATLAB and Python code.