Pipeline
The complete HINEC processing workflow — from raw NIfTI diffusion data to reconstructed fiber tracts.
Overview
The HINEC pipeline processes raw diffusion-weighted MRI data through four major stages: preprocessing, tensor estimation, tractography, and visualization. Each stage is mathematically grounded and designed for reproducibility.
runhinec.m (quick start), main.m (core processing), runTractography.m (fiber tracking), and visualizeTractography.m (visualization).Preprocessing Pipeline
The preprocessing pipeline (nim_preprocessing.m) implements a 10-step process with comprehensive T1 integration, addressing common artifacts in diffusion MRI data.
B0 Extraction
nim_preprocessing.mExtract the first volume (b=0) as the non-diffusion-weighted reference image.
Brain Extraction
nim_preprocessing.mCreate a brain mask using T1-enhanced extraction (preferred) or DWI-only fallback (BET with f=0.3).
Denoising
nim_preprocessing.mOptional MP-PCA denoising or Gaussian smoothing to reduce thermal noise.
Field Map Correction
nim_preprocessing.mFUGUE-based susceptibility distortion correction using B0 field maps.
Motion Correction
nim_preprocessing.mRigid body motion correction with b-vector rotation to match corrected orientations.
Eddy Current Correction
nim_preprocessing.mFSL eddy correction with automatic fallback to eddy_correct for datasets without acquisition parameters.
White Matter Segmentation
nim_preprocessing.mCreate optimized seeding masks from a preliminary DTI calculation, using FA thresholding and morphological erosion.
T1 Registration
nim_preprocessing.mWhen T1 data is available, compute linear and nonlinear registrations to MNI space using FLIRT and FNIRT.
Atlas Registration
nim_preprocessing.mTransform brain atlas from MNI space to DWI space using the T1-guided composite registration chain, or direct FLIRT fallback.
Finalization
nim_preprocessing.mCopy processed data to standard locations, run quality validation, generate processing reports, and clean up temporary files.
Diffusion Tensor Estimation
After preprocessing, HINEC estimates the diffusion tensor at every voxel using SPD-constrained log-linear fitting. The function nim_dt_spd computes the full 3×3 symmetric tensor, then nim_eig decomposes it into eigenvectors and eigenvalues.
% Sequential processing in main.mnim = nim_dt_spd(nim); % SPD-constrained tensor estimationnim = nim_eig(nim); % Eigendecompositionnim = nim_fa(nim); % Fractional anisotropyFA Computation
Fractional anisotropy is computed from the eigenvalues at each voxel. This scalar map serves dual purposes: it provides a clinical measure of white matter integrity, and it defines the seeding mask and termination criterion for tractography.
A normalized measure of diffusion directionality, ranging from 0 (isotropic) to 1 (perfectly linear).
Where λ̄ = (λ₁ + λ₂ + λ₃)/3. Implemented in nim_fa.m.
Parcellation
HINEC registers a brain atlas (JHU, AAL, or Desikan) from MNI standard space to the subject's native DWI space. The preferred method uses a T1-guided composite transformation chain:
If T1 data is unavailable, a direct FLIRT registration from MNI to DWI space is used as fallback.
Data Flow
Raw DWI → Preprocessing → DTI Processing → Tractography → Visualization ↓ ↓ ↓ ↓ ↓Field Maps → Distortion Corr → FA Calculation → WM Seeding → Track QualityMotion → Motion Corr → Eigenvectors → Boundary Prot → StatisticsEddy → Eddy Corr → Parcellation → Track Valid → Reports.mat file already exists, main() skips processing. Delete the output file to force a fresh run.