Skip to content
Snippets Groups Projects

Causality Code Readme

Intro

Patterns of interregional brain connectivity characterize the function of the human nervous system. Particularly, patterns of fMRI connectivity precede large-scale atrophy and are early and sensitive markers of disease prognosis. This library contains utilities to calculate connectivity with standard measures as well as implementing new measures with advantages over classical measures. To adequately characterize brain connectivity, we desire measures of correlative and causal connectivity which: * Are reproducible * Have high predictive power in various tasks * Handle nonlinear relationships in the data * Use highly accurate machine learning models for more accuracy * Incorporate explicit regularization through a structural connectivity prior from diffusion MRI

Our proposed measures exploit a machine learning formulation for efficient computation, and are evaluated against traditional measures for reproducibility and predictive power. For background, please see our manuscript preprint here: Manuscript preprint.

The broad categories of connectivity and their general algorithmic fomulations which we examine include:

Functional connectivity Pearson's R, Partial correlation, instantaneous spectral density, etc. (Not pictured)

Machine-learning functional connectivity (MLFC) MLFC algorithm

Granger Causality (GC) GC algorithm

Structurally-projected granger-causality (SPGC) SPGC algorithm

For further clarification, the algorithm for the sparse PCA projection incorporating the structural pior is below:

SPGC algorithm

Important functionality files:

  • ML_EC_Functions
    • contains all functions for calculating causal metrics on fMRI data
  • ML_FC_Functions
    • contains all functions for calculating correlative metrics on fMRI data
  • ML_FC_HPO
    • contains all functions for performing an HPO for complicated MLEC/MLFC models and incorporate into FC/EC prediction
  • PriorConstrainedSparsePCA
    • contains code to perform a prior-informed sparse PCA (importable class)
  • GC_Functions
    • contains functions for basic GC and FC analysis
  • ML_EC_FC_Utils
    • contains utility functions used generally across multiple EC/FC inference methods
  • StatsmodelsVAR_WithLasso
    • alteration to StatsmodelsVAR (statsmodels vector autoregression) to use lasso regression and still keep other functionality with AIC, BIC, etc.

For an example of how to run/use the functions described above, see example/ExampleWalkthrough.md

Additional functionality

Utilities

Found in utils

  • utils/GC_Utils

    • contains functions used by ML_EC_Functions, these do things like reshape matrices, AIC/BIC lag selection, etc.
  • utils/Neuroimaging_Utils

    • contains functions to mask/extract timeseries, manipulate brain images, etc.
  • utils/Ray_Utils

    • contains functions for parallelization with ray

Graph measures

Found in graph_connectivity/GraphMeasures

  • fGlobalMeasures

    • Calculates the following global measures of graph connectivity:
      • Clustering coefficient
      • Characteristic path length
      • Small-worldedness coefficeint
      • Global efficiency
      • Modularity
  • fLocalMeasures

    • Calculates the following local measures of graph connectivity:
      • Local Clustering coeff
      • Local efficiency
      • Connectivity degree
      • Betweenness centrality

HCP reproducibility and predictiveness experiments

Found in experiments/HCP

  • Reproduces experiments in preprint cited above
    • See experiments/HCP_Experiment_Walkthrough.md for greater detail