Beauchamp:TensorECOG
Template:PAGE UNDER CONSTRUCTION
Regularized Higher-Order Partial Least Squares Analysis for ECoG Data
By Frederick Campbell and Kelly Geyer, June 2017
Introduction
This page contains documentation of our MATLAB package for the tensor factorization algorithm Regularized Higher-Order Partial Least Squares (RHOPLS). This algorithm is specifically designed for electrocorticography (ECoG) data, with dimensions consisting of electrodes, epoch time, and frequency.
Current capabilities:
- Data pre-processing: multiple methods for scaling data and removing outlier trails
Upcoming capabilities:
- RHOPLS algorithm implementation
- Visualization of final factorization results, along with capabilities to view data during processing. Potential functionality for SUMA visualization
Requirements
Required Software:
- R
- MATLAB Tensor Toolbox Version 2.6
Before using this package, a user should configure the file rhopls_setup.m so that it can install Tensor Toolbox and set up environment variables for the current Matlab session. This function should be called before using any of the package functions. It only requires editing the first two variables:
tensor_toolbox_dir = './tensor_toolbox';
usr_local_bin = '/usr/local/bin';
Install packages with the commands. These commands are very useful to include at the beginning of any script that uses the rhopls package.
% Install RHOPLS package
cd(rhopls_dir);
addpath(pwd);
savepath;
% Install required toolboxes
rhopls_setup();
Things to note:
- This function assumes that the files '<patient ID>_trial_labels.mat', '<patient ID>_TFR_ao.mat', and '<patient ID>_TFR_ao_LowFreq.mat' exist in a directory named <patient ID>
Processing ECoG Data for Analysis
The RHOPLS package provides several methods of data standardization and outlier trial removal. The function load_patient_data
implements these in a user-friendly wrapper. Ultimately it creates the design matrix for a single patient, which is actually a 4-dimensional tensor with dimensions (trials x electrode x freq x time). This function not only returns the design tensor, trail labels and metadata, but saves them to the original data folder.
Data standardization methods:
flatten_trials
: This function flattens the ECoG tensor by trial, or first dimension, and then centers and scales data according by user optionsarray_normal
: This function centers and scales data using the array normal method, according by user options. The array normal distribution is a higher-order generalization of the multivariate normal distribution. We estimate a mean and covariance assuming the tensor was generated via the array normal distribution and use the estimated parameters to center and scale the tensor.
In following example, we mean center and scale the flattened tensor to standardize it. Additionally, outlier are removed. Users can also choose to set either center and scale to false.
%% Load and process ECoG data
% Import and create a design tensor for patient k
std_method = 'flatten_trials';
center = true;
scaled = true;
rm_outliers = true;
[X, trial_labels, metadata] = load_patient_data(patient_dir, ...
'standardizationMethod', std_method, ...
'center', center, ...
'scaled', scaled, ...
'removeOutliers', rm_outliers);
ECoG RHOPLS
parameter tuning, fit model
Results
do analysis here, show plots
References
- Frederick Campbell, "Interpretable Brain Decoding for Electrocorticography Data though Regularized High Order Partial Least Squares." Publication in progress.
- Brett W. Bader, Tamara G. Kolda and others. MATLAB Tensor Toolbox Version 2.6, Available online, February 2015. URL: http://www.sandia.gov/~tgkolda/TensorToolbox/.