class_docstr: Ivim model
      
docstr: Initialize an IVIM model.
  
  The IVIM model assumes that biological tissue includes a volume
  fraction 'f' of water flowing with a pseudo-diffusion coefficient
  D* and a fraction (1-f) of static (diffusion only), intra and
  extracellular water, with a diffusion coefficient D. In this model
  the echo attenuation of a signal in a single voxel can be written as
  
      .. math::
  
      S(b) = S_0[f*e^{(-b*D\*)} + (1-f)e^{(-b*D)}]
  
      Where:
      .. math::
  
      S_0, f, D\* and D are the IVIM parameters.
  
  Parameters
  ----------
  gtab : GradientTable class instance
      Gradient directions and bvalues
  
  split_b_D : float, optional
      The b-value to split the data on for two-stage fit. This will be
      used while estimating the value of D. The assumption is that at
      higher b values the effects of perfusion is less and hence the
      signal can be approximated as a mono-exponential decay.
      default : 400.
  
  split_b_S0 : float, optional
      The b-value to split the data on for two-stage fit for estimation
      of S0 and initial guess for D_star. The assumption here is that
      at low bvalues the effects of perfusion are more.
      default : 200.
  
  bounds : tuple of arrays with 4 elements, optional
      Bounds to constrain the fitted model parameters. This is only
      supported for Scipy version > 0.17. When using a older Scipy
      version, this function will raise an error if bounds are different
      from None. This parameter is also used to fill nan values for out
      of bounds parameters in the `IvimFit` class using the method
      fill_na. default : ([0., 0., 0., 0.], [np.inf, .3, 1., 1.])
  
  two_stage : bool
      Argument to specify whether to perform a non-linear fitting of all
      parameters after the linear fitting by splitting the data based on
      bvalues. This gives more accurate parameters but takes more time.
      The linear fit can be used to get a quick estimation of the
      parameters. default : False
  
  tol : float, optional
      Tolerance for convergence of minimization.
      default : 1e-15
  
  x_scale : array-like, optional
      Scaling for the parameters. This is passed to `least_squares` which
      is only available for Scipy version > 0.17.
      default: [1000, 0.01, 0.001, 0.0001]
  
  gtol : float, optional
      Tolerance for termination by the norm of the gradient.
      default : 1e-15
  
  ftol : float, optional
      Tolerance for termination by the change of the cost function.
      default : 1e-15
  
  eps : float, optional
      Step size used for numerical approximation of the jacobian.
      default : 1e-15
  
  maxiter : int, optional
      Maximum number of iterations to perform.
      default : 1000
  
  References
  ----------
  .. [1] Le Bihan, Denis, et al. "Separation of diffusion and perfusion
         in intravoxel incoherent motion MR imaging." Radiology 168.2
         (1988): 497-505.
  .. [2] Federau, Christian, et al. "Quantitative measurement of brain
         perfusion with intravoxel incoherent motion MR imaging."
         Radiology 265.3 (2012): 874-881.
code: def __init__(
      self,
      gtab,
      split_b_D=400.0,
      split_b_S0=200.0,
      bounds=None,
      two_stage=True,
      tol=1e-15,
      x_scale=(1000.0, 0.1, 0.001, 0.0001),
      gtol=1e-15,
      ftol=1e-15,
      eps=1e-15,
      maxiter=1000,
  ):
      r"""
      Initialize an IVIM model.
  
      The IVIM model assumes that biological tissue includes a volume
      fraction 'f' of water flowing with a pseudo-diffusion coefficient
      D* and a fraction (1-f) of static (diffusion only), intra and
      extracellular water, with a diffusion coefficient D. In this model
      the echo attenuation of a signal in a single voxel can be written as
  
          .. math::
  
          S(b) = S_0[f*e^{(-b*D\*)} + (1-f)e^{(-b*D)}]
  
          Where:
          .. math::
  
          S_0, f, D\* and D are the IVIM parameters.
  
      Parameters
      ----------
      gtab : GradientTable class instance
          Gradient directions and bvalues
  
      split_b_D : float, optional
          The b-value to split the data on for two-stage fit. This will be
          used while estimating the value of D. The assumption is that at
          higher b values the effects of perfusion is less and hence the
          signal can be approximated as a mono-exponential decay.
          default : 400.
  
      split_b_S0 : float, optional
          The b-value to split the data on for two-stage fit for estimation
          of S0 and initial guess for D_star. The assumption here is that
          at low bvalues the effects of perfusion are more.
          default : 200.
  
      bounds : tuple of arrays with 4 elements, optional
          Bounds to constrain the fitted model parameters. This is only
          supported for Scipy version > 0.17. When using a older Scipy
          version, this function will raise an error if bounds are different
          from None. This parameter is also used to fill nan values for out
          of bounds parameters in the `IvimFit` class using the method
          fill_na. default : ([0., 0., 0., 0.], [np.inf, .3, 1., 1.])
  
      two_stage : bool
          Argument to specify whether to perform a non-linear fitting of all
          parameters after the linear fitting by splitting the data based on
          bvalues. This gives more accurate parameters but takes more time.
          The linear fit can be used to get a quick estimation of the
          parameters. default : False
  
      tol : float, optional
          Tolerance for convergence of minimization.
          default : 1e-15
  
      x_scale : array-like, optional
          Scaling for the parameters. This is passed to `least_squares` which
          is only available for Scipy version > 0.17.
          default: [1000, 0.01, 0.001, 0.0001]
  
      gtol : float, optional
          Tolerance for termination by the norm of the gradient.
          default : 1e-15
  
      ftol : float, optional
          Tolerance for termination by the change of the cost function.
          default : 1e-15
  
      eps : float, optional
          Step size used for numerical approximation of the jacobian.
          default : 1e-15
  
      maxiter : int, optional
          Maximum number of iterations to perform.
          default : 1000
  
      References
      ----------
      .. [1] Le Bihan, Denis, et al. "Separation of diffusion and perfusion
             in intravoxel incoherent motion MR imaging." Radiology 168.2
             (1988): 497-505.
      .. [2] Federau, Christian, et al. "Quantitative measurement of brain
             perfusion with intravoxel incoherent motion MR imaging."
             Radiology 265.3 (2012): 874-881.
      """
      if not np.any(gtab.b0s_mask):
          e_s = "No measured signal at bvalue == 0."
          e_s += "The IVIM model requires signal measured at 0 bvalue"
          raise ValueError(e_s)
  
      if gtab.b0_threshold > 0:
          b0_s = "The IVIM model requires a measurement at b==0. As of "
          b0_s += "version 0.15, the default b0_threshold for the "
          b0_s += (
              "GradientTable object is set to 50, so if you used the "
          )
          b0_s += (
              "default settings to initialize the gtab input to the "
          )
          b0_s += "IVIM model, you may have provided a gtab with "
          b0_s += (
              "b0_threshold larger than 0. Please initialize the gtab "
          )
          b0_s += "input with b0_threshold=0"
          raise ValueError(b0_s)
  
      ReconstModel.__init__(self, gtab)
      self.split_b_D = split_b_D
      self.split_b_S0 = split_b_S0
      self.bounds = bounds
      self.two_stage = two_stage
      self.tol = tol
      self.options = {
          "gtol": gtol,
          "ftol": ftol,
          "eps": eps,
          "maxiter": maxiter,
      }
      self.x_scale = x_scale
  
      self.bounds = bounds or BOUNDS
  
imports: import warnings
  import numpy
  from scipy.optimize import least_squares, differential_evolution
  from dipy.reconst.base import ReconstModel
  from dipy.reconst.multi_voxel import multi_voxel_fit
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 1 to create a new IvimModelTRR object from inherited base classes: ReconstModel with example: obj = IvimModelTRR(gtab, split_b_D, split_b_S0, bounds, two_stage, tol, x_scale, gtol, ftol, eps, maxiter)