code: def _F2m(a, b, c):
      r""" Helper function that computes function $F_2$ which is required to
      compute the analytical solution of the Mean kurtosis
  
      Parameters
      ----------
      a : ndarray
          Array containing the values of parameter $\lambda_1$ of function $F_2$
      b : ndarray
          Array containing the values of parameter $\lambda_2$ of function $F_2$
      c : ndarray
          Array containing the values of parameter $\lambda_3$ of function $F_2$
  
      Returns
      -------
      F2 : ndarray
         Value of the function $F_2$ for all elements of the arrays a, b, and c
  
      Notes
      -----
      Function $F_2$ is defined as [1]_:
  
      .. math::
  
          F_2(\lambda_1,\lambda_2,\lambda_3)=
          \frac{(\lambda_1+\lambda_2+\lambda_3)^2}
          {3(\lambda_2-\lambda_3)^2}
          [\frac{\lambda_2+\lambda_3}{\sqrt{\lambda_2\lambda_3}}
          R_F(\frac{\lambda_1}{\lambda_2},\frac{\lambda_1}{\lambda_3},1)+\\
          \frac{2\lambda_1-\lambda_2-\lambda_3}{3\sqrt{\lambda_2 \lambda_3}}
          R_D(\frac{\lambda_1}{\lambda_2},\frac{\lambda_1}{\lambda_3},1)-2]
  
      References
      ----------
      .. [1] Tabesh, A., Jensen, J.H., Ardekani, B.A., Helpern, J.A., 2011.
             Estimation of tensors and tensor-derived measures in diffusional
             kurtosis imaging. Magn Reson Med. 65(3), 823-836
  
      """
      # Eigenvalues are considered equal if they are not 2.5% different to each
      # other. This value is adjusted according to the analysis reported in:
      # https://gsoc2015dipydki.blogspot.com/2015/08/rnh-post-13-start-wrapping-up-test.html
      er = 2.5e-2
  
      # Initialize F2
      F2 = np.zeros(a.shape)
  
      # Only computes F2 in voxels that have all eigenvalues larger than zero
      cond0 = _positive_evals(a, b, c)
  
      # Apply formula for non problematic plausible cases, i.e. b!=c
      cond1 = np.logical_and(cond0, (abs(b - c) > b * er))
      if np.sum(cond1) != 0:
          L1 = a[cond1]
          L2 = b[cond1]
          L3 = c[cond1]
          RF = carlson_rf(L1 / L2, L1 / L3, np.ones(len(L1)))
          RD = carlson_rd(L1 / L2, L1 / L3, np.ones(len(L1)))
          F2[cond1] = (
              ((L1 + L2 + L3) ** 2) / (3.0 * (L2 - L3) ** 2)
          ) * (
              ((L2 + L3) / (np.sqrt(L2 * L3))) * RF
              + ((2.0 * L1 - L2 - L3) / (3.0 * np.sqrt(L2 * L3))) * RD
              - 2.0
          )
  
      # Resolve possible singularity b==c
      cond2 = np.logical_and(
          cond0,
          np.logical_and(abs(b - c) < b * er, abs(a - b) > b * er),
      )
      if np.sum(cond2) != 0:
          L1 = a[cond2]
          L3 = (c[cond2] + b[cond2]) / 2.0
  
          # Compute alfa [1]_
          x = 1.0 - (L1 / L3)
          alpha = np.zeros(len(L1))
          for i in range(len(x)):
              if x[i] > 0:
                  alpha[i] = (
                      1.0 / np.sqrt(x[i]) * np.arctanh(np.sqrt(x[i]))
                  )
              else:
                  alpha[i] = (
                      1.0 / np.sqrt(-x[i]) * np.arctan(np.sqrt(-x[i]))
                  )
  
          F2[cond2] = (
              6.0
              * ((L1 + 2.0 * L3) ** 2)
              / (144.0 * L3**2 * (L1 - L3) ** 2)
              * (L3 * (L1 + 2.0 * L3) + L1 * (L1 - 4.0 * L3) * alpha)
          )
  
      # Resolve possible singularity a==b and a==c
      cond3 = np.logical_and(
          cond0,
          np.logical_and(abs(b - c) < b * er, abs(a - b) < b * er),
      )
      if np.sum(cond3) != 0:
          F2[cond3] = 6 / 15.0
  
      return F2
  
imports: import numpy
  import warnings
  import scipy.optimize
  import dipy.core.sphere
  from dipy.reconst.multi_voxel import multi_voxel_fit
  from dipy.reconst.dti import TensorFit, mean_diffusivity, from_lower_triangular, lower_triangular, decompose_tensor, MIN_POSITIVE_SIGNAL, nlls_fit_tensor, restore_fit_tensor
  from dipy.reconst.utils import dki_design_matrix
  from dipy.reconst.recspeed import local_maxima
  from dipy.reconst.base import ReconstModel
  from dipy.core.ndindex import ndindex
  from dipy.core.geometry import sphere2cart, cart2sphere, perpendicular_directions
  from dipy.core.optimize import PositiveDefiniteLeastSquares
  from dipy.data import get_sphere, get_fnames, load_sdp_constraints
  from dipy.reconst.vec_val_sum import vec_val_vect
  from dipy.core.gradients import check_multi_b
label_desc: Use image node_id 5 for calling a global function with example usage: _F2m(a, b, c) and returns: F2