Skip to content
Graph theory analysis of brain MRI data
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
data Updated package to v1.0.0 Apr 10, 2017
inst/extdata Fixed a bug with 'range.transform'; changed icon location. Dec 25, 2014
man Update package to v2.7.0 Dec 15, 2018
.Rbuildignore Updated package to v1.0.0 Apr 10, 2017
.gitattributes Updated package to v0.56.0 Dec 29, 2015
.travis.yml Minor update to `.travis.yml`; no version change May 30, 2018
DESCRIPTION Update package to v2.7.0 Dec 15, 2018
NAMESPACE Update package to v2.7.0 Dec 15, 2018 Update package to v2.7.0 Dec 15, 2018 Fix bug in `partition` and add checks to `robustness` Dec 7, 2018 Updated package to v2.2.0 May 28, 2018


Project Status: Active - The project has reached a stable, usable state and is being actively developed. Linux Build Status CRAN_Status_Badge GPL License CRAN Downloads

brainGraph is an R package for performing graph theory analyses of brain MRI data. It is most useful in atlas-based analyses (e.g., using an atlas such as AAL, or one from Freesurfer); however, many of the computations (e.g., the GLM-based functions and the network-based statistic) will work with any graph that is compatible with igraph. The package will perform analyses for structural covariance networks (SCN), DTI tractography (I use probtrackx2 from FSL), and resting-state fMRI covariance (I have used the Matlab-based DPABI toolbox).

Table of Contents


The package should work "out-of-the-box" on Linux systems (at least on Red Hat-based systems; i.e., CentOS, RHEL, Scientific Linux, etc.) since almost all development (and use, by me) has been on computers running CentOS 6 and (currently) CentOS 7. I have also had success running it (and did some development) on Windows 7, and have heard from users that it works on some versions of Mac OS and on Ubuntu. Please see the User Guide (mentioned below) for more details.

Installation commands

There are (primarily) two ways to install this package:

  1. Directly from CRAN: (use one of the following commands)
install.packages('brainGraph', dependencies=TRUE)
  1. From the GitHub repo (for development versions). This requires that the devtools package be installed:

This should install all of the dependencies needed along with the package itself. For more details, see the User Guide (link to PDF in next section).

Multi-core processing

Many brainGraph functions utilize multiple CPU cores. This is primarily done via the foreach package. Depending on your OS, you may need to install doMC (macOS and Linux) or doSNOW (Windows).

Then, to set up your R session for parallel processing:

OS <- .Platform$OS.type
if (OS == 'windows') {
  num.cores <- as.numeric(Sys.getenv('NUMBER_OF_PROCESSORS'))
  cl <- makeCluster(num.cores, type='SOCK')
  clusterExport(cl, 'sim.rand.graph.par')   # Or whatever function you will use
} else {
  num.cores <- detectCores()


On some systems (e.g., macOS and Windows) it might be very difficult to install the necessary packages/dependencies for the GUI functions. Since v2.2.0, the R packages RGtk2 and cairoDevice have been changed to Suggests (i.e., they are no longer required), so installation should still be possible. This also means it should be possible to install on a headless server.

Usage - the User Guide

I have a User Guide that contains extensive code examples for analyses common to brain MRI studies. I also include some code for getting your data into R from Freesurfer, FSL, and DPABI, and some suggestions for workflow organization. The User Guide is the most complete documentation of this package, so I encourage you to read it thoroughly. Please start with the Preface.

To access the User Guide, a PDF is available at this link.

Graph measures

In addition to the extensive list of measures available in igraph, I have functions for calculating/performing:

Group analyses

There are several analyses based on the General Linear Model (GLM), and others that have different purposes.


  • Between-group differences in vertex- or graph-level measures (e.g., degree, betweenness centrality, global efficiency, etc.) using the GLM's. See Chapter 8 of the User Guide, which was partly modeled after the GLM page on the FSL wiki
  • The multi-threshold permutation correction (MTPC) method for statistical inference (see Drakesmith et al., 2015 and Chapter 9 of the User Guide)
  • The network-based statistic (NBS) (see Zalesky et al., 2010 and Chapter 10 of the User Guide)
  • Graph- and vertex-level mediation analysis (see Chapter 11 of the User Guide, and the mediation package in R)

Non-GLM based

  • Bootstrapping of graph-level metrics (e.g., modularity)
  • Permutation analysis of between-group differences in vertex- or graph-level measures
  • "Individual contributions" (leave-one-out [LOO] and add-one-patient [AOP]; see Saggar et al., 2015)

Null graph-related measures

  • Null/random graph generation (both the "standard" method, and also a method controlling for clustering; see Bansal et al., 2009)
  • Small-worldness (the "original" of Watts & Strogatz, 1998 and Humphries et al., 2008; and "omega" introduced in Telesford et al., 2011)
  • Rich-club coefficients and normalization (see Zhou & Mondragon, 2004; and Colizza et al., 2006)

Other measures

  • Efficiency (global, nodal, and local; see Latora & Marchiori, 2001)
  • The rich-core (see Ma & Mondragon, 2015)
  • Leverage centrality (see Joyce et al., 2010)
  • Asymmetry index
  • Robustness ("targeted attack" and "random failure") and vulnerability
  • Euclidean distances of edges
  • Participation coefficient and within-module degree z-score (see Guimera & Amaral, 2005)
  • Gateway coefficient (see Vargas & Wahl, 2014)
  • Communicability and communicability betweenness (see Estrada & Hatano, 2008; Estrada et al., 2009; Crofts & Higham, 2009)
  • Vertex s-core membership (see Eidsaa & Almaas, 2013)


There is a plotting GUI for fast and easy data exploration that will not work without data from a standard atlas (ideally to be fixed some time in the future). You may use a custom atlas if you follow the same format as the other atlases in the package (see Chapter 4 of the User Guide for instructions).

brainGraph GUI

Getting Help

For bug reports, feature requests, help with usage/code/etc., please join the Google Group brainGraph-help. You may also consult the User Guide, and you can open an issue here on GitHub.

Future versions

An incomplete list of features/functionality I plan on adding to future versions:

  • Easy import of Freesurfer data for structural covariance networks
  • Longitudinal modeling (with linear mixed effects (LME) models)
  • Thresholding and graph creation using the minimum spanning tree as a base
  • Thresholding and graph creation for resting-state fMRI using a technique such as the graphical lasso
  • Write functions to print group analysis results in xtable format for LaTeX documents
  • Add data tables for multiple atlases/parcellations (e.g., Gordon [see Gordon et al., 2016, Cerebral Cortex], HCP, etc.)
You can’t perform that action at this time.