code: def kurtosis_maximum(
      dki_params, sphere="repulsion100", gtol=1e-2, mask=None
  ):
      """Compute kurtosis maximum value
  
      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 eingenvalues
          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
      sphere : Sphere class instance, optional
          The sphere providing sample directions for the initial search of the
          maximal value of kurtosis.
      gtol : float, optional
          This input is to refine kurtosis maximum under the precision of the
          directions sampled on the sphere class instance. The gradient of the
          convergence procedure must be less than gtol before successful
          termination. If gtol is None, fiber direction is directly taken from
          the initial sampled directions of the given sphere object
      mask : ndarray
          A boolean array used to mark the coordinates in the data that should be
          analyzed that has the shape dki_params.shape[:-1]
  
      Returns
      -------
      max_value : float
          kurtosis tensor maximum value
      max_dir : array (3,)
          Cartesian coordinates of the direction of the maximal kurtosis value
  
      """
      shape = dki_params.shape[:-1]
  
      # load gradient directions
      if not isinstance(sphere, dps.Sphere):
          sphere = get_sphere("repulsion100")
  
      # select voxels where to find fiber directions
      if mask is None:
          mask = np.ones(shape, dtype="bool")
      else:
          if mask.shape != shape:
              raise ValueError(
                  "Mask is not the same shape as dki_params."
              )
  
      evals, evecs, kt = split_dki_param(dki_params)
  
      # select non-zero voxels
      pos_evals = _positive_evals(
          evals[..., 0], evals[..., 1], evals[..., 2]
      )
      mask = np.logical_and(mask, pos_evals)
  
      kt_max = np.zeros(mask.shape)
      dt = lower_triangular(vec_val_vect(evecs, evals))
      md = mean_diffusivity(evals)
  
      for idx in ndindex(shape):
          if not mask[idx]:
              continue
          kt_max[idx], da = _voxel_kurtosis_maximum(
              dt[idx], md[idx], kt[idx], sphere, gtol=gtol
          )
  
      return kt_max
  
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 17 for calling a global function with example usage: kurtosis_maximum(dki_params, sphere, gtol, mask) and returns: kt_max