Skip to main content

Python package for performing analysis on structural brain networks using random geometric surrogate graphs

Project description

Braingraphgeo

codecov

Braingraphgeo is a package for performing analysis on structural brain networks using random geometric surrogate graphs.

Data and examples stem from a manuscript currently under review at NeuroImage:

Trinkle, S., Foxley, S., Wildenberg, G., Kasthuri, N., La Rivière, P., “The role of spatial embedding in mouse brain networks constructed from diffusion tractography and tracer injections,” Under review at NeuroImage, 2021.

For more information, see my blog post

Installation

braingraphgeo can be installed with pip:

pip install braingraphgeo

For local installation, first clone the repo:

git clone https://github.com/scott-trinkle/braingraphgeo.git

cd into the directory:

cd braingraphgeo

and run (preferably in a virtual environment):

pip install -e .

Usage

The primary utility of braingraphgeo is the creation of geometric surrogate graphs for statistical analysis of brain networks:

from braingraphgeo.surrogates import geomsurr

W = np.load(data_path)  # 2D weighted connectivity matrix
D = np.load(distance_path)  # 2D array of node distances

Wgeo = geomsurr(W,D)  # geometric surrogate connectivity matrix

The package also includes a number of utilities for creating additional random graphs, loading data, and generating useful data visualizations. It also integrates well with external graph theory packages such as networkx.

Examples for using braingraphgeo with the sample data are available as Jupyter notebooks in examples/

Data

Example data represent weighted structural brain graphs derived from neural tracer imaging and diffusion MRI tractography. Graphs are stored as weighted adjacency matrices in .csv files. Nodes are defined as anatomical regions detailed in the Allen Mouse Brain Atlas. "XXX-I" and "XXX-C" in the column and index titles of the data files represent ipsilateral and contralateral nodes, respectively. For access to the Allen brain atlas I recommend using the allensdk:

from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache

mcc = MouseConnectivityCache()
tree = mcc.get_structure_tree()

Parcellation information for the 286 nodes in the datasets is also available in data/parcellation.csv which contains columns for Allen ID, Acronym, Full Name, and Brain Division.

Node locations in 3D physical coordinates are available in data/node_positions.csv

Edge weights for the tracer data (data/tracer.csv) are defined using the normalized connection density metric from the Knox computational model (code available here).

Edge weights for the dense (data/tract_dense_n*.csv) and endpoint (data/tract_endpoint_n*.csv) tractography graphs represent raw streamline counts between nodes, normalized by the product of the two node volumes. Tractography graphs were constructed from diffusion MRI data of postmortem mouse brains. All diffusion MRI data were collected at the University of Chicago, and tractography was performed with MRTrix3.

For fair comparison between tractography (based on an inherently symmetric diffusion metric) and tracers (based on injections to a single hemisphere), graphs have been made undirected and have enforced hemispheric symmetry: W = W.T.

Distances between nodes are available in the same format in data/fiber_distances.csv. Distances are measured in mm and represent the shortest streamline connecting each pair of nodes averaged across all tractography datasets.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

braingraphgeo-0.4.tar.gz (12.0 kB view details)

Uploaded Source

File details

Details for the file braingraphgeo-0.4.tar.gz.

File metadata

  • Download URL: braingraphgeo-0.4.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10

File hashes

Hashes for braingraphgeo-0.4.tar.gz
Algorithm Hash digest
SHA256 e518a6c44390b15256bbed0d0e711d7f3d418eeb726524011b7ac4add316d57b
MD5 f4a8a13acf5fd4cc06bb0db9ae6de841
BLAKE2b-256 766367c59448fc86223a743d663ce9a726e563f842ed870006e46d25b66f4475

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page