Python Reference API

netneurotools.datasets - Automatic dataset fetching

Functions for handling datasets.

To download templates

fetch_fsaverage([version, use_local, force, ...])

Download files for fsaverage FreeSurfer template.

fetch_fsaverage_curated([version, force, ...])

Download files for fsaverage FreeSurfer template.

fetch_hcp_standards([force, data_dir, verbose])

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

fetch_fslr_curated([version, force, ...])

Download files for HCP fsLR template.

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

Fetch CIVET surface files.

fetch_civet_curated([version, force, ...])

Download files for CIVET template.

fetch_conte69([force, data_dir, verbose])

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

fetch_yerkes19([force, data_dir, verbose])

Download files for Donahue et al., 2016 Yerkes19 template.

To download atlases

fetch_cammoun2012([version, force, ...])

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

fetch_schaefer2018([version, force, ...])

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

fetch_mmpall([version, force, data_dir, verbose])

Download .label.gii files for Glasser et al., 2016 MMPAll atlas.

fetch_pauli2018([force, data_dir, verbose])

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

fetch_ye2020()

Fetch Ye et al., 2020 subcortical parcellation.

fetch_voneconomo([force, data_dir, verbose])

Fetch von-Economo Koskinas probabilistic FreeSurfer atlas.

To download project-related data

fetch_vazquez_rodriguez2019([force, ...])

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

fetch_mirchi2018([force, data_dir, verbose])

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

fetch_hansen_manynetworks([force, data_dir, ...])

Download files from Hansen et al., 2023, PLOS Biology.

fetch_hansen_receptors([force, data_dir, ...])

Download files from Hansen et al., 2022, Nature Neuroscience.

fetch_hansen_genescognition([force, ...])

Download files from Hansen et al., 2021, Nature Human Behaviour.

fetch_hansen_brainstemfc([force, data_dir, ...])

Download files from Hansen et al., 2024.

fetch_shafiei_megfmrimapping([force, ...])

Download files from Shafiei et al., 2022.

fetch_shafiei_megdynamics([force, data_dir, ...])

Download files from Shafiei et al., 2023.

fetch_suarez_mami([force, data_dir, verbose])

Download files from Suarez et al., 2022, eLife.

fetch_famous_gmat(dataset[, force, ...])

Download files from multi-species connectomes.

fetch_neurosynth()

Download Neurosynth data.

netneurotools.networks - Constructing networks

Functions for constucting networks.

To construct consensus networks

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.

To randomize networks

randmio_und(W, itr)

Optimized version of randmio_und.

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

Generate degree- and edge length-preserving surrogate connectomes.

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.

Convenient functions

binarize_network(network[, retain, keep_diag])

Keep top retain % of connections in network and binarizes.

threshold_network(network[, retain])

Keep top retain % of connections in network and binarizes.

netneurotools.plotting - Plotting brain data

Functions for making pretty plots and whatnot.

Pyvista

pv_plot_surface(vertex_data, template[, ...])

Plot surface data using PyVista.

PySurfer (deprecated)

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.

matplotlib

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

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

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

Plot data as heatmap with borders drawn around communities.

Fun color & colormap stuff

available_cmaps()

Return list of available colormaps in module.

netneurotools.metrics - Calculating graph metrics

Magics on networks.

Brain network metrics

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.

navigation_wu(nav_dist_mat, sc_mat)

Compute network navigation.

get_navigation_path_length(nav_paths, ...)

Get navigation path length from navigation results.

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.

path_transitivity(D)

Calculate path transitivity.

search_information(W, D[, has_memory])

Calculate search information.

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.

flow_graph(W[, r, t])

Calculate flow graph.

assortativity(W[, r])

Calculate assortativity.

matching_ind_und(W)

Calculate undirected matching index.

rich_feeder_peripheral(x, sc[, stat])

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

Network spreading

simulate_atrophy()

Simulate atrophy in a network.

Statistical network metrics

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.modularity - Calculating network modularity

Functions for working with network modularity.

match_cluster_labels(source, target)

Align cluster labels in source to those in target.

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".

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

Find consensus clustering labels from cluster solutions in assignments.

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.stats - General statistics functions

Functions for performing statistical operations.

Correlations

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

Compute correlation of matching columns in a and b.

weighted_pearsonr()

Calculate weighted Pearson correlation coefficient.

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

Generate random vectors that are correlated to approximately corr.

Permutation tests

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().

Regressions

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

Return residuals of regression equation from Y ~ X.

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

Return the dominance analysis statistics for multilinear regression.

netneurotools.spatial - Spatial statistics

Functions for handling spatial brain data.

Calculating spatial statistics

morans_i()

Calculate Moran's I for spatial autocorrelation.

local_morans_i()

Calculate local Moran's I for spatial autocorrelation.

netneurotools.interface - Interface for external tools

Functions for interfacing with common tools.

netneurotools.experimental - Functions in alpha stage

Functions in alpha stage.