code: def test_mask():
      data, gtab = dsi_voxels()
      for fit_type in ["LS", "NLLS"]:
          dm = dti.TensorModel(gtab, fit_type)
          mask = np.zeros(data.shape[:-1], dtype=bool)
          mask[0, 0, 0] = True
          dtifit = dm.fit(data)
          dtifit_w_mask = dm.fit(data, mask=mask)
          # Without a mask it has some value
          assert not np.isnan(dtifit.fa[0, 0, 0])
          # Where mask is False, evals, evecs and fa should all be 0
          npt.assert_array_equal(dtifit_w_mask.evals[~mask], 0)
          npt.assert_array_equal(dtifit_w_mask.evecs[~mask], 0)
          npt.assert_array_equal(dtifit_w_mask.fa[~mask], 0)
          # Except for the one voxel that was selected by the mask:
          npt.assert_almost_equal(
              dtifit_w_mask.fa[0, 0, 0], dtifit.fa[0, 0, 0]
          )
  
          # Test with returning S0_hat
          dm = dti.TensorModel(gtab, fit_type, return_S0_hat=True)
          mask = np.zeros(data.shape[:-1], dtype=bool)
          mask[0, 0, 0] = True
          for mask_more in [True, False]:
              if mask_more:
                  mask[0, 0, 1] = True
              dtifit = dm.fit(data)
              dtifit_w_mask = dm.fit(data, mask=mask)
              # Without a mask it has some value
              assert not np.isnan(dtifit.fa[0, 0, 0])
              # Where mask is False, evals, evecs and fa should all be 0
              npt.assert_array_equal(dtifit_w_mask.evals[~mask], 0)
              npt.assert_array_equal(dtifit_w_mask.evecs[~mask], 0)
              npt.assert_array_equal(dtifit_w_mask.fa[~mask], 0)
              npt.assert_array_equal(dtifit_w_mask.S0_hat[~mask], 0)
              # Except for the one voxel that was selected by the mask:
              npt.assert_almost_equal(
                  dtifit_w_mask.fa[0, 0, 0], dtifit.fa[0, 0, 0]
              )
              npt.assert_almost_equal(
                  dtifit_w_mask.S0_hat[0, 0, 0], dtifit.S0_hat[0, 0, 0]
              )
  
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 17 for calling a global function with example usage: test_mask() without return types