code: def test_single_fiber_model():
      # single fiber simulate (which is the assumption of our model)
      fie = 0.49
      ADi = 0.00099
      ADe = 0.00226
      RDi = 0
      RDe = 0.00087
  
      # prepare simulation:
      theta = random.uniform(0, 180)
      phi = random.uniform(0, 320)
      angles = [(theta, phi), (theta, phi)]
      mevals = np.array([[ADi, RDi, RDi], [ADe, RDe, RDe]])
      frac = [fie * 100, (1 - fie) * 100]
      signal, dt, kt = multi_tensor_dki(
          gtab_2s, mevals, angles=angles, fractions=frac, snr=None
      )
      # DKI fit
      dkiM = dki_micro.DiffusionKurtosisModel(gtab_2s, fit_method="WLS")
      dkiF = dkiM.fit(signal)
  
      # Axonal Water Fraction
      AWF = dki_micro.axonal_water_fraction(
          dkiF.model_params, default_sphere, mask=None, gtol=1e-5
      )
      assert_almost_equal(AWF, fie)
  
      # Extra-cellular and intra-cellular components
      edt, idt = dki_micro.diffusion_components(
          dkiF.model_params, default_sphere
      )
      EDT = eig_from_lo_tri(edt)
      IDT = eig_from_lo_tri(idt)
  
      # check eigenvalues
      assert_array_almost_equal(EDT[0:3], np.array([ADe, RDe, RDe]))
      assert_array_almost_equal(IDT[0:3], np.array([ADi, RDi, RDi]))
      # first eigenvalue should be the direction of the fibers
      fiber_direction = _check_directions([(theta, phi)])
      f_norm = abs(
          np.dot(fiber_direction, np.array((EDT[3], EDT[6], EDT[9])))
      )
      assert_almost_equal(f_norm, 1.0)
      f_norm = abs(
          np.dot(fiber_direction, np.array((IDT[3], IDT[6], IDT[9])))
      )
      assert_almost_equal(f_norm, 1.0)
  
      # Test model and fit objects
      wmtiM = dki_micro.KurtosisMicrostructureModel(
          gtab_2s, fit_method="WLS"
      )
      wmtiF = wmtiM.fit(signal)
      assert_allclose(wmtiF.awf, AWF, rtol=1e-6)
      assert_array_almost_equal(
          wmtiF.hindered_evals, np.array([ADe, RDe, RDe])
      )
      assert_array_almost_equal(
          wmtiF.restricted_evals, np.array([ADi, RDi, RDi])
      )
      assert_almost_equal(wmtiF.hindered_ad, ADe)
      assert_almost_equal(wmtiF.hindered_rd, RDe)
      assert_almost_equal(wmtiF.axonal_diffusivity, ADi)
      assert_almost_equal(wmtiF.tortuosity, ADe / RDe, decimal=4)
  
      # Test diffusion_components when a kurtosis tensors is associated with
      # negative kurtosis values. E.g of this cases is given below:
      dkiparams = np.array(
          [
              1.67135726e-03,
              5.03651205e-04,
              9.35365328e-05,
              -7.11167583e-01,
              6.23186820e-01,
              -3.25390313e-01,
              -1.75247376e-02,
              -4.78415563e-01,
              -8.77958674e-01,
              7.02804064e-01,
              6.18673368e-01,
              -3.51154825e-01,
              2.18384153,
              -2.76378153e-02,
              2.22893297,
              -2.68306546e-01,
              -1.28411610,
              -1.56557645e-01,
              -1.80850619e-01,
              -8.33152110e-01,
              -3.62410766e-01,
              1.57775442e-01,
              8.73775381e-01,
              2.77188975e-01,
              -3.67415502e-02,
              -1.56330984e-01,
              -1.62295407e-02,
          ]
      )
      edt, idt = dki_micro.diffusion_components(dkiparams)
      assert_(np.all(np.isfinite(edt)))
  
file_path: dipy/dipy/reconst/tests/test_dki_micro.py
imports: import numpy
  import random
  import dipy.reconst.dki_micro
  from numpy.testing import assert_array_almost_equal, assert_almost_equal, assert_, assert_raises, assert_allclose
  from dipy.sims.voxel import multi_tensor_dki, _check_directions, multi_tensor
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.core.gradients import gradient_table
  from dipy.data import get_fnames
  from dipy.reconst.dti import eig_from_lo_tri
  from dipy.data import default_sphere, get_sphere
label_desc: Use image node_id 3 for calling a global function with example usage: test_single_fiber_model() without return types