code: def test_recursive_response_calibration():
      """
      Test the recursive response calibration method.
      """
      SNR = 100
      S0 = 1
  
      _, fbvals, fbvecs = get_fnames("small_64D")
  
      bvals, bvecs = read_bvals_bvecs(fbvals, fbvecs)
      sphere = default_sphere
  
      gtab = gradient_table(bvals, bvecs)
      evals = np.array([0.0015, 0.0003, 0.0003])
      evecs = np.array([[0, 1, 0], [0, 0, 1], [1, 0, 0]]).T
      mevals = np.array(
          ([0.0015, 0.0003, 0.0003], [0.0015, 0.0003, 0.0003])
      )
      angles = [(0, 0), (90, 0)]
  
      where_dwi = lazy_index(~gtab.b0s_mask)
  
      S_cross, _ = multi_tensor(
          gtab, mevals, S0, angles=angles, fractions=[50, 50], snr=SNR
      )
  
      S_single = single_tensor(gtab, S0, evals, evecs, snr=SNR)
  
      data = np.concatenate(
          (np.tile(S_cross, (8, 1)), np.tile(S_single, (2, 1))), axis=0
      )
  
      odf_gt_cross = multi_tensor_odf(
          sphere.vertices, mevals, angles, [50, 50]
      )
  
      odf_gt_single = single_tensor_odf(sphere.vertices, evals, evecs)
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          response = recursive_response(
              gtab,
              data,
              mask=None,
              sh_order=8,
              peak_thr=0.01,
              init_fa=0.05,
              init_trace=0.0021,
              iter=8,
              convergence=0.001,
              parallel=False,
          )
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          csd = ConstrainedSphericalDeconvModel(gtab, response)
  
      csd_fit = csd.fit(data)
  
      assert_equal(np.all(csd_fit.shm_coeff[:, 0] >= 0), True)
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          fodf = csd_fit.odf(sphere)
  
      directions_gt_single, _, _ = peak_directions(
          odf_gt_single, sphere
      )
      directions_gt_cross, _, _ = peak_directions(odf_gt_cross, sphere)
      directions_single, _, _ = peak_directions(fodf[8, :], sphere)
      directions_cross, _, _ = peak_directions(fodf[0, :], sphere)
  
      ang_sim = angular_similarity(
          directions_cross, directions_gt_cross
      )
      assert_equal(ang_sim > 1.9, True)
      assert_equal(directions_cross.shape[0], 2)
      assert_equal(directions_gt_cross.shape[0], 2)
  
      ang_sim = angular_similarity(
          directions_single, directions_gt_single
      )
      assert_equal(ang_sim > 0.9, True)
      assert_equal(directions_single.shape[0], 1)
      assert_equal(directions_gt_single.shape[0], 1)
  
      with warnings.catch_warnings(record=True) as w:
          sphere = Sphere(xyz=gtab.gradients[where_dwi])
          npt.assert_equal(len(w), 1)
          npt.assert_(issubclass(w[0].category, UserWarning))
          npt.assert_(
              "Vertices are not on the unit sphere" in str(w[0].message)
          )
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          sf = response.on_sphere(sphere)
      S = np.concatenate(([response.S0], sf))
  
      tenmodel = TensorModel(gtab, min_signal=0.001)
  
      tenfit = tenmodel.fit(S)
      FA = fractional_anisotropy(tenfit.evals)
      FA_gt = fractional_anisotropy(evals)
      assert_almost_equal(FA, FA_gt, 1)
  
imports: import warnings
  import numpy
  import numpy.testing
  from numpy.testing import assert_, assert_equal, assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from dipy.testing import assert_greater, assert_greater_equal
  from dipy.data import get_sphere, get_fnames, default_sphere, small_sphere
  from dipy.sims.voxel import multi_tensor, single_tensor, multi_tensor_odf, all_tensor_evecs, single_tensor_odf
  from dipy.core.gradients import gradient_table
  from dipy.core.sphere import Sphere, HemiSphere
  from dipy.core.sphere_stats import angular_similarity
  from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel, ConstrainedSDTModel, forward_sdeconv_mat, odf_deconv, odf_sh_to_sharp, mask_for_response_ssst, response_from_mask_ssst, response_from_mask, auto_response_ssst, auto_response, recursive_response
  from dipy.direction.peaks import peak_directions
  from dipy.reconst.dti import TensorModel, fractional_anisotropy
  from dipy.reconst.shm import descoteaux07_legacy_msg, QballModel, sf_to_sh, sh_to_sf, real_sh_descoteaux, sph_harm_ind_list
  from dipy.reconst.shm import lazy_index
  from dipy.utils.deprecator import ExpiredDeprecationError
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 4 for calling a global function with example usage: test_recursive_response_calibration() without return types