Mathematical Foundations
The physical principles and mathematical framework behind diffusion MRI, tensor estimation, and fiber tracking.
What Diffusion MRI Measures
Diffusion MRI does not directly image the brain's wiring. Instead, it measures how water molecules move through tissue. In unrestricted fluid, water diffuses equally in all directions — this is called isotropic diffusion. But in highly organized tissue such as white matter, cellular membranes and myelin sheaths constrain water to move preferentially along the fiber axis. This directional bias — anisotropic diffusion — is the physical signal that HINEC exploits.
The fundamental signal model for diffusion MRI. Each measurement applies a magnetic gradient in direction g with strength b, attenuating the signal proportionally to diffusion along that direction.
S₀ is the non-diffusion-weighted signal, b is the b-value (s/mm²), g is the unit gradient direction, and D is the 3×3 diffusion tensor.
The Diffusion Tensor Model
At each voxel, the local diffusion profile is modeled as a 3×3 symmetric positive definite matrix — the diffusion tensor. This tensor captures both the magnitude and directional preference of water diffusion. Because the tensor is symmetric, it has six independent components.
A symmetric 3×3 matrix encoding the diffusion profile at each voxel. The diagonal elements represent diffusion along each axis; off-diagonal elements capture cross-axis correlation.
The constraint D ∈ S₊³ means the tensor must be symmetric positive definite — all eigenvalues must be strictly positive.
SPD-Constrained Tensor Estimation
HINEC estimates the diffusion tensor from multiple gradient directions using log-linear fitting with a symmetric positive definite (SPD) constraint. Taking the logarithm of the Stejskal-Tanner equation linearizes the estimation problem.
By taking the natural logarithm of the signal ratio, tensor estimation becomes a linear least-squares problem.
Implemented in nim_dt_spd.m. The SPD constraint ensures all eigenvalues λ₁ ≥ λ₂ ≥ λ₃ > 0, preventing physically meaningless negative diffusivities.
Eigendecomposition
The diffusion tensor is decomposed into its eigenvectors and eigenvalues. The primary eigenvector v₁ points along the direction of maximum diffusion — the estimated fiber direction. The eigenvalues measure diffusion magnitude along each axis.
The tensor factors into a rotation matrix V (whose columns are the fiber directions) and a diagonal matrix of eigenvalues Λ.
v₁ is the primary eigenvector (fiber direction), v₂ and v₃ span the perpendicular plane. Eigenvalues are ordered λ₁ ≥ λ₂ ≥ λ₃ > 0.
Fractional Anisotropy
Fractional anisotropy (FA) is a scalar measure between 0 and 1 that summarizes how strongly diffusion follows one main direction. An FA of 0 means perfectly isotropic diffusion (equal in all directions); an FA approaching 1 indicates highly directional diffusion, typically associated with well-organized white matter.
FA summarizes how strongly diffusion follows one main direction. Higher FA often indicates more directionally organized white matter.
Where λ̄ = (λ₁ + λ₂ + λ₃)/3 is the mean diffusivity. Computed in nim_fa.m.
Other Tensor Metrics
Beyond FA, the eigenvalues yield additional scalar measures that characterize different aspects of the local tissue microstructure.
The average diffusion across all directions. Elevated MD can indicate edema or tissue degeneration.
Diffusion along the primary fiber direction. Reduced AD may indicate axonal injury.
Average diffusion perpendicular to the fiber direction. Elevated RD may indicate demyelination.
Tractography Integration
Tractography reconstructs white matter pathways by numerically integrating along the primary eigenvector field. Starting from a seed point, the algorithm takes small steps in the direction indicated by the local diffusion tensor, building a streamline that approximates a fiber tract.
The simplest tracking scheme: at each position, step forward along the principal eigenvector by a fixed step size.
r is the current position, Δs is the step size (default 0.5 mm), and e₁ is the primary eigenvector interpolated at position rᵢ.
Termination Criteria
Streamline tracking stops when the algorithm detects it has left white matter or entered a region of unreliable directional information:
- Low anisotropy: FA(r) < 0.15 — the tensor no longer has a clear preferred direction
- Sharp curvature: angle between successive steps exceeds 35° — the track has turned too sharply to be biologically plausible
- Maximum length: step count exceeds 1000 — prevents infinite tracking
- Boundary exit: the track has left the brain mask
Track Quality Metrics
The total Euclidean length of a reconstructed streamline.
Tracks shorter than min_length (default 35 mm) are discarded as likely noise.
A composite metric combining mean FA along the track with a curvature penalty.
The minimum distance from a track point to the tissue boundary. Used for erosion-based boundary protection.
Tracking terminates if d_boundary(r) falls below a safety threshold.
Field Map Correction Theory
Diffusion MRI is sensitive to B₀ field inhomogeneities, which cause geometric distortions along the phase-encoding direction. HINEC corrects these using field maps when available.
The actual spatial frequency differs from the nominal frequency by an amount proportional to the field inhomogeneity.
γ = 42.58 MHz/T (gyromagnetic ratio), T_E = echo time, ΔB₀ = B₀ field inhomogeneity in Tesla.
Voxel positions are shifted along the phase-encoding direction proportionally to the local field map value and dwell time.
t_dwell is the effective echo spacing (typically 0.58 ms), n̂_PE is the phase encoding direction unit vector.
