Skip to content

EEG_2: Feature Extraction

Nikhil Anand edited this page Aug 11, 2023 · 2 revisions

Two separate feature extractions were carried out - one directly from the dataset files on MATLAB and the other from functional connectivity matrices extracted from the EEG data. Both of these have been outlined below.

Functional Connectivity Graph Features (Python)

  1. Various graph features were extracted from the functional connectivity matrices, ie, Degree Centrality, Betweenness Centrality and Eigenvector centrality.

  2. This was done for graphs made from 17 different 31 x 31 connectivity matrices, corresponding to the 17 bands, where 31 is the number of channels.

  3. To access the notebook (with a step-by-step explanation), go to the filepath 'codes/fconn_feature_extract.ipynb'.

Amplitude and Spectral Domain Features (MATLAB)

Various features were extracted from the data, such as amplitude domain features and spectral domain features. Before this, the preprocessed data is divided into epochs.

  1. To access the epoching code, go to the filepath 'codes/divide_epochs.m'.

  2. Here, the data is divided into 10 epochs with a 50% overlap, each 60s in length.

  3. To access the code, go to the filepath 'codes/extract_features.m'.

  4. The code contains all the feature extractions combined into a single set of code.

  5. First, epoched data is imported. Then, the data is divided into 5 frequency bands (alpha, beta, gamma, theta and delta).

% deltaBand = [0.5, 4];
% thetaBand = [4, 8];
% alphaBand = [8, 14];
% betaBand = [14, 30];
% gammaBand = [30, Inf];
  1. Next, the envelope is computed using the Hilbert transform, and amplitude features such as mean, median, mode, standard deviation, kurtosis and skewness are computed.

  2. Next, the Power Spectral Density (PSD) is computed, and attributes totalPower, meanPower and edgeFreq are computed.

totalPower = sum(psd);
meanPower = totalPower/(top-arr(b)); % arr(b+1) - arr(b) is the frequency range
totalPower = mean(totalPower);
meanPower = mean(meanPower);
            
cumulativePower = cumsum(psd);
edgeFreqIdx = find(cumulativePower >= 0.95*totalPower, 1);
edgeFreq = (edgeFreqIdx - 1)*(top-arr(b))/500;
  1. Finally, relative powers of various combinations of bands are computed into a separate tensor, such as theta/alpha, beta/alpha and so on.
relPowFeatures(ch, 1) = thetaPower / alphaPower;
relPowFeatures(ch, 2) = betaPower / alphaPower;
relPowFeatures(ch, 3) = (thetaPower + alphaPower) / betaPower;
relPowFeatures(ch, 4) = thetaPower / betaPower;
relPowFeatures(ch, 5) = (thetaPower + alphaPower) / (alphaPower + betaPower);
relPowFeatures(ch, 6) = gammaPower / deltaPower;
relPowFeatures(ch, 7) = (gammaPower + betaPower) / (deltaPower + alphaPower);
  1. All features are exported into the relevant folders (amp, psd, relPow).

  2. The feature extraction was run on the first 152 subjects as well. This can be accessed on the lab server, in the path '/space_lin2/nikhil/exports'.

Clone this wiki locally