Abstract
Functional Magnetic Resonance Imaging (fMRI) has traditionally focused on gray matter, often disregarding white matter as a source of noise. However, recent research indicates that white matter exhibits directional functional signals aligned with its structural pathways. The High Angular Resolution Functional Imaging (HARFI) pipeline was developed to map these signals using functional orientation distributions (FODs). This paper details the effort to harden and containerize the HARFI pipeline, addressing critical bugs and accessibility barriers. By wrapping the MATLAB-based workflow into a Singularity container, we provide a reproducible, license-free tool for the neuroimaging community.
Introduction
While gray matter is the primary focus of most functional studies, the white matter "wiring" of the brain contains meaningful, anisotropic functional signals. The HARFI pipeline characterizes these signals by calculating directional correlations and fitting them to spherical harmonic models. Despite its utility, the original implementation suffered from "research code" syndrome: high technical complexity, dependency on paid MATLAB licenses, and subtle but impactful bugs. Specifically, a unit mismatch in the integration radius and a commented-out detrending step limited the tool's reliability and adoption. This work aims to resolve these issues through rigorous code correction and containerization.
Methods
Code Correction and Hardening
The reproduction effort began with identifying and fixing two primary issues in the source repository. First, a mismatch between the published methodology (integration radius in millimeters) and the code implementation (voxels) was corrected. Second, a critical detrending segment that had been accidentally disabled in the version control system was restored.
Containerization Workflow
To ensure cross-platform compatibility and remove the requirement for a MATLAB license, the authors employed a multi-step process:
- Standalone Compilation: The scripts were converted into a standalone executable using the MATLAB Compiler (
mcc), allowing them to run on the free MATLAB Runtime (MCR). - Singularity Packaging: The executable, along with necessary libraries, environment variables, and atlas files, was packaged into a Singularity container. This ensures identical execution across various high-performance computing (HPC) environments.
The HARFI Pipeline
The containerized pipeline follows a structured workflow. After receiving preprocessed 4D fMRI data, it performs temporal detrending and band-pass filtering (0.015–0.1 Hz). The signal is then sampled along 60 unit vectors and integrated over a 9mm radius. Finally, spherical harmonic fitting produces FODs, which are exported in a format compatible with MRtrix3 for visualization and tractography.
Datasets and Validation
The pipeline's robustness was validated across six diverse datasets with varying spatial resolutions (2mm to 4mm) and repetition times (TR):
- BLSA: Baltimore Longitudinal Study of Aging.
- OpenNeuro Benchmarks: Including studies on animated caricatures, object recognition (THINGS-fMRI), motor tasks, neuroCOVID, and changepoint detection.
Results and Key Insights
The containerized pipeline successfully reproduced the outputs of the original authors' reference data. Qualitative analysis demonstrates that the tool effectively captures complex brain features, such as crossing fiber patterns and asymmetric functional distributions.
Key insights from this effort include:
- White Matter Anisotropy: The results reinforce that white matter functional signals mirror underlying physical fiber bundles.
- Importance of Software Hardening: The discovery of the "silent" detrending bug highlights how version-control errors can undermine scientific tools without rigorous reproduction efforts.
- Interoperability: By outputting MRtrix-compatible files, the pipeline bridges the gap between functional imaging and standard structural tractography tools.
Discussion and Future Work
While the containerized HARFI pipeline significantly lowers the barrier to entry for white matter functional research, some limitations remain. The pipeline currently requires users to perform their own initial preprocessing (e.g., motion correction). Furthermore, it does not yet include built-in tools for downstream quantitative statistical analysis. Future work will focus on integrating these end-to-end capabilities and developing standardized metrics for the exported spherical harmonic coefficients to further streamline the research workflow.
Summary updated