NOTE: Currently under development.
This framework reconstructs high-resolution, motion-corrected 3D diffusion volumes from multiple low-resolution, motion-corrupted 2D stacks of fetal non-human primate (NHP) MRI data. It integrates state-of-the-art tools for distortion correction, motion correction, slice-to-volume reconstruction (SVR), and higher-order diffusion modeling to produce high-quality data suitable for advanced analysis, such as Fiber Orientation Distribution (FOD) for tractography.
The pipeline is organized into three main stages:
-
Preprocessing: Each individual 2D diffusion stack is independently processed. This includes denoising, Gibbs ringing correction, brain extraction, bias field correction, and comprehensive correction for eddy currents, subject motion, and susceptibility-induced distortions using FSL
eddywith either TOPUP- or T2-based field map estimation. -
Super-Resolution & Alignment:
- All preprocessed stacks are rigidly registered to a common reference stack.
- Slice-to-Volume Reconstruction (SVR) is used to generate a single high-resolution, motion-corrected
b=0volume. - The SVR volume is aligned to a high-resolution T2-weighted anatomical template.
- Finally, the full diffusion-weighted signal is reconstructed into the T2 template space at high resolution using an iterative method that models the signal with Spherical Harmonics.
-
Diffusion Modelling: The final high-resolution 4D DWI volume is used to:
- Fit a diffusion tensor model to derive metrics like Fractional Anisotropy (FA) and Mean Diffusivity (MD).
- Estimate Fiber Orientation Distributions (FODs) using Constrained Spherical Deconvolution (CSD) to resolve complex fiber crossings.
This pipeline relies on several external software packages. You must have them installed and available in your system's PATH.
- FSL (v6.0 or later): For
flirt,eddy,topup,fnirt, and other utilities. - MRtrix3: For denoising, Gibbs correction, tensor and FOD modeling (
dwidenoise,mrdegibbs,dwi2tensor,dwi2fod, etc.). - ANTs: For N4 bias field correction and mask propagation (
N4BiasFieldCorrection,antsApplyTransforms). - Singularity / Apptainer: Required to run containerized versions of MIRTK and SVRTK.
- MIRTK (
mirtk.sif): Used for converting transformation formats. - SVRTK (
svrtk.sif): The core toolkit for slice-to-volume reconstruction (mirtk reconstruct,mirtk reconstructDWI).
- MIRTK (
- Python 3: With libraries such as
nibabelandnumpy.
The pipeline assumes that brain masks have been generated beforehand. You can find the weights for our nnU-Net model here.
The pipeline is designed to work with data organized in a BIDS-like structure.
/path/to/project/
├── rawdata/
│ └── sub-<ID>/
| └── ses-<ID>/
| ├── dwi/
| | ├── sub-..._acq-ax_run-1_dwi.nii.gz
| | ├── sub-..._acq-ax_run-1_dwi.bval
| | ├── sub-..._acq-ax_run-1_dwi.bvec
| | ├── sub-..._acq-ax_run-1_dwi.json
| | └──... (other acquisitions/runs) ...
| └── fmap/
| ├── sub-..._acq-ax_run-1_epi.nii.gz
| ├── sub-..._acq-ax_run-1_epi.json
| └── ...
│
└── derivatives/
├── T2_recon/ (High-resolution T2s and masks)
| └── sub-<ID>/
| └── ses-<ID>/
| ├── T2_recon.nii.gz
| └── T2_recon_mask.nii.gz
|
├── manual_masks/ (brain masks for DWI stacks)
| └── sub-<ID>/
| └── ses-<ID>/
| ├── acq-ax_run-1/
| │ └── mask.nii.gz
| └── ... (masks for each acq) ...
|
└── reconstruction/ (Output of this pipeline)
└── sub-<ID>/
└── ses-<ID>/
├── 01_prepared_stacks/
├── 02_preprocessed_stacks/
... (and so on) ...
The entire pipeline is orchestrated by the master script 00_run_pipeline.sh.
-
Clone the Repository:
git clone https://github.com/MecaLab/Babofet_DWI.git cd Babofet_DWI -
Configure the Master Script: Open
00_run_pipeline.shand edit the USER CONFIGURATION section:- Set the correct paths for
BIDS_ROOT_DIRand the Singularity image files (SVRTK_SIF_PATH,MIRTK_SIF_PATH). - Adjust reconstruction parameters (
SVR_RESOLUTION,DWI_RECON_RESOLUTION, etc.) as needed. - Ensure the logic for finding the
T2_TEMPLATE_IMAGEpoints to your high-resolution anatomical data.
- Set the correct paths for
-
Run the Pipeline: Execute the master script from the command line, providing the subject and session IDs as arguments:
./00_run_pipeline.sh <subject_id> <session_id>
For example:
./00_run_pipeline.sh Aziza ses-01
The script will create an output directory (
derivatives/reconstruction/...) and run all processing steps sequentially.
The pipeline is composed of modular scripts, each performing a specific task:
01_prepare_data.sh: Copies raw DWI data from the BIDSrawdatadirectory into thederivativestree for processing.02_preprocess_stacks.sh: The main per-stack preprocessing script. It performs denoising, degibbsing, distortion correction, bias correction, and eddy correction.03_register_stacks.sh: Registers all preprocessedb=1000mean images to a designated reference stack using FSLflirt.04a_reconstruct_b0.sh: Usesmirtk reconstructto create a single high-resolution, motion-correctedb=0volume from all stacks.04b_reconstruct_b1000.sh: (Optional but recommended) Reconstructs a high-resolution meanb=1000image, which can be useful for registration.05_align_to_t2.sh: Aligns the reconstructedb=0volume to the subject's high-resolution T2 anatomical image. This defines the final space for the DWI reconstruction.06_reconstruct_dwi.sh: The core reconstruction step. Usesmirtk reconstructDWIto reconstruct the full diffusion signal in the T2 template space.07_fit_tensor.sh: Fits the diffusion tensor and CSD models to the final 4D DWI volume using MRtrix3.08_mask_propagation.sh: Propagates anatomical tissue segmentations from the T2 space into the final DWI space for quantitative analysis.99_quality_control.sh: Generates a series of "lightbox" images (e.g., FA, MD, color-FA maps) for quality control of the final outputs.
