BrainNetTest

BrainNetTest provides non-parametric hypothesis testing for populations of brain networks represented as graphs, following the L1-distance ANOVA framework of Fraiman and Fraiman (2018, doi:10.1038/s41598-018-23152-5).

The package includes:

Installation

# From CRAN
install.packages("BrainNetTest")

# Development version
# install.packages("remotes")
# remotes::install_github("mmaximiliano/BrainNetTest")
install.packages("BrainNetTest", repos = c('https://mmaximiliano.r-universe.dev', 'https://cloud.r-project.org'))

Quick example

library(BrainNetTest)

set.seed(1)
control <- generate_category_graphs(
  n_graphs = 20, n_nodes = 10, n_communities = 2,
  base_intra_prob = 0.8, base_inter_prob = 0.2, seed = 1)
patient <- generate_category_graphs(
  n_graphs = 20, n_nodes = 10, n_communities = 2,
  base_intra_prob = 0.6, base_inter_prob = 0.4, seed = 2)

populations <- list(Control = control, Patient = patient)

# Do the populations differ at all? Statistic T and its permutation p-value
global_test(populations, n_permutations = 1000, seed = 42)

# Which edges are responsible? Global test plus critical-edge identification
result <- identify_critical_links(
  populations, alpha = 0.05, method = "fisher",
  n_permutations = 1000, seed = 42)

result                  # compact report
summary(result)         # settings and node-level ranking
head(result$critical_edges)
get_critical_nodes(result)

References

Fraiman, D. and Fraiman, R. (2018) An ANOVA approach for statistical comparisons of brain networks. Scientific Reports, 8, 4746. https://doi.org/10.1038/s41598-018-23152-5

License

MIT (c) 2026 Maximiliano Martino, Daniel Fraiman.