code: def test_wmti_model_multi_voxel():
      # DKI fit
      dkiM = dki_micro.DiffusionKurtosisModel(gtab_2s, fit_method="WLS")
      dkiF = dkiM.fit(DWIsim)
  
      # Axonal Water Fraction
      sphere = get_sphere()
      AWF = dki_micro.axonal_water_fraction(
          dkiF.model_params, 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, sphere
      )
      EDT = eig_from_lo_tri(edt)
      IDT = eig_from_lo_tri(idt)
  
      # check eigenvalues
      assert_array_almost_equal(EDT[..., 0], ADE, decimal=3)
      assert_array_almost_equal(EDT[..., 1], RDE, decimal=3)
      assert_array_almost_equal(EDT[..., 2], RDE, decimal=3)
      assert_array_almost_equal(IDT[..., 0], ADI, decimal=3)
      assert_array_almost_equal(IDT[..., 1], RDI, decimal=3)
      assert_array_almost_equal(IDT[..., 2], RDI, decimal=3)
  
      # Test methods performance when a signal with all zeros is present
      FIEc = FIE.copy()
      RDIc = RDI.copy()
      ADIc = ADI.copy()
      ADEc = ADE.copy()
      Torc = Tor.copy()
      RDEc = RDE.copy()
      DWIsimc = DWIsim.copy()
  
      FIEc[0, 0, 0] = 0
      RDIc[0, 0, 0] = 0
      ADIc[0, 0, 0] = 0
      ADEc[0, 0, 0] = 0
      Torc[0, 0, 0] = 0
      RDEc[0, 0, 0] = 0
      DWIsimc[0, 0, 0, :] = 0
      mask = np.ones((2, 2, 2))
      mask[0, 0, 0] = 0
  
      dkiF = dkiM.fit(DWIsimc)
      awf = dki_micro.axonal_water_fraction(
          dkiF.model_params, sphere, gtol=1e-5
      )
      assert_almost_equal(awf, FIEc)
  
      # Extra-cellular and intra-cellular components
      edt, idt = dki_micro.diffusion_components(
          dkiF.model_params, sphere, awf=awf
      )
      EDT = eig_from_lo_tri(edt)
      IDT = eig_from_lo_tri(idt)
      assert_array_almost_equal(EDT[..., 0], ADEc, decimal=3)
      assert_array_almost_equal(EDT[..., 1], RDEc, decimal=3)
      assert_array_almost_equal(EDT[..., 2], RDEc, decimal=3)
      assert_array_almost_equal(IDT[..., 0], ADIc, decimal=3)
      assert_array_almost_equal(IDT[..., 1], RDIc, decimal=3)
      assert_array_almost_equal(IDT[..., 2], RDIc, decimal=3)
  
      # Check when mask is given
      dkiF = dkiM.fit(DWIsim)
      awf = dki_micro.axonal_water_fraction(
          dkiF.model_params, sphere, gtol=1e-5, mask=mask
      )
      assert_almost_equal(awf, FIEc, decimal=3)
  
      # Extra-cellular and intra-cellular components
      edt, idt = dki_micro.diffusion_components(
          dkiF.model_params, sphere, awf=awf, mask=mask
      )
      EDT = eig_from_lo_tri(edt)
      IDT = eig_from_lo_tri(idt)
      assert_array_almost_equal(EDT[..., 0], ADEc, decimal=3)
      assert_array_almost_equal(EDT[..., 1], RDEc, decimal=3)
      assert_array_almost_equal(EDT[..., 2], RDEc, decimal=3)
      assert_array_almost_equal(IDT[..., 0], ADIc, decimal=3)
      assert_array_almost_equal(IDT[..., 1], RDIc, decimal=3)
      assert_array_almost_equal(IDT[..., 2], RDIc, decimal=3)
  
      # Check class object
      wmtiM = dki_micro.KurtosisMicrostructureModel(
          gtab_2s, fit_method="WLS"
      )
      wmtiF = wmtiM.fit(DWIsim, mask=mask)
      assert_almost_equal(wmtiF.awf, FIEc, decimal=3)
      assert_almost_equal(wmtiF.axonal_diffusivity, ADIc, decimal=3)
      assert_almost_equal(wmtiF.hindered_ad, ADEc, decimal=3)
      assert_almost_equal(wmtiF.hindered_rd, RDEc, decimal=3)
      assert_almost_equal(wmtiF.tortuosity, Torc, decimal=3)
  
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 4 for calling a global function with example usage: test_wmti_model_multi_voxel() without return types