Working with animal electrophysiology data
The algorithms implemented in FieldTrip can also be used on data from animal electrophysiology experiments, such as local field potentials (LFPs) and spikes. The way that data from animal electrophysiology data acquisition systems in handled in FieldTrip is slightly different from that of EEG and MEG data. Furthermore, there are a few functions that are specific to animal electrophysiology data.
If you are only processing LFPs and no spikes, then the remainder of this page is not relevant for you. LFPs are processed in exactly the same way as EEG and MEG data, and the other tutorials should help you to get started. However, if you are analyzing spikes, or a combination of spikes with LFPs, then you should read on.
Representation of a data set
FieldTrip is mainly developed for the analysis of continuous electrophysiological data, such as EEG, MEG, ECoG, and local field potentials (LFPs) recorded in the neuropil. These data can all be considered as a continuous multivariate time series, which is sampled at discrete time points at regular intervals.
Many animal neurophysiology experiments also allow the recording of spiking activity of small groups of neurons. Spiking activity is fully characterized by the set of time points at which the spikes occur. These data are inherently discrete and represents events (spikes) that happen at irregular moments in time. The inherently discrete and irregular nature of spiking activity requires a some effort to combine it with the simultaneously recorded LFPs.
Another difference between human electrophysiology data and animal electrophysiology data is the representation of that data on disk. Whereas human EEG or MEG data is typically stored in a single (large) file, the data from a single animal recording session are sometimes stored in a large number of separate files with different file formats. For example,
- The signal recorded at different sites (e.g., single wire electrodes, tetrodes, subdural grid electrodes) is often saved into separate files, one per recording site.
- Different aspects of the signal recorded at one site (e.g., spiking activity and local field potential) are often saved into separate files.
- The stimulus and event information is often stored in a separate file.
Reading data into FieldTrip usually requires that all these files can be accessed. It is good practice to keep all these files in a single directory and also to keep this directory clean (that is, to save the output of the analyses to another directory). With this practice, the directory name can be used as an argument for FieldTrip functions like ft_read_header, that operate at the level of the complete data set (instead of separate files).
Synchronizing with timestamps
Besides reading the data from the different files into memory, a challenging aspect of the analysis of combined spike and LFP data is synchronization. LFP data are typically sampled at a frequency of approximately 1 KHz. In contrast, spike data are typically obtained by thresholding data that is recorded at a much higher sampling frequency (typically 30-40 kHz). Thus, the samples at which spikes are obtained do not correspond to the samples at which the LFP data are obtained. In FieldTrip, as in all other animal electrophysiology software, the synchronizing link between spike and LFP data are the so-called timestamps. Timestamps are generated by the recording system and vary in the clock which generates them: the Neuralynx system has timestamps at 1 MHz, whereas the Plexon system has timestamps at 40KHz.
The accurate specification of the time (by means of the timestamp) at which the LFP samples were acquired and at which the spikes were acquired allows the data to be synchronized and merged. Every spike and every LFP sample has an associated timestamp and this forms the time axis, via which both of types of data can be synchronized.
An essential part in every analysis is trial selection. Typically, the interest is in segments of data that precede, follow, or include certain stimulus or response events. This event information (Which event occurred when?) is usually stored in a separate file. In FieldTrip, the event information is obtained by calling the function ft_read_event, which produces a so-called event structure. The timing information in this event structure involves timestamps, and therefore the events can be linked to the LFP and the spike data.
Trial selection operates in three steps. In the first step, trials of LFP data are selected. In the second step, spike data are read into memory, And in the third step, spike data are appended to the selected trials of LFP data. These three steps are now described in some detail.
- Trials of LFP data are selected in essentially the same way as trials of human EEG and MEG data. In a user-written trial function, a so-called trl-structure has to be constructed which specifies the timestamps that correspond to the beginning and the end of the trials. The trials of LFP data are then extracted from the data on disk.
- Reading spike data into memory is performed by the function ft_read_spike. This function takes the spike filename as an argument. In the function’s output, spikes are identified by their timestamps. This function must be applied to every file that contains spike data. Once loaded into memory, multiple spike data sets can be appended by means of the function ft_appendspike.
- Appending spike data to LFP data is also performed by the function ft_appendspike. An important point here is that, in the output, the spikes are no longer identified by their timestamps. Instead, spike channels are now stored as time series of zeros and ones with the same sampling frequency as the LFP channels. This format allows for joint analyses of spike and LFP data, such as spike-field coherence analyses and spike-triggered averages.