class_docstr: Class for the Diffusion Kurtosis Microstructural Model
      
class_docstr_tok: ["Class","for","the","Diffusion","Kurtosis","Microstructural","Model"]
docstr: Fit method of the Diffusion Kurtosis Microstructural Model
  
  Parameters
  ----------
  data : array
      An 4D matrix containing the diffusion-weighted data.
  
  mask : array
      A boolean array used to mark the coordinates in the data that
      should be analyzed that has the shape data.shape[-1]
  
  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 maxima 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
  
  awf_only : bool, optiomal
      If set to true only the axonal volume fraction is computed from
      the kurtosis tensor. Default = False
docstr_tok: ["Fit","method","of","the","Diffusion","Kurtosis","Microstructural","Model","Parameters","--","--","--","--","--","data",":","array","An","4D","matrix","containing","the","diffusion-weighted","data",".","mask",":","array","A","boolean","array","used","to","mark","the","coordinates","in","the","data","that","should","be","analyzed","that","has","the","shape","data.shape","[","-1","]","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","maxima","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","awf_only",":","bool",",","optiomal","If","set","to","true","only","the","axonal","volume","fraction","is","computed","from","the","kurtosis","tensor",".","Default","=","False"]
code: def fit(
      self,
      data,
      mask=None,
      sphere="repulsion100",
      gtol=1e-2,
      awf_only=False,
  ):
      """Fit method of the Diffusion Kurtosis Microstructural Model
  
      Parameters
      ----------
      data : array
          An 4D matrix containing the diffusion-weighted data.
  
      mask : array
          A boolean array used to mark the coordinates in the data that
          should be analyzed that has the shape data.shape[-1]
  
      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 maxima 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
  
      awf_only : bool, optiomal
          If set to true only the axonal volume fraction is computed from
          the kurtosis tensor. Default = False
      """
      if mask is not None:
          # Check for valid shape of the mask
          if mask.shape != data.shape[:-1]:
              raise ValueError("Mask is not the same shape as data.")
          mask = np.array(mask, dtype=bool, copy=False)
      data_in_mask = np.reshape(data[mask], (-1, data.shape[-1]))
  
      if self.min_signal is None:
          self.min_signal = MIN_POSITIVE_SIGNAL
  
      data_in_mask = np.maximum(data_in_mask, self.min_signal)
  
      # DKI fit
      dki_params = super().fit(data_in_mask).model_params
  
      # Computing awf
      awf = axonal_water_fraction(dki_params, sphere=sphere, gtol=gtol)
  
      if awf_only:
          params_all_mask = np.concatenate(
              (dki_params, np.array([awf]).T), axis=-1
          )
      else:
          # Computing the hindered and restricted diffusion tensors
          hdt, rdt = diffusion_components(
              dki_params, sphere=sphere, awf=awf
          )
          params_all_mask = np.concatenate(
              (dki_params, np.array([awf]).T, hdt, rdt), axis=-1
          )
  
      if mask is None:
          out_shape = data.shape[:-1] + (-1,)
          params = params_all_mask.reshape(out_shape)
          # if extra is not None:
          #    self.extra = extra.reshape(data.shape)
      else:
          params = np.zeros(
              data.shape[:-1] + (params_all_mask.shape[-1],)
          )
          params[mask, :] = params_all_mask
          # if extra is not None:
          #    self.extra = np.zeros(data.shape)
          #    self.extra[mask, :] = extra
  
      return KurtosisMicrostructuralFit(self, params)
  
imports: import numpy
  from dipy.reconst.dti import lower_triangular, from_lower_triangular, decompose_tensor, trace, mean_diffusivity, radial_diffusivity, axial_diffusivity, MIN_POSITIVE_SIGNAL
  from dipy.reconst.dki import split_dki_param, _positive_evals, directional_kurtosis, directional_diffusion, kurtosis_maximum, DiffusionKurtosisModel, DiffusionKurtosisFit
  from dipy.reconst.dti import design_matrix
  from dipy.core.ndindex import ndindex
  from dipy.reconst.vec_val_sum import vec_val_vect
  from dipy.data import get_sphere
  import dipy.core.sphere
label_desc: Use image node_id 2 for calling the KurtosisMicrostructureModel obj's underlying member method code with example usage: obj.fit(data, mask, sphere, gtol, awf_only) and returns: KurtosisMicrostructuralFit