code: def test_color_fa():
      data, gtab = dsi_voxels()
      dm = dti.TensorModel(gtab, "LS")
      dmfit = dm.fit(data)
      fa = fractional_anisotropy(dmfit.evals)
  
      fa = np.ones((3, 3, 3))
      # evecs should be of shape (fa, 3, 3)
      evecs = np.zeros(fa.shape + (3, 2))
      npt.assert_raises(ValueError, color_fa, fa, evecs)
  
      evecs = np.zeros(fa.shape + (3, 3))
      evecs[..., :, :] = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
  
      npt.assert_equal(fa.shape, evecs[..., 0, 0].shape)
      npt.assert_equal((3, 3), evecs.shape[-2:])
  
      # 3D test case
      fa = np.ones((3, 3, 3))
      evecs = np.zeros(fa.shape + (3, 3))
      evecs[..., :, :] = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
      cfa = color_fa(fa, evecs)
      cfa_truth = np.array([1, 0, 0])
      true_cfa = np.reshape(np.tile(cfa_truth, 27), [3, 3, 3, 3])
  
      npt.assert_array_equal(cfa, true_cfa)
  
      # 2D test case
      fa = np.ones((3, 3))
      evecs = np.zeros(fa.shape + (3, 3))
      evecs[..., :, :] = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
      cfa = color_fa(fa, evecs)
      cfa_truth = np.array([1, 0, 0])
      true_cfa = np.reshape(np.tile(cfa_truth, 9), [3, 3, 3])
  
      npt.assert_array_equal(cfa, true_cfa)
  
      # 1D test case
      fa = np.ones(3)
      evecs = np.zeros(fa.shape + (3, 3))
      evecs[..., :, :] = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
      cfa = color_fa(fa, evecs)
      cfa_truth = np.array([1, 0, 0])
      true_cfa = np.reshape(np.tile(cfa_truth, 3), [3, 3])
  
      npt.assert_array_equal(cfa, true_cfa)
  
imports: import warnings
  import numpy
  import numpy.testing
  import scipy.optimize
  import dipy.reconst.dti
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.reconst.dti import ols_resort_msg, axial_diffusivity, color_fa, fractional_anisotropy, from_lower_triangular, geodesic_anisotropy, lower_triangular, mean_diffusivity, radial_diffusivity, TensorModel, trace, linearity, planarity, sphericity, decompose_tensor, _decompose_tensor_nan
  from dipy.io.image import load_nifti_data
  from dipy.data import get_fnames, dsi_voxels, get_sphere
  from dipy.core.subdivide_octahedron import create_unit_sphere
  import dipy.core.gradients
  import dipy.core.sphere
  from dipy.sims.voxel import single_tensor
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 9 for calling a global function with example usage: test_color_fa() without return types