Skip to content

Frequency Contribution Analysis

David López-García edited this page Oct 16, 2021 · 11 revisions

Overview

The contribution of different frequency bands to the overall decoding performance can be assessed in MVPAlab through an exploratory sliding filter approach. To this end, the original EEG signal can be pre-filtered using a band stop sliding FIR filter. Therefore, different frequency bands can be filtered-out of the original EEG data, producing new filtered versions of the original dataset.

The classic time-resolved multivariate analysis is now computed for each filtered-out version of the data. The importance of each filtered-out band is quantified computing the difference maps in decoding performance between the filtered and the original decoding results.

Accordingly, if the classification performance at any given point is higher for the original signal compared to the filtered-out version, then the removed frequency band contains relevant information used by the classification algorithms to discriminate between conditions. This procedure is illustrated in the following figure:



mvpalab-sf Figure 1. Sliding filter analysis diagram. This analysis compares in a time-resolved way the classification performance between the original dataset and a filtered-out version in which a certain frequency band has been removed. This procedure is repeated for each frequency band (step) returning a classification performance difference map which indicates how each frequency band contributes to the classification performance.



By definition, this analysis can be computed in a time-resolved manner (without temporal generalization) and using only the mean accuracy or the AUC as performance metric.

Configuration

Several parameters should be defined in the MVPAlab con-figuration structure to compute the sliding filter procedure:

cfg.sf.flag   = true;
cfg.sf.metric =auc’;
cfg.sf.lfreq  = 0;
cfg.sf.hfreq  = 40;

cfg.sf.fspac  = 'log';
cfg.sf.nfreq  = 40;
  • Sliding filter analysis can be enabled or disabled setting the configuration variable (.flag) to true or false.
  • The (.lfreq) and (.hfreq) variables define the frequency limits in which the analysis will be computed.
  • As mentioned before, mean accuracy (.metric = 'acc') or AUC (.metric = ‘auc’) can be selected as performance metrics for this analysis.
  • The number of individual frequency bands that will be removed from the original dataset (frequency resolution) is defined by (.nfreq).

Each of these frequency bands can be linear (.fspac = 'lin') or logarithmically (.fspac = 'log') spaced as shown in the following figure:


mvpalab-filters Figure 2. Removed frequencies: magnitude response for both linear and logarithmically spaced band-stop sliding filters. 60 frequency bands, 1408 filter order, Blackman window, 2Hz overlapped bandwidth.


On the one hand, if the frequency bands are linearly spaced, the frequency resolution is equally distributed across the entire spectrum. On the other hand, a higher frequency resolution is found in the low part of the spectrum if the frequency bands are logarithmically spaced. This is especially interesting for investigations focusing in the study of the lower part of the M/EEG spectrum (α,β and θ frequency bands).

The filter design parameters such as filter type (.ftype), filter bandwidth (.bandwidth), window type (.wtype), filter order (.order), and others, can also be tuned in the configuration file as follows:

cfg.sf.ftype = 'bandstop';
cfg.sf.wtype = 'blackman';
cfg.sf.bw    = 2;
cfg.sf.hbw   = cfg.sf.bw/2;
cfg.sf.order = 1408;

Caution: Digital filters usually affect brain signals and are commonly applied at many stages from the data acquisition to the final publication. Many undesired events including temporal blurring or signal delays may occur, which may lead to incorrect interpretation of the results. Therefore, an appropriate filter design becomes crucial to prevent (or mitigate) these signal distortions.

Please see [1,2] for a deeper understanding of how brain signals can be affected by filtering processes.

Demo scripts

The complete sliding filter analysis pipeline is coded in the following main script::

sfmvpa_demo.m

%% MVPAlab TOOLBOX - (sfmvpa_demo.m)
% -------------------------------------------------------------------------
% Brain, Mind and Behavioral Research Center - University of Granada.
% Contact: [email protected]
% -------------------------------------------------------------------------

clear; clc; 
 
% Initialize project and run configuration file:
cfg = mvpalab_init();
run cfg_file; % cfg_file_advanced for advanced configuration.

% Load data, generate conditions and feature extraction:
cfg = mvpalab_import(cfg);

% Compute sliding filter analysis:
[cfg,diffMap,stats] = mvpalab_sfilter(cfg);

% Save cfg file:
mvpalab_savecfg(cfg);

% Plot the results:
run sf_plot;

Due to the elevated RAM requirements of this analysis, the import function stores each filtered versions of the original dataset in a specific folder of your hard drive for each participant individually. The user should consider using an external hard drive for this high-demand analysis.

Then, as explained before, the function mvpalab_sfilter() computes and compares the decoding performance of different metrics between the original dataset and each filtered version, returning a difference map structure diffMap. The result matrices [freqs x timepoints x subjects] for specific performance metrics can be extracted using dot notation (e.g. diffMap.auc). Only the mean accuracy and the area under the curve are implemented for this analysis.

Additionally, if enabled, this function also implements the statistical permutation analysis, returning the stats variable, which includes the statistically significant clusters.

Here you can find a basic configuration file for the former analysis:

cfg_file.m

%% Basic configuration file for MVPA analysis - Folder and data files:

cfg.analysis = 'MVPA';
cfg.location = pwd;

% Condition indentifiers:
cfg.study.conditionIdentifier{1,1} = 'condition_a';
cfg.study.conditionIdentifier{1,2} = 'condition_b';

% Data paths:
cfg.study.dataPaths{1,1} = 'C:\Users\Cimcyc\Desktop\data\condition_a\';
cfg.study.dataPaths{1,2} = 'C:\Users\Cimcyc\Desktop\data\condition_b\';

% Data files:
cfg.study.dataFiles{1,1} = {'1.mat','2.mat','3.mat'};
cfg.study.dataFiles{1,2} = {'1.mat','2.mat','3.mat'};

% Enable permutation analysis:
cfg.stats.flag = true;

% Sliding filter analysis configuration:
cfg.sf.flag = 1;
cfg.sf.filesLocation = [cfg.location filesep 'filtered_datasets'];
cfg.sf.metric = 'acc'; % (acc = mean ccuracy, auc = are under the curve)

% Frequency limits:
cfg.sf.lfreq = 0;   % Analysis inferior limit (Hz).
cfg.sf.hfreq = 20;  % Analysis superior limit (Hz).

% Filter design:
cfg.sf.ftype = 'bandstop';      % Filter type.
cfg.sf.wtype = 'blackman';      % Window type.
cfg.sf.bw    = 2;               % Filter bandwidth (Hz).
cfg.sf.hbw   = cfg.sf.bw/2;     % Halfband width (Hz).
cfg.sf.order = 2408;            % Filter order.

% Frequency steps:
cfg.sf.fspac = 'log';  % Linear or logarithmic (lin/log.)
cfg.sf.nfreq = 32;     % Number of steps - log (Hz).

And finally, the following script generate a graphic representation of the result:

sf_plot.m

% Initialize and configure plots
graph = mvpalab_plotinit();
graph.xlim = [-100 1000];

% Load results if needed: 
load results/diffMaps/result.mat

% Mean accuracy plot (no statistical significance)
figure;
subplot(1,2,1)
hold on
mvpalab_plotfreqcont(graph,cfg,result);

% Load results and and statistics if needed:
load results/diffMaps/stats.mat

% Mean accuracy plot (statistical significance)
subplot(1,2,2)
hold on
mvpalab_plotfreqcont(graph,cfg,result,stats);
Clone this wiki locally