Tutorial

GLHMM is a Python toolbox with a focus on neuroscience applications but broadly applicable to other domains as well. It implements a generalisation of various types of Hidden Markov Model (HMM). The toolbox can be applied on multiple data modalities, including fMRI, EEG, MEG, and ECoG, and offers a comprehensive set of HMMs tailored for different data types and analysis goals. The most important configurable aspect is the state distribution, which is parameterized using a regression model. A non-exhaustive list of possible state distributions are:

  • Gaussian: used in fMRI and other neuroimaging modalities.

  • Wishart: employed in fMRI to specifically focus on changes in connectivity (covariance).

  • Time-delay embedded: applied to whole-brain electrophysiological data (MEG or EEG), to capture spectral modulations in the data.

  • Autoregressive: provides a more detailed spectral description for electrophysiological data with a limited number of channels.

  • Regression-based decoding: describes the dynamic relationship between brain activity and ongoing stimuli.

  • Regression-based encoding: emphasizes the spatial interpretation of brain activity in relation to stimuli.

Installation

If you have not done so, install the repo using:

pip install glhmm

Examples

Example data is provided in the example_data folder.

For an example of running a standard HMM using only one set of time series, see Example standard Gaussian HMM.

For an example of running a GLHMM using two sets of time series, see Example GLHMM.

Relations to behaviour

After estimating an HMM, we can explore its connections with an external variable not initially considered in the model. This could involve tasks like predicting age from subject-specific HMMs based on neuroimaging data or examining correlations with physiological factors. Our toolbox supports these types of analyses in the modules Prediction and Statistics

Prediction

This module enables the utilization of individual brain activity patterns for various applications, including predictions (such as cognitive abilities) and classifications (of subjects or clinical groups, for example). For a tutorial, see here

Statistics

This module provides powerful permutation testing analysis, which allows for statistical significance assessment without data distribution assumptions. It supports various test types, such as between- and within-session/subject tests. Users can choose between permutation testing with regression or correlation for a wide range of research questions. For a tutorial demonstrating the application of testing look at the following examples: - Testing across subjects . - Testing across sessions . - Testing across trials . - Testing across visits .