5. Neural‐Behavioral Modeling - jasonnan2/Automated-Analysis-of-EEG GitHub Wiki
This page explains how to model relationships between neural features and behavioral variables using the NeurBehMdl
framework. It applies to both ScalpObject
and SourceObject
. Sample script can be found at the bottom of both runERP.m or runSource.m
% Simulate a behavioral table
behTbl = table();
rng(1234)
behTbl.Subject = {sublist1, sublist2};
behTbl.behVar1 = rand(1,length(behTbl.Subject)';
% Obj here can either be a scalpObject or sourceObject as long as the main analyze function has been run.
% Extract significant neural data into a tabular format
obj = obj.calSigTbl('sig');
% Calculate the neural behavioral models
obj =obj.NeurBehMdl(neuralVar,behTbl,keyColumnName,baseModel,'modelName');
% Extracts p values
obj.neuralBehMdl.modelName_NeuralVarName = extractp(obj.neuralBehMdl.modelName_NeuralVarName,"NeuralVarName",1);
Output from scalpObject.neuralBehMdl.modelName_NeuralVarName
Model Formula | Model Type | NeuralVarNameneuralP |
---|---|---|
NeuralVarName_time1_alpha_Pz | LinearModel (1×1) | 0.49731 |
NeuralVarName_time1_theta_FC4 | LinearModel (1×1) | 0.36107 |
NeuralVarName_time1_theta_O2 | LinearModel (1×1) | 0.22291 |
Extracts significantly different neural measures and saves them into a table for each variable and time window. Can be done for both scalp or source objects. Must be run after obj.analyzeRoi()
or obj.analyzeScalp()
Parameter | Description |
---|---|
chanTypes (optional)
|
A string specifying which channels/ROIs to include in the table: • 'sig' (default) extracts only significant channels/ROIs• 'all' includes all channels/ROIs |
Output: Populates
obj.results.sigValues.(variable).(time)
with the resulting tables.
Fits behavioral linear models that relate neural data to behavioral variables. Full model will be baseModel+neuralVar. e.g. if baseModel = behVar1 ~ 1 +
and neuralVar = {'neuralVar1}
, then the full model will be behVar1 ~ 1 +neuralVar1
.
Parameter | Description |
---|---|
neuralVar |
Cell array of neural variable(s) names to test. Must match variables defined in obj.info.variables . |
behTbl |
A table containing behavioral data. Must include subject IDs in a column with a name that matches keyColumnName . |
keyColumnName |
String specifying the column name in behTbl for subject IDs. |
baseModel |
A base model string for fitlm (e.g., "behVar1 ~ 1 +" ). The neural variable is automatically appended to this model specification. |
modelname |
(Optional) A label to identify the model. If not provided, a valid field name is created by concatenating baseModel and the neural variable name. |
Output: Saves the fitted models in
obj.neuralBehMdl.(modelname_variable)
for each neural variable and time window.
Extracts p-values corresponding to the neural predictors from the fitted behavioral models.
Parameter | Description |
---|---|
behModels |
The table or struct output returned from NeurBehMdl containing the fitted models. |
template |
A string used to identify the neural predictor in the model's coefficient names (e.g., 'NeuralVarName' ). |
showall (optional)
|
A flag (1 or 0). If set to 1 (default), all p-values are returned; if set to 0 , only models with p < 0.05 are retained. |
Output: Adds a new field/column named
<template>neuralP
to thebehModels
structure containing the extracted p-values.