Skip to content

binding

binding

IVIM binding adapter for the shared fitting infrastructure.

BoundIVIMModel wraps an IVIMModel together with b-values, producing a FittableModel that the shared fitter can use without knowing about IVIM-specific context.

Provides an analytical Jacobian for efficient Levenberg-Marquardt optimization.

BoundIVIMModel

BoundIVIMModel(
    model, b_values, fixed=None, b_threshold=200.0
)

Bases: BaseBoundModel

IVIM model with b-values bound.

Wraps an IVIMModel so the fitter only sees predict_array_batch(free_params) -> output.

PARAMETER DESCRIPTION
model

IVIM signal model.

TYPE: IVIMModel

b_values

Diffusion weighting values in s/mm^2.

TYPE: NDArray

fixed

Parameters to fix at constant values during fitting.

TYPE: dict[str, float] | None DEFAULT: None

b_threshold

b-value threshold for segmented initial guess estimation.

TYPE: float DEFAULT: 200.0

ensure_device

ensure_device(xp)

Transfer b-values array to the target device.

predict_array_batch

predict_array_batch(free_params_batch, xp)

Predict signal for a batch of voxels.

PARAMETER DESCRIPTION
free_params_batch

Free parameter values, shape (n_free, n_voxels).

TYPE: NDArray

xp

Array module.

TYPE: module

RETURNS DESCRIPTION
NDArray

Predicted signal, shape (n_b, n_voxels).

get_initial_guess_batch

get_initial_guess_batch(observed_batch, xp)

Get initial parameter guesses using segmented approach.

Uses log-linear fit at high b-values for D, heuristic for f and D*, and b=0 signal for S0.

PARAMETER DESCRIPTION
observed_batch

Observed data, shape (n_b, n_voxels).

TYPE: NDArray

xp

Array module.

TYPE: module

RETURNS DESCRIPTION
NDArray

Initial guesses, shape (n_free, n_voxels).

compute_jacobian_batch

compute_jacobian_batch(params_batch, predicted, xp)

Compute analytical Jacobian for IVIM bi-exponential model.

Only computes columns for free (non-fixed) parameters.

PARAMETER DESCRIPTION
params_batch

Free parameter values, shape (n_free, n_voxels).

TYPE: NDArray

predicted

Predicted signal, shape (n_b, n_voxels).

TYPE: NDArray

xp

Array module.

TYPE: module

RETURNS DESCRIPTION
NDArray

Jacobian, shape (n_free, n_b, n_voxels).