Progress portal

P r o g r e s s

Miscellaneous scripts

Python Script to parse Xsens MVN XML Data

Steps for removing eye-blink artefacts from EEG data using ICA

Here are the steps we followed to preprocess EEG data, run ICA and prune the data of eye-blink artefacts. These steps are of course not the only hard and fast way to follow, but rather the ones that actually worked well for us, and for which scripts are available (see below). There would necessarily have to be variations in each step depending upon your data (format, sampling frequency, desired filter name it). Accordingly, the scripts would need minor to major adaptations as necessary, but the hope is that they serve as a template to work with and adapt rather than having to start with a blank slate. We thank Alessandro Tavano for his valuable support and advice about ICA, and Katrin Cunitz for sharing some of her insights about the analysis pipeline she employed for children data.

  1. Import data, edit triggers etc., filter it, re-reference it, all in EEGLab.
  2. Remove bad channels (automatically) and throw away any other channels that were just too noisy, again in EEGLab. Let us call this data Pre-ICA_BC data.
  3. Remove out-of-the-ordinary artefacts, electrode black-outs etc. MANUALLY. But leave the good-looking eye blink artefacts in the data as is. And run ICA. Let us call the resulting dataset the ICAed data. (This step was what was very time-consuming for us, because we tried to use the automatic rejection options in EEGLab. Everytime we tried something new, ran the whole ICA, the ICA components were judged by a trained eye to be 'not good!'.)
  4. Decide to throw away bad ICA components...pretty arbitrary to the untrained eye, and very subjective in our opinion! Solution: use SASICA (which works as a plugin for EEGLab) that will select what it thinks as bad components from the ICA automatically, and one could decide on a case-by-case basis to accept that or not! What we ended up doing was the following: initially, we went through each participant one by one to make this decision, say for 5 to 10 participants. Once convinced that SASICA's decisions are way more reliable than our own, we just trusted SASICA's decisions as god-given...and decided to reject the components suggested by SASICA without further appeal.
  5. Now, and here is the important thing: we didn't run SASICA on the ICAed data, but instead copied the ICA weights etc. from the ICAed data to the Pre-ICA_BC data (which is the full, unrejected data, just with bad channels removed in step 2). And then we ran SASICA on the Pre-ICA data. This resulted in the PRUNED data, meaning the bad ICA components identified by SASICA removed from the Pre-ICA data.
  6. We could now interpolate the missing/rejected channels in the Pruned data and export it as an EEP cnt file using the eepio plugin.
  7. On the exported EEP data, we could use the usual reject.cfg step, just to reject any big noise that still remained in the data.
  8. On this data, we could then do the averaging etc. as usual in the EEProbe analysis pipeline.

In step 5 above, we could either choose to run SASICA based on eye electrodes alone (the best option for most normally-noisy but not too-noisy data, such as adult EEG data), or additionally use the ADJUST plugin option as well (for data that is way too noisy, such as children data). We didn't have eye electrodes, and the data was very noisy to say the least. So we used ADJUST.

Get the SASICA (SemiAutomatic Selection of Independent Components for Artifact correction in the EEG) plugin here. It comes included with ADJUST and other plugins it uses, and a PDF copy of the related JNM paper (well worth a read to understand things much better).

MATLAB Scripts for EEG Data Analysis using EEGLab

  • From the preprocessed data, reject bad channels (automatically, to get ICA_BC dataset) and do pre-ICA clean up (manually!)
  • On the pre-ICA cleaned up data, run ICA (binica), based on which prune bad components using SASICA from the ICA_BC dataset (see above) to get PRUNED_DATA

Exporting Biopac Digital Input Channels to Triggers


Any and all scripts available on these pages or snippets thereof can be freely copied, reused, redistributed and modified, provided it is exclusively for non-commercial scientific research purposes. Unless otherwise explicitly mentioned in the header block, none of the scripts or snippets provided on these pages involve copyrighted material from or intellectual property of other unacknowledged sources.

Presentation is a registered trademark, owned by Neurobehavioral Systems, Inc., CA, USA.

Whilst the scripts and code snippets provided here are intended to be useful in the broader pursuit of science, they are provided 'as is', with no warranty of any sort, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the author(s) or the Institute be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the scripts provided on these pages or the use or other dealings in the scripts. Comments, criticisms and suggestions for improvements are always welcome. Please get in touch with Dr. R. Muralikrishnan in this regard. Copyleft (ↄ) R. Muralikrishnan (only for the scripts and code snippets on these pages).