Brain Connectivity Toolbox

 

NOTE:  THIS PAGE IS CURENTLY UNDER CONSTRUCTION AND WILL BE CONTINUALLY UPDATED

 

This toolbox combines Matlab functions and data sets that are useful for the analysis of structural or functional brain networks.  All efforts have been made to avoid errors, but users are strongly urged to independently verify the accuracy of these functions, and to ascertain that their use is appropriate for the chosen application.  Please report bugs or substantial improvements to osporns@indiana.edu.

 

Several people have made contributions to this toolbox – if you wish to contribute yourself with a new function or set of functions, please contact osporns@indiana.edu.

 

Contributors:

OS, Olaf Sporns

AR, Aviad Rubinstein

RK, Rolf Kötter

MR, Mikail Rubinov

 

We distinguish graphs by whether they are binary or weighted, undirected (symmetrical) or directed.  All four combinations may occur.  It is very important to note that individual functions may be applicable to graphs of only one or several types.  Currently, graphs provided as input to these functions are not examined for graph type to ensure appropriate use.  Be aware that, for example, use of a weighted graph with a function that was not designed for this graph type will almost certainly give invalid results.

 

Graph Types:

                                    BU, binary and undirected

                                    BD, binary and directed

                                    WU, weighted and undirected

                                    WD, weighted and directed

 

 

Download All Functions (BCT.zip)

 

 

Brain Connectivity Data Sets

 

Function

Description

Graph Type

Contributor / Reference

macaque71.mat

Macaque cortex, as described in Young (1993), N = 71, K = 746

BD

OS

Young, 1993

Used in (e.g.): Sporns, 2002

fve30.mat

fve32.mat

Two versions (N = 30, K = 311; N = 32, K = 320) of macaque visual cortex, after Felleman and van Essen (1991)

BD

OS

Felleman and Van Essen, 1991

Used in (e.g.): Sporns et al., 2000; Sporns and Kotter, 2004

macaque47.mat

Binary connection matrix of cortico-cortical connections among visual and sensorimotor areas.  N = 47, K = 505.

BD

RK

Used in (e.g.): Honey et al., 2007

cat.mat

Binary connection matrix of cortico-cortical connections in the cat brain, transcribed from the original article by Scannell et al., 1999. 

‘CIJall’ has all cortical and thalamic areas and connections, with ordinal strength information preserved

‘CIJctx’ has only 52 cortical regions, N = 52, K = 820.

BD

OS

Scannell et al., 1999

Used in (e.g.): Sporns and Zwi, 2004; Sporns and Kotter, 2004

 

 

Synthetic Connection Matrices

 

Function

Description

Graph Type

Contributor / Reference

makerandCIJ.m

Generates a random connection matrix of size N, K.

BD

OS

makerandCIJ_nondir.m

Generates a random connection matrix of size N, K.

BU

OS

makerandCIJdegreesfixed.m

Generates a random connection matrix given a specific indegree and outdegree sequence.  Returns a flag that indicates if the algorithm succeeded or failed.

BD

AR

makeevenCIJ.m

Generates a connection matrix of size N, K, with a number of clusters that are linked by evenly distributed random connections.

BD

OS

makefractalCIJ.m

Generates a fractal connection matrix with a hierarchical cluster organization.

BD

OS

makelatticeCIJ.m

Generates a lattice connection matrix of size N, K.  Connections are arranged to be maximally close to the main diagonal, without “wrapping around” (no ring).

BD

OS

makeringlatticeCIJ.m

Same as ‘makelatticeCIJ.m’, but with wrap-around, i.e. a ring lattice is generated.

BD

OS

maketoeplitzCIJ.m

Generates a connection matrix of size N, K, with connections arranged such that their density exhibits a Gaussian profile with distance away from the main diagonal.

BD

OS

 

 

Graph Randomization Algorithms

 

Function

Description

Graph Type

Contributor / Reference

randomizeCIJiop.m

Randomizes a given connection matrix by swapping two connections at a time.  Preserves indegree and outdegree sequence.  Vertex order is randomly permuted before swaps are executed.

BD

OS

Maslov and Sneppen (2002)

randomizeCIJiop_nondir.m

A version of ‘randomizeCIJiop’ that works for binary undirected connection matrices.

BU

OS

Maslov and Sneppen (2002)

randmiod.m

A different randomization algorithm, also preserving degrees.  If the matrix is weighted, the out-strength is preserved in addition to the out-degree, while the in-strength is not preserved.

BD, WD

MR

randmiou.m

A version of ‘randmiod.m’ that works for undirected matrices.  If the connection matrix is weighted, in- and out-degree are preserved, but the connection weights are redistributed

BU, WD

MR

latticizeCIJiop.m

Latticizes a given connection matrix by swapping connections in such a way as to minimize a cost function that determines the shape (e.g. ring lattice) of the matrix.

BD

OS

 

 

Matrix and Graph Visualization

 

Function

Description

Graph Type

Contributor / Reference

writetoPAJ.m

A function that converts matlab connection matrices into Pajek-compatible format

BU, BD

CH

reorderMAT.m

A reordering algorithm that permutes rows and columns of a matrix in order to force matrix elements with high values near the main diagonal – this often helps in displaying community structure, clusters, and the like.

BU, BD, WU, WD

OS

 

 

Size, Degrees and Degree Distributions

 

Function

Description

Graph Type

Contributor / Reference

density.m

Density of connections over the entire graph

BD

OS

degrees.m

Vertex degrees

BD

OS

degrees_nondir.m

Vertex degrees, assuming undirected (symmetrical) connections

BU

OS

strengths.m

Vertex strengths (i.e. sum of all connection weights)

WD

OS

strengths_nondir.m

Vertex strengths, assuming undirected (symmectrical) connections

WU

OS

compare.m

An implementation of the matching index, expressing the overlap or correlation between the connection patterns of all vertex pairs

BD

OS

Hilgetag et al., 2002                                         

jdegree.m

Joint degree distribution

BD

OS

Sporns, 2002

assortativity.m

Assortativity, after Newman, 2002.  Essentially a correlation coefficient for the degrees of linked vertices.  Positive assortativity indicates that edges tend to link vertices with same or similar degree.

BD, BU

OS

Newman, 2002

 

 

Clustering

 

Function

Description

Graph Type

Contributor / Reference

clustcoef.m

Finds all neighbors of a central vertex (regardless whether they are connected via incoming, outgoing, or bidirectional connections), then finds the ratio of actually existing over all possible connections between them.

BD, BU

OS

Cbin_undirected.m

Gives results equivalent to ‘clustcoef.m’ for undirected matrices

BU

MR

Cbin_fagiolo.m

Binary clustering coefficient, following the approach described by Fagiolo, 2006.  Results are similar, but not identical, to ‘clustcoef.m’, as neighbors that are connected with one or two connections are handled differently.

BD

MR

Fagiolo, 2006

Cwei_onnela_undirected.m

Clustering coefficient for weighted undirected matrices, following the approach of Onnela (after Fagiolo, 2006)

WU

MR

Onnela

Fagiolo, 2006

Cwei_onnela_fagiolo.m

Clustering coefficient for weighted directed matrices, following Fagiolo, 2006.

WD

MR

Onella

Fagiolo, 2006

components.m

Finds components by examining the reachability matrix of a graph (provided by ‘reachdist.m’)

BD, BU

OS

 

 

Paths, Path Lengths and Distances

 

Function

Description

Graph Type

Contributor / Reference

findpaths.m

Finds all paths that start at a set of source vertices, up to a specified length.  Warning: very memory-intensive

BD

OS

findwalks.m

Finds all walks

BD

OS

reachdist.m

Finds the reachability and distance matrices.  Note: Distance matrices have nonzero entries on the main diagonal

BD

OS

breadth.m

 

BD

OS

breadthdist.m

 

BD

OS

charpath.m

Calculates the characteristic path length from the distance matrix (the average of all finite entries), as well as node excentricity, graph radius and diameter

BD

OS

erange.m

Finds shortcuts

BD

OS

Watts, 1999

cycprob.m

Cycle probabilities, including the fractions of all paths that can be completed as cycles.

BD

OS

Lbin.m

Calculates a distance matrix for binary graphs, with zeros on the main diagonal, and ‘Inf’ if no path exists.  The reachability matrix would correspond to all entries of the distance matrix with finite path lengths greater than 0.

BD

MR

Lwei.m

Calculates a distance matrix for weighted graphs, converts connection weights (proximities) to distances by using a simple inverse function.  This function gives identical results to MatlabBGL’s ‘all_shortest_paths.m’.

WD

MR

 

 

Centrality

 

Function

Description

Graph Type

Contributor / Reference

BCwei.m

Betweenness centrality.  Input matrix can be binary or weighted.  Connection weights (proximities) are converted to distances by using a simple inverse rule.  This function gives identical results to MatlabBGL’s ‘betweenness_centrality.m’.  Note that the output is a count of the number of shortest paths, which can be converted to a ratio.

This function outputs both node and edge centrality.

BD, WD

BU, WU

MR

 

 

Motifs

 

Function

Description

Graph Type

Contributor / Reference

count_motifs.m

Main function for counting motif frequencies, outputs also the motif participation for each vertex

BD, BU

AR, OS

count_list_motifs.m

Same as ‘count_motifs’, in addition outputs a list of all motifs and their participating vertices

BD, BU

AR, OS

find_connected_subsets.m

Function called by ‘count_motifs’ to find all connected subsets of a connection matrix

BD, BU

AR

compress_subgraphs.m

Function called by ‘count_motifs’ to compress all subgraphs

BD, BU

AR

weighted_motifs.m

compress_weighted.m

Functions for counting motif intensities and coherences for weighted graphs.  NOTE: Only one weighted motif per subgraph is counted.  MR’s motif functions (see below) take an alternative approach.

WD, WU

AR, MR

motifs2a.mat

motifs3a.mat

motifs4a.mat

motifs5a.mat

These data files are needed to do motif counts of sizes 2-5.

BD, BU

AR

motif3count.m

motif4count.m

motif34lib.mat

make_motif34lib.m

motif_conversion3.mat

find_motif34.m

These functions are for binary matrices and should produce identical output to ‘count_motifs.m’.  ‘motif3count.m’ is for motifs of size 3.  Both functions require ‘motif34lib.mat’ (generated by ‘make_motif34lib.m’).

To get a motif frequency matching that delivered by ‘count_motifs.m’, load ‘motif_conversion3.mat’ and convert with ‘convertMtoO’ (MR uses a different motif numbering scheme than OS/AR).

‘find_motif34.m’ allows to access a motif ID for a given motif matrix, or motif matrices (all isomorphs) for a given motif ID (in MR’s classification).

BD, BU

MR

motif3IQ.m

motif4IQ.m

These functions are for weighted motif counts – not using the same approach as ‘weighted_motifs.m’.  Instead for each given subgraph, all weighted motifs contained within that subgraph are counted (this is analogous to the “functional motifs” of Sporns and Kotter, 2004).  To get to motif frequencies, just collapse the matrix F, for example:  mf = sum(F,2)’./3  (for motifs of size 3).  

WD, WU

BD, BU

MR

 

 

Cutsets

 

Function

Description

Graph Type

Contributor / Reference

COMING SOON