code: def axial_kurtosis(
      dki_params,
      min_kurtosis=-3.0 / 7,
      max_kurtosis=10,
      analytical=True,
  ):
      r"""Compute axial kurtosis (AK) from the kurtosis tensor [1]_, [2]_
  
      Parameters
      ----------
      dki_params : ndarray (x, y, z, 27) or (n, 27)
      All parameters estimated from the diffusion kurtosis model.
      Parameters are ordered as follows:
          1) Three diffusion tensor's eigenvalues
          2) Three lines of the eigenvector matrix each containing the first,
              second and third coordinates of the eigenvector
          3) Fifteen elements of the kurtosis tensor
      min_kurtosis : float (optional)
          To keep kurtosis values within a plausible biophysical range, axial
          kurtosis values that are smaller than `min_kurtosis` are replaced with
          `min_kurtosis`. Default = -3./7 (theoretical kurtosis limit for regions
          that consist of water confined to spherical pores [3]_)
      max_kurtosis : float (optional)
          To keep kurtosis values within a plausible biophysical range, axial
          kurtosis values that are larger than `max_kurtosis` are replaced with
          `max_kurtosis`. Default = 10
      analytical : bool (optional)
          If True, AK is calculated from rotated diffusion kurtosis tensor,
          otherwise it will be computed from the apparent diffusion kurtosis
          values along the principal axis of the diffusion tensor (see notes).
          Default is set to True.
  
      Returns
      -------
      ak : array
          Calculated AK.
  
      Notes
      -----
      AK is defined as the directional kurtosis parallel to the fiber's main
      direction e1 [1]_, [2]_. You can compute AK using to approaches:
  
      1) AK is calculated from rotated diffusion kurtosis tensor [2]_, i.e.:
  
      .. math::
          AK = \hat{W}_{1111}
              \frac{(\lambda_{1}+\lambda_{2}+\lambda_{3})^2}{(9 \lambda_{1}^2)}
  
      2) AK can be sampled from the principal axis of the diffusion tensor:
  
      .. math::
          AK = K(\mathbf{\mathbf{e}_1)
  
      Although both approaches leads to an exact calculation of AK, the first
      approach will be referred to as the analytical method while the second
      approach will be referred to as the numerical method based on their analogy
      to the estimation strategies for MK and RK.
  
      References
      ----------
      .. [1] Jensen, J.H., Helpern, J.A., 2010. MRI quantification of
             non-Gaussian water diffusion by kurtosis analysis. NMR in
             Biomedicine 23(7): 698-710
      .. [2] 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
      .. [3] Barmpoutis, A., & Zhuo, J., 2011. Diffusion kurtosis imaging:
             Robust estimation from DW-MRI using homogeneous polynomials.
             Proceedings of the 8th {IEEE} International Symposium on
             Biomedical Imaging: From Nano to Macro, ISBI 2011, 262-265.
             doi: 10.1109/ISBI.2011.5872402
  
      """
      # Flat parameters
      outshape = dki_params.shape[:-1]
      dki_params = dki_params.reshape((-1, dki_params.shape[-1]))
  
      # Split data
      evals, evecs, kt = split_dki_param(dki_params)
  
      # Initialize AK
      AK = np.zeros(kt.shape[:-1])
  
      # select relevant voxels to process
      rel_i = _positive_evals(
          evals[..., 0], evals[..., 1], evals[..., 2]
      )
      kt = kt[rel_i]
      evecs = evecs[rel_i]
      evals = evals[rel_i]
      AKi = AK[rel_i]
  
      # Compute mean diffusivity
      md = mean_diffusivity(evals)
  
      if analytical:
          # Rotate the kurtosis tensor from the standard Cartesian coordinate
          # system to another coordinate system in which the 3 orthonormal
          # eigenvectors of DT are the base coordinate
          Wxxxx = Wrotate_element(kt, 0, 0, 0, 0, evecs)
          AKi = Wxxxx * (md**2) / (evals[..., 0] ** 2)
  
      else:
          # Compute apparent directional kurtosis along evecs[0]
          dt = lower_triangular(vec_val_vect(evecs, evals))
          for vox in range(len(kt)):
              AKi[vox] = directional_kurtosis(
                  dt[vox],
                  md[vox],
                  kt[vox],
                  np.array([evecs[vox, :, 0]]),
              )
  
      # reshape data according to input data
      AK[rel_i] = AKi
  
      if min_kurtosis is not None:
          AK = AK.clip(min=min_kurtosis)
  
      if max_kurtosis is not None:
          AK = AK.clip(max=max_kurtosis)
  
      return AK.reshape(outshape)
  
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 14 for calling a global function with example usage: axial_kurtosis(dki_params, min_kurtosis, max_kurtosis, analytical) and returns: AK