Signal rotational invariants (SH)

TMI’s -SH mode estimates signal rotational invariants directly from a spherical harmonic (SH) representation of the diffusion signal. It runs independently of microstructure model fitting, with no SMI priors, training, or parameter regression. A single diffusion shell is supported, including acquisitions without b=0.

Table of contents

  1. Quick start
  2. Outputs
  3. Choose a fitting order for each shell
  4. Signal normalization
  5. SH fitting and noise correction
    1. Rician bias expectation correction
    2. Clipped correction
    3. Iteration limits and diagnostics
    4. The same correction choices for DTI and DKI
    5. Processing time and parallel workers
  6. Gradient nonlinearity
  7. Relationship to SMI

Quick start

-SH alone uses ordinary linear least squares (LLS) for the SH fit, with automatic fitting orders and no noise map required:

tmi dwi.nii sh_output -SH

-SH -RicianExp fits the expected Rician magnitude without a signal constraint by default. Supply a noise map with -sigma:

tmi dwi.nii sh_rician -SH -RicianExp -sigma sigma.nii

Add -nonNeg to constrain the SH signal at acquired directions and on a dense sphere grid. This option requires -RicianExp. Supplying -sigma alone does not switch from LLS to Rician fitting. The same estimator choice applies to -SMI. See Rician bias expectation correction for the observation model and initialization.

For clipped correction followed by ordinary LLS, use:

tmi dwi.nii sh_clip -SH -RicianClipMax -sigma sigma.nii
tmi dwi.nii sh_abs -SH -RicianClipAbs -sigma sigma.nii

Add -mask brain_mask.nii to restrict fitting to a brain mask. For data with a retained Rician noise floor, use -RicianClipAbs -sigma sigma.nii when all shells are below $3000\,\mathrm{s/mm^2}$, or -RicianExp -sigma sigma.nii when the data include $b\geq3000\,\mathrm{s/mm^2}$. Expectation fitting is slower because it uses nonlinear optimization. The selected estimator applies to all shells in the call. See Rician bias for the recommendations and noise assumptions.

Outputs

Standalone SH fitting saves separate S0.nii, S2.nii, and higher even-order files through the maximum fitted order. Each file is 4D, with one volume per shell, including a singleton volume dimension for a single shell. SH_shells.json maps each zero-based volume index to its b-value (s/mm²), b-shape, echo time (ms), number of measurements, and fitted SH order. For example, -lmaxSH 8 fits through order 8 and saves S0.nii, S2.nii, S4.nii, S6.nii, and S8.nii:

tmi dwi.nii sh_output -SH -lmaxSH 8

Order 8 is supported with all SH estimators, including Rician expectation fitting. Each directional shell fitted at order 8 needs at least 45 measurements with a full-rank SH design. b=0 and isotropic shells use order 0. In -SH mode, -lmaxSH sets the SH fitting order itself. See the standalone SH options.

Choose a fitting order for each shell

Orders 2, 4, 6, and 8 require at least 6, 15, 28, and 45 independent directional measurements, respectively. With -SH, each shell’s maximum SH order can be specified independently using a comma-separated list. This works with LLS, RicianExp, RicianClipMax and RicianClipAbs, for example:

# Input containing b=0, 1000, 2000, 7000 and 25000 s/mm², at one b-shape and TE:
tmi dwi.nii sh_lls -SH -lmaxSH 0,2,4,4,6
tmi dwi.nii sh_rician -SH -RicianExp -sigma sigma.nii -lmaxSH 0,2,4,4,6
Shell b-value (s/mm²) Maximum SH fitting order Fitted invariants
0 0 S0
1000 2 S0, S2
2000 4 S0, S2, S4
7000 4 S0, S2, S4
25000 6 S0, S2, S4, S6

The list must contain one nonnegative even order for every shell, including b=0 and isotropic shells, in ascending b-value, then b-shape, then echo time. SH_shells.json records this order and the order actually fitted. Use zero for b=0/isotropic shells; these use scalar estimation with the selected correction. A single integer applies the same order to all directional shells; omitting -lmaxSH selects fitting orders automatically. Write the list as one argument, with no spaces or trailing comma. If adapting an earlier standalone SH command, replace -lmax with -lmaxSH; -SH -lmax is rejected with a migration message.

The example saves S0.nii, S2.nii, S4.nii, and S6.nii, each with five shell volumes. Volumes above a shell’s fitting order are zero placeholders, not estimated invariants: for example, b=1000 has no fitted S4 or S6, and only b=25000 has a fitted S6. Fitting the shells together retains cross-shell rank-one processing: each even order uses only the shells that support it. Changing one shell’s order can therefore also change higher-order invariants in other shells through this joint step.

-lmaxSH is supported only with -SH. For -SMI, the separate -lmax option accepts one value (0, 2, 4, or 6) specifying the invariant order used for Standard Model regression; the SH fitting orders remain automatic per shell. The choice between ordinary LLS, corrected LLS and Rician-expectation fitting applies to both output modes. Only Rician-expectation fitting supports optional -nonNeg.

A requested order that cannot be identified from the directions is rejected; an unsupported higher-order invariant should not be interpreted as a measured zero. A full-rank design can still be poorly conditioned when directions are nearly redundant; reducing the fitting order can improve stability.

Signal normalization

The saved invariants are in the original signal units. For figures, normalized invariants can be computed as S_l / mean_b0, using the mean b=0 image at the same echo time. When comparing estimators, use the same b=0 reference image for all methods so differences in the denominator do not confound the comparison. Apply this normalization after fitting; the Rician fit itself uses the DWI and noise map in their original matching units.


SH fitting and noise correction

By default, SH coefficients are fit with ordinary linear least squares. Supplying a noise map alone does not change this estimator. The fitting and correction methods below are shared by standalone -SH and the signal-estimation stage of -SMI.

Rician bias expectation correction

Both -SH -RicianExp and -SMI -RicianExp fit

\[\widehat c=\arg\min_c\sum_i \left[\mu_R((Yc)_i,\sigma)-M_i\right]^2.\]

For the conditional least-squares framework behind this expectation fit, see Veraart et al. (2013).

Every nonlinear search starts from ordinary LLS on $\sqrt{\max(0,M^2-\sigma^2)}$, including retries. The objective uses original observations, preserving negative values after denoising. The Rician mean is even in $Yc$, so unconstrained fits can have signed lobes.

Nonnegativity is optional: add -nonNeg to enforce $Y_{\mathrm{grid}}c\geq0$ at acquired directions and on a 65,536-direction sphere grid, before cross-shell rank-one processing. This constrains signals, not individual coefficients. A finite grid does not guarantee positivity everywhere; constraining a truncated expansion can introduce bias even for a positive physical signal. Nonnegativity can substantially reduce variance, so users choose this bias–variance tradeoff. At $\sigma=0$, fits reduce to ordinary LLS, or constrained LLS with -nonNeg.

The solver uses an analytic Jacobian and batched fitting. With -nonNeg, violated grid directions trigger constrained refinement; failures return the best grid-feasible estimate with a warning. Initialization remains max-zero LLS.

Clipped correction

Choose -RicianClipMax or -RicianClipAbs to fit ordinary LLS to $\sqrt{\max(0,M^2-\sigma^2)}$ or $\sqrt{\lvert M^2-\sigma^2\rvert}$, respectively. These modes have no signal constraint and cannot be combined with -nonNeg. SH fits in signal space, so corrected zeros need no logarithm floor. -RicianExp overrides either clipping flag and keeps max-zero initialization.

All corrections require an aligned -sigma map in matching signal units. Use the original noise level responsible for the retained magnitude bias, even after denoising. They also apply to b0 and isotropic (STE) shells: clipping precedes averaging; expectation fitting inverts the Rician mean of the sample average using the original sigma. Higher-order invariants of these shells are zero. Basis normalization, rank-one processing and SMI regression are unchanged; $S_0$ is not rank-one processed. See Rician bias for equations and assumptions. No method guarantees unbiased finite-sample estimates.

Iteration limits and diagnostics

With -RicianExp -nonNeg, -RicianSH_maxiter N caps cumulative constrained-refinement iterations per voxel and shell, including restarts. The initial batched fit retains its standard limit. At the cap, the best grid-feasible fit is returned with a warning; very small caps can change estimates substantially.

When a cap is supplied, -SH and -SMI save:

  • RicianSH_early_stop.nii: refinement reached the cap.
  • RicianSH_iterations.nii: cumulative refinement iterations.
  • RicianSH_nonconverged.nii: cap exhaustion or other refinement failure.
  • RicianSH_diagnostics.json: shell metadata and counts.

Each image volume describes one shell before rank-one processing. Zero iterations means no refinement was needed, including b0/isotropic shells. These diagnostics do not describe the initial batched fit’s convergence.

The same correction choices for DTI and DKI

All three flags also apply to DTI/DKI/WDKI. Both clipping choices retain existing tensor settings, including -db0restore -akc_outliers together. Tensor expectation fitting is unconstrained, ignores AKC and does not yet support b0 restoration or spatial refinements. Tensor expectation starts from absolute-value corrected LLS; SH/SMI retain max-zero initialization. See tensor details.

Processing time and parallel workers

Use -n_cores for independent voxel blocks, with one BLAS thread per worker. Clipping is generally faster than expectation fitting; runtime depends on voxel count, SH order, SNR and active constraints. Parallelization retains the same objective, initialization, dense-grid check and rank-one processing.

Gradient nonlinearity

Standalone -SH currently fits the nominal shells and does not apply the voxelwise gradient-nonlinearity field supplied with -gnc. Integration of protocol-independent parameter estimation (PIPE) into TMI’s SH/SMI workflow is under development; see Coelho et al. (2026). For background and the currently supported tensor workflow, see gradient nonlinearity correction.

Relationship to SMI

Standard Model Imaging uses the signal rotational invariants as inputs to its model regression. -SMI saves these in rotinvs_smi.nii alongside the estimated tissue parameters. Standalone -SH saves separate S0.nii, S2.nii, … files without fitting tissue parameters. Run separate calls if both output formats are needed; -SH and -SMI cannot be combined in one call. SMI training priors affect its model regression, not standalone SH estimation.