Python Reference API

netneurotools.networks - Constructing networks

Functions for generating group-level networks from individual measurements.

func_consensus(data[, n_boot, ci, seed])

Calculate thresholded group consensus functional connectivity graph.

struct_consensus(data, distance, hemiid[, ...])

Calculate distance-dependent group consensus structural connectivity graph.

threshold_network(network[, retain])

Keep top retain % of connections in network and binarizes.

binarize_network(network[, retain, keep_diag])

Keep top retain % of connections in network and binarizes.

match_length_degree_distribution(W, D[, ...])

Generate degree- and edge length-preserving surrogate connectomes.

randmio_und(W, itr)

Optimized version of randmio_und.

strength_preserving_rand_sa(A[, ...])

Strength-preserving network randomization using simulated annealing.

strength_preserving_rand_sa_mse_opt(A[, ...])

Strength-preserving network randomization using simulated annealing.

strength_preserving_rand_sa_dir(A[, ...])

Strength-preserving network randomization using simulated annealing.

netneurotools.modularity - Calculating network modularity

Functions for working with network modularity.

consensus_modularity(adjacency[, gamma, B, ...])

Find community assignments from adjacency through consensus.

zrand(X, Y)

Calculate the z-Rand index of two community assignments.

get_modularity(adjacency, comm[, gamma])

Calculate modularity contribution for each community in comm.

get_modularity_z(adjacency, comm[, gamma, ...])

Calculate average z-score of community assignments by permutation.

get_modularity_sig(adjacency, comm[, gamma, ...])

Calculate significance of community assignments in comm by permutation.

netneurotools.cluster - Working with clusters

Functions for clustering and working with cluster solutions.

find_consensus(assignments[, null_func, ...])

Find consensus clustering labels from cluster solutions in assignments.

match_assignments(assignments[, target, seed])

Re-label clusters in columns of assignments to best match target.

reorder_assignments(assignments[, ...])

Relabel and reorders rows / columns of assignments to "look better".

match_cluster_labels(source, target)

Align cluster labels in source to those in target.

netneurotools.plotting - Plotting brain data

Functions for making pretty plots and whatnot.

sort_communities(consensus, communities)

Sort communities in consensus according to strength.

plot_mod_heatmap(data, communities, *[, ...])

Plot data as heatmap with borders drawn around communities.

plot_conte69(data, lhlabel, rhlabel[, surf, ...])

Plot surface data on Conte69 Atlas.

plot_fslr(data, lhlabel, rhlabel[, ...])

Plot surface data on a given fsLR32k atlas.

plot_fsaverage(data, *, lhannot, rhannot[, ...])

Plot data to fsaverage brain using annot as parcellation.

plot_fsvertex(data, *[, order, surf, views, ...])

Plot vertex-wise data to fsaverage brain.

plot_point_brain(data, coords[, views, ...])

Plot data as a cloud of points in 3D space based on specified coords.

netneurotools.stats - General statistics functions

Functions for performing statistical preprocessing and analyses.

gen_spinsamples(coords, hemiid[, n_rotate, ...])

Return a resampling array for coords obtained from rotations / spins.

residualize(X, Y[, Xc, Yc, normalize, ...])

Return residuals of regression equation from Y ~ X.

get_mad_outliers(data[, thresh])

Determine which samples in data are outliers.

efficient_pearsonr(a, b[, ddof, nan_policy])

Compute correlation of matching columns in a and b.

permtest_1samp(a, popmean[, axis, n_perm, seed])

Non-parametric equivalent of scipy.stats.ttest_1samp().

permtest_rel(a, b[, axis, n_perm, seed])

Non-parametric equivalent of scipy.stats.ttest_rel().

permtest_pearsonr(a, b[, axis, n_perm, ...])

Non-parametric equivalent of scipy.stats.pearsonr().

get_dominance_stats(X, y[, ...])

Return the dominance analysis statistics for multilinear regression.

network_pearsonr(annot1, annot2, weight)

Calculate pearson correlation between two annotation vectors.

network_pearsonr_numba(annot1, annot2, weight)

Numba version of netneurotools.stats.network_pearsonr().

network_pearsonr_pairwise(annot_mat, weight)

Calculate pairwise network correlation between rows of annot_mat.

effective_resistance(W[, directed])

Calculate effective resistance matrix.

network_polarisation(vec, W[, directed])

Calculate polarisation of a vector on a graph.

network_variance(vec, D)

Calculate variance of a vector on a graph.

network_variance_numba(vec, D)

Numba version of netneurotools.stats.network_variance().

network_covariance(joint_pmat, D[, ...])

Calculate covariance of a joint probability matrix on a graph.

network_covariance_numba(joint_pmat, D[, ...])

Numba version of netneurotools.stats.network_covariance().

netneurotools.metrics - Calculating graph metrics

Functions for calculating network metrics.

Uses naming conventions adopted from the Brain Connectivity Toolbox (https://sites.google.com/site/bctnet/).

_binarize(W)

Binarize a matrix.

degrees_und(W)

Compute the degree of each node in W.

degrees_dir(W)

Compute the in degree and out degree of each node in W.

distance_wei_floyd(D)

Compute the all-pairs shortest path length using Floyd-Warshall algorithm.

retrieve_shortest_path(s, t, p_mat)

Return the shortest paths between two nodes.

communicability_bin(adjacency[, normalize])

Compute the communicability of pairs of nodes in adjacency.

communicability_wei(adjacency)

Compute the communicability of pairs of nodes in adjacency.

rich_feeder_peripheral(x, sc[, stat])

Calculate connectivity values in rich, feeder, and peripheral edges.

navigation_wu(nav_dist_mat, sc_mat)

Compute network navigation.

get_navigation_path_length(nav_paths, ...)

Get navigation path length from navigation results.

search_information(W, D[, has_memory])

Calculate search information.

path_transitivity(D)

Calculate path transitivity.

flow_graph(W[, r, t])

Calculate flow graph.

mean_first_passage_time(W[, tol])

Calculate mean first passage time.

diffusion_efficiency(W)

Calculate diffusion efficiency.

resource_efficiency_bin(W_bin[, lambda_prob])

Calculate resource efficiency and shortest-path probability.

matching_ind_und(W)

Calculate undirected matching index.

_graph_laplacian(W)

Compute the graph Laplacian of a weighted adjacency matrix.

netneurotools.datasets - Automatic dataset fetching

Functions for fetching and generating datasets.

Functions to download atlases and templates

fetch_cammoun2012([version, data_dir, url, ...])

Download files for Cammoun et al., 2012 multiscale parcellation.

fetch_civet([density, version, data_dir, ...])

Fetch CIVET surface files.

fetch_conte69([data_dir, url, resume, verbose])

Download files for Van Essen et al., 2012 Conte69 template.

fetch_fsaverage([version, data_dir, url, ...])

Download files for fsaverage FreeSurfer template.

fetch_pauli2018([data_dir, url, resume, verbose])

Download files for Pauli et al., 2018 subcortical parcellation.

fetch_schaefer2018([version, data_dir, url, ...])

Download FreeSurfer .annot files for Schaefer et al., 2018 parcellation.

fetch_hcp_standards([data_dir, url, resume, ...])

Fetch HCP standard mesh atlases for converting between FreeSurfer and HCP.

fetch_voneconomo([data_dir, url, resume, ...])

Fetch von-Economo Koskinas probabilistic FreeSurfer atlas.

Functions to download real-world datasets

fetch_connectome(dataset[, data_dir, url, ...])

Download files from multi-species connectomes.

fetch_mirchi2018([data_dir, resume, verbose])

Download (and creates) dataset for replicating Mirchi et al., 2018, SCAN.

fetch_vazquez_rodriguez2019([data_dir, url, ...])

Download files from Vazquez-Rodriguez et al., 2019, PNAS.

Functions to generate (pseudo-random) datasets

make_correlated_xy([corr, size, seed, tol])

Generate random vectors that are correlated to approximately corr.

netneurotools.freesurfer - FreeSurfer compatibility functions

Functions for working with FreeSurfer data and parcellations.

apply_prob_atlas(subject_id, gcs, hemi, *[, ...])

Create an annotation file for subject_id by applying atlas in gcs.

find_parcel_centroids(*, lhannot, rhannot[, ...])

Return vertex coords corresponding to centroids of parcels in annotations.

parcels_to_vertices(data, *, lhannot, rhannot)

Project parcellated data to vertices defined in annotation files.

vertices_to_parcels(data, *, lhannot, rhannot)

Reduce vertex-level data to parcels defined in annotation files.

spin_data(data, *, lhannot, rhannot[, ...])

Project parcellated data to surface, rotates, and re-parcellates.

spin_parcels(*, lhannot, rhannot[, version, ...])

Rotate parcels in {lh,rh}annot and re-assigns based on maximum overlap.

netneurotools.civet - CIVET compatibility functions

Functions for working with CIVET data (ugh).

read_civet(fname)

Read a CIVET-style .obj geometry file.

civet_to_freesurfer(brainmap[, surface, ...])

Project brainmap in CIVET space to freesurfer fsaverage space.

netneurotools.utils - Miscellaneous, grab bag utilities

Miscellaneous functions of various utility.

run(cmd[, env, return_proc, quiet])

Run cmd via shell subprocess with provided environment env.

add_constant(data)

Add a constant (i.e., intercept) term to data.

get_triu(data[, k])

Return vectorized version of upper triangle from data.

get_centroids(img[, labels, image_space])

Find centroids of labels in img.

netneurotools.colors - Useful colormaps

Useful colormaps.

available_cmaps()

Return list of available colormaps in module.