code: def setup_module():
      global gtab_3s, signal_sph, msignal_sph, DWI, MDWI
      global bvecs, gtab, params_single, params_multi, MKgt_multi
      global bvals_3s, MDgt_multi, S0gt_multi, MKgt, MDgt
  
      fimg, fbvals, fbvecs = get_fnames("small_64D")
      bvals, bvecs = read_bvals_bvecs(fbvals, fbvecs)
      bvals = round_bvals(bvals)
      gtab = gradient_table(bvals, bvecs)
  
      # 2 shells for techniques that requires multishell data
      bvals_3s = np.concatenate((bvals, bvals * 1.5, bvals * 2), axis=0)
      bvecs_3s = np.concatenate((bvecs, bvecs, bvecs), axis=0)
      gtab_3s = gradient_table(bvals_3s, bvecs_3s)
  
      # Simulation 1. Spherical kurtosis tensor - MSK and MSD from the MSDKI
      # model should be equal to the MK and MD of the DKI tensor for cases of
      # spherical kurtosis tensors
      Di = 0.00099
      De = 0.00226
      mevals_sph = np.array([[Di, Di, Di], [De, De, De]])
      f = 0.5
      frac_sph = [f * 100, (1.0 - f) * 100]
      signal_sph, dt_sph, kt_sph = multi_tensor_dki(
          gtab_3s, mevals_sph, S0=100, fractions=frac_sph, snr=None
      )
      # Compute ground truth values
      MDgt = f * Di + (1 - f) * De
      MKgt = 3 * f * (1 - f) * ((Di - De) / MDgt) ** 2
      params_single = np.array([MDgt, MKgt])
      msignal_sph = np.zeros(4)
      msignal_sph[0] = signal_sph[0]
      msignal_sph[1] = signal_sph[1]
      msignal_sph[2] = signal_sph[100]
      msignal_sph[3] = signal_sph[180]
  
      # Simulation 2. Multi-voxel simulations
      DWI = np.zeros((2, 2, 2, len(gtab_3s.bvals)))
      MDWI = np.zeros((2, 2, 2, 4))
      MDgt_multi = np.zeros((2, 2, 2))
      MKgt_multi = np.zeros((2, 2, 2))
      S0gt_multi = np.zeros((2, 2, 2))
      params_multi = np.zeros((2, 2, 2, 2))
  
      for i in range(2):
          for j in range(2):
              for k in range(1):  # Only one k to have some zero voxels
                  f = random.uniform(0.0, 1)
                  frac = [f * 100, (1.0 - f) * 100]
                  signal_i, dt_i, kt_i = multi_tensor_dki(
                      gtab_3s,
                      mevals_sph,
                      S0=100,
                      fractions=frac,
                      snr=None,
                  )
                  DWI[i, j, k] = signal_i
                  md_i = f * Di + (1 - f) * De
                  mk_i = 3 * f * (1 - f) * ((Di - De) / md_i) ** 2
                  MDgt_multi[i, j, k] = md_i
                  MKgt_multi[i, j, k] = mk_i
                  S0gt_multi[i, j, k] = 100
                  params_multi[i, j, k, 0] = md_i
                  params_multi[i, j, k, 1] = mk_i
                  MDWI[i, j, k, 0] = signal_i[0]
                  MDWI[i, j, k, 1] = signal_i[1]
                  MDWI[i, j, k, 2] = signal_i[100]
                  MDWI[i, j, k, 3] = signal_i[180]
  
file_path: dipy/dipy/reconst/tests/test_msdki.py
imports: import numpy
  import random
  from numpy.testing import assert_array_almost_equal, assert_raises, assert_almost_equal, assert_
  from dipy.sims.voxel import single_tensor, multi_tensor_dki
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.core.gradients import gradient_table, unique_bvals_magnitude, round_bvals
  from dipy.data import get_fnames
  import dipy.reconst.msdki
  from dipy.reconst.msdki import msk_from_awf, awf_from_msk
label_desc: Use image node_id 1 for calling a global function with example usage: setup_module() without return types