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.
At my recent workshop, several people asked about pre-processing of data in R, and I told them it wasn’t really possible at the moment. What I might have been less clear about is that it is not that is not possible, but that there isn’t really the wide range of pre-programmed tools as in Python and Matlab. So it’s just not practical to do it all in R as it stands.
Occassionally I do something other than playing with EEG data. R can also handle a lot of spatial data - in other words, you can create nice maps. There’s the small matter of an election coming up next month which is probably our last chance of avoiding a disastrous Brexit.
I decided to try out some of R’s mapping functions and packages to see if I could come up with any useful graphics of the sort you usually see: maps showing turn-out, who won each constituency, things like that.