Tractography
Deterministic fiber tracking — from seed points to reconstructed white matter pathways.
Overview
HINEC reconstructs white matter pathways by following the primary eigenvector of the diffusion tensor from seed points throughout the brain. Starting from locations in white matter, the algorithm takes small steps in the direction of maximum water diffusion, building streamlines that approximate fiber tracts. Each streamline grows bidirectionally from its seed point until a termination criterion is met.
Tracking Algorithms
Standard FACT (Euler Integration)
The simplest deterministic tracking method. At each position, the algorithm steps forward along the principal eigenvector by a fixed step size. Fast but can accumulate integration error over long tracks.
Step forward by Δs in the direction of the primary eigenvector e₁ at the current position.
YAML: algorithm: 'standard', integration_order: 1. Default step_size: 0.5 voxels.
HINEC High-Order (RK4)
Fourth-order Runge-Kutta integration evaluates the eigenvector field at four intermediate points per step, producing smoother and more accurate streamlines than Euler integration.
Adaptive RKF45
Runge-Kutta-Fehlberg with adaptive step size control. The algorithm automatically adjusts the step size based on local error estimates — taking smaller steps in regions of high curvature and larger steps in straight sections. This provides the highest accuracy with optimal computational efficiency.
interp_method: 'trilinear') for sub-voxel eigenvector sampling.Seed Generation
HINEC uses a hierarchical masking strategy to determine where to place seed points:
- Primary: White matter mask from the preprocessing pipeline
- Fallback 1: FA-based white matter mask (FA > 0.2, morphologically eroded)
- Fallback 2: Eroded brain mask as last resort
% Seed density: number of seeds per voxel% density = 1: one seed at voxel center% density = 5: five randomly distributed seeds per voxel (default)for i = 1:size(base_seeds, 1) for j = 1:density offset = (rand(1, 3) - 0.5) * 0.8; seed_points(idx, :) = base_seeds(i, :) + offset; idx = idx + 1; endendBidirectional Tracking
From each seed point, HINEC tracks in both the forward (+1) and backward (-1) directions along the eigenvector. The two half-tracks are concatenated to form a complete streamline. This doubles coverage compared to unidirectional tracking.
for direction = [-1, 1] track = track_fiber_standard_optimized(nim, seed, direction, options, cos_angle_thresh); if size(track, 1) > 1 track_length_mm = sum(vecnorm(diff(track), 2, 2)); if track_length_mm >= options.min_length tracks{track_count} = track; end endendDirection Interpolation
For sub-voxel accuracy, HINEC uses trilinear interpolation of pre-computed eigenvector components. The critical optimization is separating the 5D eigenvector array into three 3D component arrays before tracking begins, providing a ~40% speedup.
% Pre-compute eigenvector components (KEY OPTIMIZATION)nim.v1_x = squeeze(nim.evec(:,:,:,1,1)); % X componentnim.v1_y = squeeze(nim.evec(:,:,:,2,1)); % Y componentnim.v1_z = squeeze(nim.evec(:,:,:,3,1)); % Z component % During tracking: trilinear interpolation of each componentx_comp = interp3(nim.v1_x, pos(2), pos(1), pos(3), 'linear', 0);y_comp = interp3(nim.v1_y, pos(2), pos(1), pos(3), 'linear', 0);z_comp = interp3(nim.v1_z, pos(2), pos(1), pos(3), 'linear', 0);Termination Criteria
Tracking terminates when any of the following conditions is met:
| Criterion | Default | Condition |
|---|---|---|
| Low anisotropy | 0.15 | FA(r) < termination_fa |
| Sharp curvature | 35° | Angle between successive steps > angle_thresh |
| Maximum length | 1000 steps | Step count exceeds max_steps |
| Boundary exit | — | Position leaves brain mask or image bounds |
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| algorithm | string | No | 'standard' | 'standard' (FACT) or 'hinec' (high-order) |
| integration_order | int | No | 1 | 1 (Euler), 2 (RK2), 4 (RK4), 5 (RKF45) |
| interp_method | string | No | 'none' | 'trilinear' or 'none' |
| step_size | float | No | 0.5 | Step size in voxel units |
| seed_density | int | No | 5 | Seeds per voxel (1-8 recommended) |
| termination_fa | float | No | 0.15 | FA threshold for termination |
| angle_thresh | float | No | 35 | Maximum curvature angle (degrees) |
| max_steps | int | No | 1000 | Maximum integration steps |
| min_length | float | No | 35 | Minimum track length (mm) |
| act_enabled | bool | No | false | Anatomically constrained tractography |
Output Structure
Results are saved to tractography_results/ with timestamped filenames:
tractography_results/└── tracks_standard_2025-01-15_14_30_22.mat ├── tracks % Cell array of Nx3 fiber coordinates ├── options % Parameters used ├── elapsed_time % Computation time (seconds) └── algorithm % Algorithm name string