3. 🧠 Scalp‐Based EEG Function Reference - jasonnan2/Automated-Analysis-of-EEG GitHub Wiki
This page outlines the standard analysis workflow using the ScalpObject
class to process, analyze, and visualize scalp-level EEG data. Reference script is runERP.m.
Example
# load in required variables
% Initialize ScalpObject
scalpObject = ScalpObject(project.scalpData, project.info, baselineTime, timeRange, cfg);
% Clean missing subject data
scalpObject = scalpObject.cleanDatasets();
% Preprocess: outlier removal, baseline correction
scalpObject = scalpObject.standardProcessing();
% Calculate average EEG across channels/freqs/time
scalpObject = scalpObject.calChanData();
% Run group comparisons with default cfg
scalpObject = scalpObject.analyzeScalp();
% Plot ERP waveforms across groups - Override cfg and plot Pz and FC4 electrodes only. cfg is used for all other parameters
scalpObject.plotERPs('chans2plot',{'Pz', 'FC4'});
% Plot significant group differences in bar form
scalpObject.plotScalpBar();
📚 Initial Set Up and Processing
obj = ScalpObject(project.scalpData, project.info, baselineTime, timeRange,cfg)
Initializes a new scalp analysis object.
Inputs | Description |
---|---|
scalpData |
Struct of EEG data for each group |
info |
Metadata from project.info |
baselineTime |
1×2 vector (in ms) for baseline correction |
timeRange |
Struct defining labeled time windows |
cfg (optional) |
Configuration struct for filtering/plotting |
obj.cleanDatasets()
Removes subjects missing across any group or variable.
obj.standardProcessing(...)
Performs outlier removal and optional baseline correction.
Parameter | Description | Default |
---|---|---|
'outlier' |
'5SD' or '3MAD' method for subject-level outlier removal |
'5SD' |
'calBaseline' |
Whether to apply baseline correction | 1 |
obj.calChanData()
Computes average channel-level activity across frequencies, time windows, and groups.
Parameter | Description |
---|---|
None | No parameters |
Main Analysis Functions
⚠️ If no name-value pairs are specified, values in
cfg
are used by default. Name-value pairs overridecfg
.
obj.analyzeScalp(...)
💻 Performs group comparisons and identifies significant electrodes.
Parameter | Description |
---|---|
'vars2plot' |
Cell array of variable names to include |
'freq2plot' |
Frequencies to analyze |
'times2plot' |
Time windows to compare (e.g., 'time1' ) |
'combinations' |
Nx2 array of group indices to compare (e.g., [1 2] ) |
'FDRflag' |
1 = apply FDR correction; 0 = uncorrected |
'toPlot' |
1 = generate scalp topoplots |
'isnormal' |
'auto' , 1 = assume normal, 0 = non-parametric test |
Uses
cfg
by default; name-value pairs take precedence.
obj.calSigTbl(...)
Extracts significantly different neural measures and saves them into a table for each variable and time window. Must be run after obj.analyzeScalp()
.
Parameter | Description |
---|---|
chanTypes (optional) |
A string specifying which channels to include in the table: • 'sig' (default) extracts only significant channels• 'all' includes all channels |
Output: Populates
obj.results.sigValues.(variable).(time)
with the resulting tables.
obj.plotERPs(...)
📉 Plots ERP waveforms across selected channels, groups, and frequencies.
Parameter | Description |
---|---|
'vars2plot' |
Variables to plot |
'freq2plot' |
Frequency bands to include |
'times2plot' |
Time windows to plot |
'chans2plot' |
Channel labels or 'all' for significant channels |
'groups2plot' |
Groups to overlay in the plot |
'errorType' |
'none' , 'sem' , or '95CI' |
'color_list' |
Custom colors for each group |
Significant channels are used if
'chans2plot' = 'all'
.
obj.plotScalpBar(...)
📊 Plots grouped bar charts for selected variables, frequencies, and time ranges.
Parameter | Description |
---|---|
'vars2plot' |
Variables to plot |
'freq2plot' |
Frequency bands to include |
'times2plot' |
Time windows to plot |
'chans2plot' |
Channel labels or 'all' for significant channels |
'groups2plot' |
Groups to overlay in the plot |
'color_list' |
Custom colors for each group |