PHOTONAI-Graph - A Python Toolbox for Graph Machine Learning

Jan Ernsting, Vincent Holstein, Nils R. Winter, Kelvin Sarink, Ramona Leenings, Marius Gruber, Jonathan Repple, Benjamin Risse, Udo Dannlowski, Tim HahnmedRxiv 2023

Abstract

Graph data is an omnipresent way to represent information in machine learning. Especially, in neuroscience research, data from Diffusion-Tensor Imaging (DTI) and functional Magnetic Resonance Imaging (fMRI) is commonly represented as graphs. Exploiting the graph structure of these modalities using graph-specific machine learning applications is currently hampered by the lack of easy-to-use software. PHOTONAI Graph aims to close the gap between domain experts of machine learning, graph experts and neuroscientists. Leveraging the rapid machine learning model development features of the Python machine learning API PHOTONAI, PHOTONAI Graph enables the design, optimization, and evaluation of reliable graph machine learning models for practitioners. As such, it provides easy access to custom graph machine learning pipelines including, hyperparameter optimization and algorithm evaluation ensuring reproducibility and valid performance estimates. Integrating established algorithms such as graph neural networks, graph embeddings and graph kernels, it allows researchers without significant coding experience to build and optimize complex graph machine learning models within a few lines of code. We showcase the versatility of this toolbox by building pipelines for both resting–state fMRI and DTI data in the hope that it will increase the adoption of graph-specific machine learning algorithms in neuroscience research.

Introduction

In neuroscience, the brain is naturally represented as a "connectome"—a graph where regions are nodes and neural pathways are edges. While Graph Machine Learning (GML) offers powerful tools for analyzing these structures, its adoption is hindered by an "accessibility gap." Current neuroimaging toolboxes excel at basic graph measures but lack advanced ML capabilities, while state-of-the-art GML libraries (e.g., DGL, PyG) require significant programming expertise.

PHOTONAI-Graph addresses this by providing a high-level, scikit-learn-compatible interface that automates the "plumbing" of GML. It allows researchers to build, optimize, and evaluate end-to-end pipelines—from raw connectivity matrices to Graph Neural Networks (GNNs)—using a low-code approach.

Methods and Architecture

PHOTONAI-Graph is an extension of the PHOTONAI ecosystem, focusing on rapid development and rigorous evaluation. The toolbox is organized into several core functional modules that can be chained into a pipeline.

The PHOTONAI-Graph architecture and workflow, illustrating the path from connectivity matrices to machine learning outputs.

The core modules include:

  • Graph Constructors: Transforms dense connectivity matrices into sparse adjacency matrices via thresholding, k-nearest neighbors, or random walks.
  • Graph Measures & Controllability: Implements classical metrics like centrality and density alongside network controllability features.
  • Graph Embeddings & Kernels: Integrates GEM and GraKeL for dimensionality reduction and similarity measures.
  • Graph Neural Networks (GNNs): Wraps six GNN architectures (via DGL and PyTorch), managing training and message-passing internally.
  • Automation: Supports nested cross-validation and hyperparameter optimization to ensure reliable performance estimates.

Evaluation and Results

The toolbox was validated using two large-scale neuroimaging datasets: 10Kin1Day (DTI, N > 8,000) and the Human Connectome Project Young Adult (HCP-YA) (rs-fMRI, N > 1,000).

The authors demonstrated three proof-of-concept analyses:

  1. Sex Prediction (DTI): Using an SVM-based pipeline on 10Kin1Day, achieving an accuracy of 0.642 ± 0.024.
  2. Sex Prediction (fMRI): Using a GCN on HCP-YA, achieving an accuracy of 0.749 ± 0.026.
  3. Grip Strength Prediction (fMRI): A regression task on HCP-YA, achieving a Pearson correlation of 0.361 ± 0.068.
Example pipeline for sex prediction using fMRI data from the HCP-YA dataset, showing the Graph Convolutional Network (GCN) configuration and resulting performance metrics.

Discussion and Conclusion

PHOTONAI-Graph significantly lowers the barrier to entry for domain experts. For instance, a complete sex-prediction pipeline can be implemented in just 43 lines of code. The toolbox is modality-agnostic, handling automatic format conversions between networkx, numpy, scipy, and dgl. By enforcing best practices like nested cross-validation, it mitigates common pitfalls like data leakage.

While the current version focuses on whole-graph classification and regression, future work includes adding a graphical user interface (GUI), expanding to node-level classification and link prediction tasks, and further optimizing scalability for massive single graphs.

Summary updated

BibTeX
@misc{ernsting2023photonai,
  author = {Jan Ernsting and Vincent Holstein and Nils R. Winter and Kelvin Sarink and Ramona Leenings and Marius Gruber and Jonathan Repple and Benjamin Risse and Udo Dannlowski and Tim Hahn},
  title = {{PHOTONAI-Graph - A Python Toolbox for Graph Machine Learning}},
  year = {2023},
  doi = {10.1101/2023.06.22.23291748},
  howpublished = {medRxiv},
}
Figure