Intertrial coherence (ITC) is a measure of how consistent oscillatory phase is across an ensemble of trials.
In the schematic below, we have a sine wave of an arbitrary frequency.
The amplitude of the wave is the distance between 0 and the wave at a given timepoint. So here, you can see it has a maximum of 1, indicated by the arrow. A complete cycle of of the wave is the amplitude peaking, declining to a trough, then hitting zero again.
Two years ago I wrote a post demonstrating Python pre-processing of EEG data using Python chunks in an RMarkdown document. This worked great. But something I mentioned then was that there was a package called reticulate that would allow more direct interfacing with Python in R. That package has been under a lot of development since then, as has RStudio. Plots produced in Python chunks can now be embedded in RMarkdown.
In the last post, I showed how you can get the EEG data from EEGLAB .set files saved as Matlab v7.3 files, but that there are some limitations on what else you can get from them beyond the data itself. Specifically, you can’t extract channel locations, and there are no labels to tell you which channels the data is from. This is due a limitation of the available tools for reading HDF5 files, which is the actual format of Matlab v7.
Like a lot of people, I’ve been using EEGLAB and Fieldtrip for years and have a lot of data already processed using those packages. It can be a bit annoying getting the data from them - in the past I’ve converted the data to text/csv files, which is ok as far as it goes. It’s a bit of a faff getting them in the right format, and EEGLAB’s in-built export function drops useful info like epoch numbers and event codes etc.
As mentioned in my last post, I’ve been working on a package for EEG analysis in R called eegUtils. I’d mostly been focusing on relatively simple visualization tools: topographical plots - ERP Visualization: Creating topographical scalp maps: part 1. But one thing was really bugging me - how the data gets into R in the first place.
Sure, it’s nice pre-processing data in other packages - EEGLAB or MNE-Python - and then transferring the processed data across to R.
A few months ago I wrote a post about how there isn’t really a killer EEG analysis package for R, and that many of the things you typically want to do are not really implemented yet. So I’ve started to implement several functions myself and incorporate them into my own package, currently called eegUtils. I’ll maybe come up with a catchier name at some point before I get to the stage of trying to get it on CRAN.
In the last post I loaded in some data from a BDF file and showed how to re-reference and high-pass filter it.
Normally when running an EEG data we’ll have periods of interest that we want to extract from the recording, typically using triggers sent via a parallel cable or similar.
Trigger events A Biosemi system can record up to 16 trigger inputs, representing the resulting numbers as 16-bit (i.