Multivariate Transfer Entropy Estimation using Coupled Hidden Markov Models
This repository contains MATLAB codes for estimating Multivariate Transfer Entropy (MTE) using Coupled Hidden Markov Models (CHMMs), specifically Latent Structure Influence Models (LSIMs). The implementation is based on research published in the IEEE ICBME 2022 conference.
Studying complex dynamical systems such as the brain requires identifying causal relationships from brain signals like EEG. In such systems, causal inference is challenging since datasets are often high-dimensional, nonlinear, noisy, and often with small sample sizes. Using multivariate transfer entropy (MTE), causal relationships can be inferred in linear and nonlinear ways.
In this study, latent structure influence models (LSIMs) are adapted to develop a novel MTE estimator that measures effective connectivity in multivariate time series. LSIMs are a specific type of coupled hidden Markov model (CHMM) in which hidden Markov chain interactions are expressed as influence models.
Simulated datasets from neural mass models (NMMs) are used to compare the proposed estimator with the existing k-nearest neighbors (kNN) method at different conditions, including data length, signal-to-noise ratio, and network size. Using ground-truth structure networks, we define a binary classification problem for recovering directed edges from NMM simulation datasets in each specific condition.
Key Finding: Based on the AUCPR criterion, the proposed MTE estimator for NMMs is more effective than the standard kNN method. The proposed LSIM-based method outperforms the existing kNN method by about 3.7% in AUCPR values for SNRs in the range of 0 dB to 5 dB.
@inproceedings{karimi2022coupled,
title={Coupled Hidden Markov Models for Estimating Multivariate Transfer Entropy in Neural Mass Models: A Simulation Study},
author={Karimi, S. and Shamsollahi, M.B.},
booktitle={2022 29th National and 7th International Iranian Conference on Biomedical Engineering (ICBME)},
pages={14--21},
year={2022},
organization={IEEE}
}mte-estimation/
├── main_nms_connectivity.m # Main simulation script
├── paper_plots.m # Script to generate paper figures
├── nms_connectivity_data.m # Neural mass model data generation
├── H_methods_IT_corrected.m # HERMES toolbox integration
├── prec_rec.m # Precision-recall curve computation
├── nms_mte_results.mat # Pre-computed results
├── pr-curve.png # Sample PR curve image
├── figs/ # Generated figures directory
├── chmm-lsim-matlab-toolbox-main/ # CHMM-LSIM toolbox
└── HERMES Toolbox/ # HERMES connectivity toolbox
- MATLAB (R2018b or later recommended)
- Dependencies:
HERMES Toolbox MEX File Dependency: The HERMES toolbox requires compiled MEX files (tim_matlab.mex*) that are platform-specific. If you encounter the following error:
Unrecognized function or variable 'tim_matlab'.
Error in entropy_combination (line 95)
I(i) = tim_matlab(...
Solutions by Operating System:
- Windows: MEX files are typically included and should work out-of-the-box
- macOS/Linux: You may need to compile the MEX files manually:
- Navigate to
HERMES Toolbox/lib/tim-matlab-1.2.0/ - Run
mex tim_matlab.cin MATLAB - Ensure the compiled file is in your MATLAB path
- Navigate to
Alternative: If MEX compilation fails, you can still run the LSIM-based comparisons by commenting out the HERMES-related code in main_nms_connectivity.m (lines 113-120).
-
Clone this repository:
git clone https://github.com/your-username/mte-estimation.git cd mte-estimation -
Add the required toolboxes to your MATLAB path:
addpath(genpath('chmm-lsim-matlab-toolbox-main')) addpath(genpath('HERMES Toolbox'))
-
Generate simulation data and results:
main_nms_connectivityThis script will:
- Generate neural mass model simulations
- Apply different noise levels (SNR: -10 to 20 dB)
- Test various network sizes (3, 5, 10 channels)
- Compare LSIM vs kNN methods
- Save results to
nms_mte_results.mat
-
Generate paper figures:
paper_plotsThis will create:
- ROC curves
- Precision-Recall curves
- Performance comparison plots
- All figures saved in
figs/directory
The proposed LSIM-based MTE estimator shows superior performance compared to the standard kNN method across various conditions:
| Channels | SNR (dB) | ||||||
|---|---|---|---|---|---|---|---|
| -10 | -5 | 0 | 5 | 10 | 15 | 20 | |
| ---------- | ---------- | ---- | ---- | ---- | ---- | ---- | ---- |
| 3 | -1.7 | 3.5 | 4.7 | 1.1 | -0.4 | -1.8 | -0.6 |
| 5 | -0.3 | 5.5 | 3.0 | 1.0 | 1.4 | 2.6 | 2.5 |
| 10 | 0.5 | 1.9 | 3.6 | 4.1 | 3.2 | 1.0 | 0.3 |
| ---------- | ---------- | ---- | ---- | ---- | ---- | ---- | ---- |
| Avg | -0.5 | 3.6 | 3.8 | 2.1 | 1.4 | 0.6 | 0.7 |
Key Observations:
- Best performance at SNR = 0 dB with 3.8% improvement
- Consistent improvements across most SNR levels
- Robust performance across different network sizes
Comparison of PR curves in 10-channel NMM simulations at SNR=0dB and T=500
- Simulated EEG-like signals using coupled neural mass models
- Excitatory and inhibitory synaptic connections
- Realistic brain connectivity patterns
- LSIM Method: Uses coupled hidden Markov models with latent structure influence
- kNN Method: Traditional k-nearest neighbors approach
- Evaluation: Binary classification of directed edges using ground truth
- Network Sizes: 3, 5, 10 channels
- Data Lengths: 100, 200, 500, 1000 time points
- SNR Levels: -10 to 20 dB (7 levels)
- Evaluation Metrics: AUCPR, AUROC, Precision, Recall
- Novel MTE Estimator: First application of LSIMs for transfer entropy estimation
- Robust Performance: Superior results under noisy conditions
- Scalable Framework: Works across different network sizes and data lengths
- Comprehensive Evaluation: Thorough comparison with state-of-the-art methods
% Simulation parameters
max_iteration = 100; % Maximum EM iterations
num_surrogate = 20; % Number of surrogate tests
T_durations = [100,200,500,1000]; % Data lengths
db_vals = -10:5:20; % SNR levels (dB)
channels(1).num = [3,5,10]; % Network sizes
% Model parameters
n_lags_hermes = 2; % HERMES lag parameter
n_lags_lsim = 1; % LSIM lag parameter
fs = 100; % Sampling frequency- Source: GitHub Repository
- Purpose: Provides the core LSIM implementation
- Key Functions:
em_lsim,te_embed_lsim,forward_backward_lsim
- Source: GitHub Repository
- Reference: Niso, G., et al. (2013). HERMES: towards an integrated toolbox to characterize functional and effective brain connectivity. Neuroinformatics, 11(4), 405-434.
- Purpose: Provides kNN-based transfer entropy estimation for comparison
-
MEX File Error (most common):
Unrecognized function or variable 'tim_matlab'- Cause: Platform-specific MEX files not compiled
- Solution: See "Important System Compatibility Note" above
-
Path Issues:
% Ensure all toolboxes are in MATLAB path addpath(genpath('chmm-lsim-matlab-toolbox-main')) addpath(genpath('HERMES Toolbox')) addpath(genpath('.'))
-
Memory Issues:
- Large simulations may require significant RAM
- Consider reducing
max_repeatorT_durationsfor testing
-
Compilation Errors on macOS/Linux:
- Ensure you have a C compiler installed
- Try:
mex -setup Cin MATLAB - For macOS: Install Xcode Command Line Tools
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please open an issue on the GitHub repository.
