Skip to content

Function that uses EEGlab functions and structures to transform 160channel data into 64 channel data and the other way around

License

Notifications You must be signed in to change notification settings

DouweHorsthuis/Interpolating-channels-between-different-cap-sizes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Transforming data and structures between 160 channel cap and 64 channels

This project is a function that transforms data between 160 channel data sets and 64 channel data sets. There are 2 ways of doing this, one is via interpolation and one is via keeping channels that have the same approximate distance the the new channels. The whole function is build so that it works within the EEGlab structure.

Table of Contents

  1. About the project
  2. Getting started
  3. Usage
  4. Testing the function
  5. Future steps
  6. License
  7. Contact
  8. Acknowledgement

About The Project

transform_channels() - transform x amount of channel data into different amount of channels using the interpolation function of EEGlab or keeping the channels that are closest to the original channels. By comparing the location on both caps.

Usage: EEGOUT = transform_channels(EEG,chanlocs_new,n_new_chan,methode);

Inputs: EEG - EEGLAB data set
chanlocs_new - chanlocs structure with amount of channels
desired for EEG to be transformed to.
n_new_chan - 64 or 160, this will decide what channels to keep
Methods:
Interpolate - This will interpolate all the channels from one configuration to the next Keep - This will keep all the original channels that are as close as possible to the equivalent channel of the new configuration. Output:
EEGOUT - data set with the new amount of channels

Example:
EEG = transform_n_channels(EEG,EEG2.chanlocs,64,Keep);

Extra:
To get the EEG2.chanlocs with the new amount of channels,simply load an .set file with those amount of channels making sure that the channel info has been inputted

Author: Douwe Horsthuis, CNL Albert Einstein College of Medicine, 2021 douwehorsthuis@gmail.com

This function relies several EEGLAB functions.

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

Software: You need to have a copy of EEGlab (these scripts works for version eeglab2019_1)

Usage

You can use the data and example in the testing folder.

In short, you use the normal EEGlab function to load your data for "EEG". EEG2 is a data set (or only the chanlocs of a data set with the other amount of channels) Then you use the function EEG = transform_n_channels(ORGEEG, newchan,n_new_chan, landmark)

 EEG = pop_loadset('filename', '64.set', 'filepath', data_path);%loading participant file with 160 channels
 EEG2 = pop_loadset('filename', '160.set', 'filepath', data_path);%loading participant file with 64 channels
 EEG = transform_n_channels(EEG,EEG2.chanlocs,160, 'landmark');

Caps

Important to note is that this function is made to be used one Bio-semi caps. For now it uses the locations of a 64channels cap with a 10-20 system layout and a 160 channel cap with a ABC layout. For more info on these differences see the biosemi website

Two different methods

The function uses two different methods. Either it interpolates all the channels or it keeps the channel that are the as close as possible between the original and the new data and adds/takes the remaining channels depending on if you go from 160-->64 or 64-->160. Interpolate method This method makes sure that the new data has the same channel locations as other 64 channel data. Because the 160 channel cap does not follow the 10-20 layout rule none of the channels are kept. Instead it uses the original data to interpolate as many channels as the new data set needs to have. It uses the different channel locations in the EEG.chanloc structure to figure this out. Pros:

  1. if you don't have all the channels (you deleted a bad channel) this will still work.
  2. your new data channels will have the exact same coordinates as the rest of your data. Cons:
  3. all the data is interpolated. This might be something that for example ICA does not deal well with.

Keep method
This method makes sure that the original data is not interpolated, instead it only uses interpolation if needed to create extra channels when you go from 64-->160. It keeps the channel locations of the original data, which will be slightly different but it doesn't touch the EEG data, so this is still the same.

  1. As many channels as possible are not altered. This means that the data should be perfect for ICA for example. Cons:
  2. Since not all of the channels have an channel on the other layout with the exact same coordinates, the data less good spacial.
  3. if your original data is missing channels, it might be a problem to use this.Because you would need to interpolate the data before to get these channels.

From 160 to 64 VS. from 64 to 160

You can use the function in both directions, one thing to keep in mind is that creating 64 channels out of 160 is using a lot of data to create less new channels, whereas the opposite is true when you go from 64 to 160. Always test the data still looks the way it should. When looking at topoplots it shows what happens. See Scalpmaps below for plots with real data.

EEGlab structures

This function works within EEGlab, and only works on things inside the EEG structure. The main part of the script deals with the name and location of the channels, this would be in EEG.chanlocs.
When it's done it also moves around the data in EEG.data. This is because for a 160ch setup, A1 is the first channel (meaning urchan = 1) whereas for a 64 channel setup FP1. The equivalent channel to A1 is Cz, this channel is the 48th channel.

Testing the function

ERPs

I have tested plotting ERPs but they are somewhat misleading. When looking at the ERPs using the 'keep' method they are identical to the original data. This makes sense because they are identical. Whereas the 'interpolate' method changes the ERP a little. Because of this there are no ERPs here. But you can see them here

Scalpmaps

These are scalpmaps based on the data of 78 people that started with 160 channel cap and 28 people that started with at 64 channel cap.

Channel number transformation Original Data interpolate methode keep methode
64 to 160
160 to 64

Or as can seen below in still figures at 100ms and 350ms into after the onset of a stimulus.

IN the first case we interpolate from 64 to 160 channels.

Original Data interpolate methode keep methode

IN the second case we interpolate from 160 to 64 channels.

Original Data interpolate methode keep methode

Future steps

Ideally we want to test this funtion on a group of datasets to see if there is an issue and if it changes the data in a significant way.

Please let me know if you have any suggestion on how to make this function better or if you want to help and update the function to include more cap sizes

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Douwe Horsthuis - @douwejhorsthuis - douwehorsthuis@gmail.com

Project Link: https://github.com/DouweHorsthuis/Interpolating-channels-between-different-cap-sizes/

Acknowledgements

About

Function that uses EEGlab functions and structures to transform 160channel data into 64 channel data and the other way around

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages