Model fitting

The process of estimating IVIM parameters from a set of diffusion data has proved to be complicated in the presence of noise, resulting in several suggested algorithm for model fitting. Three of the most commonly used algorithm are implemented here: 1) non-linear least squares (NLLS), 2) segmented model fitting, and 3) Bayesian model fitting.[1], [2]

NLLS estimates all IVIM parameters of the particular model directly by minimizing the squared residuals between the data and the model predictions. The algorithm builds on the scipy function curve_fit which in turn applies a “Trust Region Reflective” algorithm (API).

A segmented algorithm for model fitting has been developed specifically for IVIM for improved robustness based on the prior knowledge that D*>>D. With this in mind one can assume that for some threshold b-value (bthr) the signal from the perfusion comparment is of negligible size (\(F_P \approx 0\)). Accordingly, the algorithm is split into two main steps. First, the model corresponding to the diffusion comparment is fitted to data with (\(b\geq b_{thr}\)) to estimate the diffusion-related parameters and an extrapolated signal at b = 0. In a second step, these parameter estimates are fixed when a complete model is fitted to data for all b-values. The specific algorithm implemented here is based on analytic solutions of the least squares problem (API).[3]

Bayesian algorithm introduces the ability to include prior knowledge and has proved to be more robust in the case of IVIM model fitting.[1], [2] The algorithm implemented here builds on Markov-Chain Monte Carlo, which numerically samples the posterior parameter distribution, and also provides the option to take information from neighboring voxels into accound (API).[2]

References

API

ivim.fit.nlls(im_file: str, bval_file: str, regime: str, roi_file: str | None = None, outbase: str | None = None, verbose: bool = False, fitK: bool = False, cval_file: str | None = None, seq: str = 'monopolar', delta_file: str | None = None, Delta_file: str | None = None, T_file: str | None = None, k_file: str | None = None) None

NLLS fitting of the IVIM model in different regimes.

Parameters:
  • im_file – path to nifti image file

  • bval_file – path to .bval file

  • regime – IVIM regime to model: no (= sIVIM), diffusive (long encoding time), ballistic (short encoding time) or intermediate (multiple encoding times)

  • roi_file – (optional) path to nifti file defining a region-of-interest (ROI) from with data is extracted

  • outbase – (optional) basis for output filenames to which e.g. ‘_D.nii.gz’ is added

  • verbose – (optional) if True, diagnostics during fitting is printet to terminal

  • fitK – (optional) if True, the kurtosis signal representation is used instead of a monoexponential one in the first step

  • cval_file – (optional) path to .cval file

  • seq – (optional) diffusion encoding sequence type (monopolar or bipolar)

  • delta_file – (optional) path to .delta file (gradient duration)

  • Delta_file – (optional) path to .Delta file (gradient separation)

  • T_file – (optional) path to .T file (total encoding time)

  • k_file – (optional) path to .k file (flow-/non-flow-compensated)

ivim.fit.seg(im_file: str, bval_file: str, regime: str, bthr: float = 200, roi_file: str | None = None, outbase: str | None = None, verbose: bool = False, fitK: bool = False, cval_file: str | None = None, cthr: float = 0) None

Segmented fitting of the IVIM model different regimes.

Parameters:
  • im_file – path to nifti image file

  • bval_file – path to .bval file

  • regime – IVIM regime to model: no (= sIVIM), diffusive (long encoding time) or ballistic (short encoding time)

  • bthr – (optional) threshold b-value from which signal is included in first fitting step

  • roi_file – (optional) path to nifti file defining a region-of-interest (ROI) from with data is extracted

  • outbase – (optional) basis for output filenames to which e.g. ‘_D.nii.gz’ is added

  • verbose – (optional) if True, diagnostics during fitting is printet to terminal

  • fitK – (optional) if True, the kurtosis signal representation is used instead of a monoexponential one in the first step

  • cval_file – (optional) path to .cval file

  • cthr – (optional) threshold c-value from above which signal is included in first fitting step

ivim.fit.bayes(im_file: str, bval_file: str, regime: str, roi_file: str | None = None, outbase: str | None = None, verbose: bool = False, fitK: bool = False, spatial_prior: bool = False, n: int = 2000, burns: int = 1000, ctm: str = 'mean', cval_file: str | None = None, seq: str = 'monopolar', delta_file: str | None = None, Delta_file: str | None = None, T_file: str | None = None, k_file: str | None = None)

Bayesian fitting of the IVIM model in different regimes

Parameters:
  • im_file – path to nifti image file

  • bval_file – path to .bval file

  • regime – IVIM regime to model: no (= sIVIM), diffusive (long encoding time), ballistic (short encoding time) or intermediate (multiple encoding times)

  • roi_file – (optional) path to nifti file defining a region-of-interest (ROI) from with data is extracted

  • outbase – (optional) basis for output filenames to which e.g. ‘_D.nii.gz’ is added

  • verbose – (optional) if True, diagnostics during fitting is printet to terminal

  • fitK – (optional) if True, the kurtosis signal representation is used instead of a monoexponential one in the first step

  • spatial_prior – (optional) if True, a spatial prior enforcing similary between 4-neighbours is applied

  • n – (optional) number of Markov Chain Monte Carlo (MCMC) iterations

  • burns – (optional) number of MCMC iterations before sampling

  • ctm – (optional) central tendency measure (mean or mode) used to summarize the posterior parameter distributions

  • cval_file – (optional) path to .cval file

  • seq – (optional) diffusion encoding sequence type (monopolar or bipolar)

  • delta_file – (optional) path to .delta file (gradient duration)

  • Delta_file – (optional) path to .Delta file (gradient separation)

  • T_file – (optional) path to .T file (total encoding time)

  • k_file – (optional) path to .k file (flow-/non-flow-compensated)