Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MegaTrack (MGTK)

MegaTrack is a framework for the anatomically accurate and time-efficient virtual dissection and analysis of large-scale diffusion-MRI tractography datasets. It is designed to bring the anatomical accuracy of expert manual dissection to population-scale studies, where per-subject manual work would otherwise be impractical.

The framework rests on four steps:

  1. Normalisation of each subject's streamlines to a common template space.
  2. MegaTrack dataset generation, concatenating the normalised tractograms into a single "mega" tractogram, optionally with demographic or anatomical pre-filtering and fibre compression for very large cohorts. Every streamline is tagged with a unique Subject + Streamline ID (SSID).
  3. Simultaneous supervised dissection in template space, using any combination of manual ROIs (AND / NOT / EITHER_END), atlas-based subcortical ROIs, cortical ROIs (e.g. from FreeSurfer), or geometric constraints (length, shape, U-fibres).
  4. Native-space recovery of each subject's dissected tract via direct SSID lookup, without inverse spatial transforms, followed by extraction of tract-specific scalar metrics (FA, MD, RD, AD, HMOA, ...).

The framework is registration-agnostic: any pipeline producing an affine plus a warp can be plugged in (FSL, ANTs, TORTOISE, DTI-TK have all been used in practice). Combined with SSID tagging, this decouples the space in which dissection is performed from the space in which analysis is run, and supports a wide range of downstream applications: case-control group comparison, longitudinal designs, custom atlas generation filtered by demographics, streamline-level lesion-disconnection mapping, and the curation of expert-vetted training data for machine-learning approaches.


Status: initial release for peer review

This is an initial code release accompanying the MegaTrack manuscript currently under journal review (2026). It is intended to enable reviewers and early users to reproduce and inspect the method. It is not the final polished release; documentation, examples, and packaging will be refined and a final tagged release will follow paper acceptance.

During peer review, please contact the corresponding author (flavio.dellacqua@kcl.ac.uk) for any reproducibility queries or installation issues.

The accompanying manual (doc/Megatrack_manual_0.2.pdf) is also a working draft and will be replaced with the consolidated user guide for the final release.

Important — manual vs. this release: the dependencies listed in the manual do not match this initial release. The manual assumes the full nbltools package on PATH / MATLABPATH; this release instead bundles the relevant subset of internal NBL utilities under utils/, so nbltools is not required to run the core MegaTrack pipeline. Refer to the Requirements section below as the authoritative dependency list for this release. The optional gzip_niis cleanup step mentioned in the manual (which is part of nbltools) can be replaced with a standard find ... -name "*.nii" -exec gzip {} \;.


Key features

  • Manual-dissection accuracy at population scale. Tracts are dissected once in template space and recovered in each subject's native space.
  • SSID-based native-space recovery. Each streamline carries a unique Subject + Streamline ID, so per-subject tracts are reconstructed by direct lookup, without inverse spatial transforms.
  • Registration-agnostic. Any pipeline producing an affine plus a warp can be used upstream (FSL, ANTs, TORTOISE, DTI-TK). An ANTs driver is provided out of the box.
  • Flexible ROIs. Manual AND / NOT / EITHER_END ROIs, atlas-based subcortical ROIs, cortical ROIs (e.g. from FreeSurfer), and geometric constraints (length, shape, U-fibres) can be combined freely.
  • Symmetric dissection. Optional bias-free simultaneous dissection of both hemispheres on a symmetric template (see manual).
  • Scalable. Demographic and anatomical pre-filtering at concatenation, plus optional Douglas-Peucker fibre compression, keep hundred-to-thousand subject cohorts tractable.
  • Validated applications. High agreement with expert manual dissection (weighted Dice>0.95 for tract overlap, R²>0.9 for tract-specific metrics), with improved inter-rater reliability and longitudinal reproducibility; replication of known group differences in a motor neuron disease cohort (corticospinal tract, p=0.001); custom atlas generation (140-subject HARDI dataset, >5000 dissected tracts); novel streamline-level lesion-disconnection mapping for stroke and other focal lesions.

Online companion tool

A companion web application is available at https://megatrackatlas.org, providing interactive visualisation of the 140-subject MegaTrack atlas, demographic filtering, and online tract-lesion disconnection analysis. The online tool exposes pre-built atlases and a subset of analyses to users who do not need to run the local pipeline; this repository contains the offline framework used to build MegaTrack datasets and atlases.


Requirements

Bundled in this repository (under utils/)

The relevant subset of internal NBL utilities and third-party MATLAB dependencies needed by the core MegaTrack functions is included so that the pipeline runs without pulling additional NBL software:

  • utils/nifti_IO/ — NIfTI read/write helpers (NBL_load_nii, NBL_niftireader, etc.).
  • utils/Tracts/.trk I/O, filtering, and analysis primitives.
  • utils/utils/ — small helpers (path handling, parallel pool setup, ANTs ↔ MGTK transform conversion, registration wrapper).
  • utils/3rd_parties/NIFTI_toolbox/ — Jimmy Shen's MATLAB NIfTI toolbox.
  • utils/3rd_parties/dpsimplify/ — Douglas-Peucker line simplification.

External tools (must be installed separately)

Tool Purpose Required
MATLAB Runs the mt_*.m core dissection / analysis routines yes
ANTs Subject-to-template registration (MGTK_normalise_ANTs.sh) yes
c3d Image manipulation used by registration / ROI prep yes
TrackVis Interactive ROI definition for dissections yes
StarTrack Recommended upstream tool for tractography and diffusion-map generation (FA, MD, RD, AD, HMOA). MegaTrack expects .trk files and scalar maps in a layout compatible with StarTrack output. recommended

Other tractography software can be used provided that the .trk files and scalar maps are spatially aligned and use a header convention compatible with StarTrack's output (see Note 1 in the manual, step 1a).


Installation

  1. Clone this repository.
  2. Add the repository and its subdirectories to your shell PATH and to MATLAB's MATLABPATH. The manual (page 1) gives ready-to-paste ~/.bashrc snippets for typical NBL machines.
  3. Make sure ANTs, c3d, MATLAB, and TrackVis are installed and reachable on PATH.

See doc/Megatrack_manual_0.2.pdf for a full walkthrough including data layout, command-line options, and a worked example.


Pipeline at a glance

The full pipeline is documented step by step in the manual. The user-facing entry points are bash drivers that wrap the MATLAB core:

Stage Command Purpose
0 MGTK_normalise_ANTs.sh Compute per-subject native → template transforms with ANTs.
1 mgtk_1_norm Apply transforms to each subject's .trk file.
1b mgtk_1_norm_map Apply transforms to scalar maps (FA, MD, ...).
2 mgtk_2_create Concatenate all subjects into the MegaTrack tractogram, optionally with a pre-filter and/or symmetric (-s) flipping.
3 mgtk_3_dissect Apply AND / NOT / EITHER_END ROIs and project the dissected streamlines back to each subject in native space.
4 mgtk_4_analyse Extract per-subject, per-tract statistics for the requested scalar maps.
5 mgtk_5_fullprob Optional: full-probability mapping stage.

A symmetric-dissection workflow (-s flag) is provided to dissect both hemispheres simultaneously without left/right bias; see the manual.


Repository layout

mgtk/
├── README.md                    this file
├── doc/
│   └── Megatrack_manual_0.2.pdf user manual (draft)
├── MGTK_normalise_ANTs.sh       stage-0 registration driver
├── HCP_transf_2_mgtk.sh         helper for HCP-style transform import
├── mgtk_1_norm                  stage-1 bash driver (calls mt_1_normalize.m)
├── mgtk_1_norm_map              stage-1b map normalisation
├── mgtk_2_create                stage-2 bash driver (calls mt_2_create.m)
├── mgtk_3_dissect               stage-3 bash driver (calls mt_3_filter.m)
├── mgtk_4_analyse               stage-4 bash driver (calls mt_4_analysis.m)
├── mgtk_5_fullprob              stage-5 bash driver
├── mgtk_post_ras2las            post-processing utility (RAS ↔ LAS)
├── mt_*.m                       MATLAB core routines
└── utils/                       bundled NBL + third-party MATLAB dependencies
    ├── nifti_IO/
    ├── Tracts/
    ├── utils/
    └── 3rd_parties/
        ├── NIFTI_toolbox/
        └── dpsimplify/

Citation

If you use MegaTrack in your work, please cite:

Dell'Acqua F., Beyh A., Stones R., Barrett R.L., De Santiago Requejo F., Laguna P.L., Lacerda L.M., Davison C., Leslie A., Howells H., Goldstein L.H., Williams S.C., Catani M. (2025). MegaTrack: a framework for the anatomically accurate and time-efficient virtual dissection and analysis of large-scale tractography datasets. bioRxiv preprint. doi: 10.1101/2025.05.27.656234

A final citation including the journal DOI will be added on publication.


Acknowledgements

This release vendors the following third-party MATLAB code under utils/3rd_parties/:

  • NIFTI toolbox (Jimmy Shen) for NIfTI I/O.
  • dpsimplify for Douglas-Peucker line simplification.

Please retain the original authors' licences and credits when redistributing.


Contact and issues

For installation, bug reports, or reproducibility queries during peer review:


Licence

MegaTrack is released under the GNU General Public License v3.0 (GPL-3.0). The full licence text is in the LICENSE file at the root of this repository.

In short: you may use, modify, and redistribute MegaTrack freely, including for academic and commercial research, provided that any derivative work that you distribute is also released under GPL-3.0 with source code available, and that the original copyright and licence notices are preserved.

Bundled third-party components under utils/3rd_parties/ (NIFTI toolbox, dpsimplify) retain their original authors' licences; please consult the respective subdirectories.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages