File Sources#

File Sources stream pre-recorded continuous data and events into the File Reader.#

Type

Plugin::Type::FILE_SOURCE

Base Class

FileSource

Template

open-ephys-plugins/file-source-template

A File Source plugin allows the GUI’s File Reader to stream data from a new type of data format. By default, the File Reader can load data stored in the GUI’s Binary Format. File Source plugins for the Open Ephys Format and NWB Format can be installed via the Plugin Installer.

A data format may contain data for multiple recordings and/or data streams, but the File Reader can only read one of these at a time. Each “Record” within a File Source represents one recording (a block of contiguous samples) from one data stream (a block of channels that are sampled synchronously). When a new file is loaded, the File Source must provide information about all of the Records that are available, and then the user can select which one to read at any given time. To read in data from multiple recordings or data streams simultaneously, multiple File Readers can be connected via a Merger.

To create a new File Source, start with the File Source Template and add code that implements the following methods:

bool open(File file)#

When this method is called, the File Source should attempt to open the file selected by the user, and return true if successful. If the file is not valid or cannot be read for any reason, this method should return false. For formats that distribute data across multiple files, this file should contain configuration information that can be used to access all of the additional files. For example, in the Binary Format, this is a JSON file with an .oebin extension.

Parameters:

file – A Juce File object representing the input file. The plugin can call File::getFullPathName() to return a string containing the complete path to this file.

void fillRecordInfo()#

Instructs the File Source to fill the infoArray and eventInfoArray objects with the relevant information for all recordings (“Records”).

void updateActiveRecord(int index)#

Informs the File Source that a new Record has been selected by the user.

Parameters:

index – The index of the selected Record within the infoArray object.

void seekTo(int64 sample)#

Informs the File Source about the next sample index that should be read from the active Record.

Parameters:

sample – The 0-based sample index to seek to.

void readData(int16 *buffer, int nSamples)#

Reads data from the active Record into a temporary integer buffer.

Parameters:
  • buffer – A buffer of 16-bit integers that will hold the incoming data.

  • nSamples – The total number of samples to read.

void processChannelData(int16 *inputBuffer, float *outputBuffer, int channel, int64 nSamples)#

Converts data from integers to floats so it can be processed by downstream plugins.

Parameters:
  • inputBuffer – A temporary buffer of unscaled 16-bit integers.

  • outputBuffer – A buffer of floats containing data in real-world values (usually microvolts).

  • channel – The index of the channel to convert.

  • nSamples – The total number of samples to convert.

void processEventData(EventInfo &info, int64 startSampleNumber, int64 stopSampleNumber)#

Adds info about the events that occurred within a given range of samples.

Parameters:
  • info – The EventInfo object to be updated.

  • startSampleNumber – The minimum sample at which the incoming events can occur.

  • stopSampleNumber – The maximum sample at which the incoming events can occur.