code: def test_q0_constraint_and_unity_of_ODFs(
      radial_order=6, time_order=2
  ):
      gtab_4d = generate_gtab4D()
      tau = gtab_4d.tau
  
      l1, l2, l3 = [0.0015, 0.0003, 0.0003]
      S = generate_signal_crossing(gtab_4d, l1, l2, l3)
      # first test without regularization
      qtdmri_mod_ls = qtdmri.QtdmriModel(
          gtab_4d, radial_order=radial_order, time_order=time_order
      )
      qtdmri_fit_ls = qtdmri_mod_ls.fit(S)
      fitted_signal = qtdmri_fit_ls.fitted_signal()
      # only first tau_point is normalized with least squares.
      E_q0_first_tau = fitted_signal[
          np.all([tau == tau.min(), gtab_4d.b0s_mask], axis=0)
      ].item()
      assert_almost_equal(float(E_q0_first_tau), 1.0)
  
      # now with cvxpy regularization cartesian
      qtdmri_mod_lap = qtdmri.QtdmriModel(
          gtab_4d,
          radial_order=radial_order,
          time_order=time_order,
          laplacian_regularization=True,
          laplacian_weighting=1e-4,
      )
      qtdmri_fit_lap = qtdmri_mod_lap.fit(S)
      fitted_signal = qtdmri_fit_lap.fitted_signal()
      E_q0_first_tau = fitted_signal[
          np.all([tau == tau.min(), gtab_4d.b0s_mask], axis=0)
      ].item()
      E_q0_last_tau = fitted_signal[
          np.all([tau == tau.max(), gtab_4d.b0s_mask], axis=0)
      ].item()
      assert_almost_equal(E_q0_first_tau, 1.0)
      assert_almost_equal(E_q0_last_tau, 1.0)
  
      # check if odf in spherical harmonics for cartesian raises an error
      try:
          qtdmri_fit_lap.odf_sh(tau=tau.max())
          assert_equal(True, False)
      except ValueError:
          print("missing spherical harmonics cartesian ODF caught.")
  
      # now with cvxpy regularization spherical
      qtdmri_mod_lap = qtdmri.QtdmriModel(
          gtab_4d,
          radial_order=radial_order,
          time_order=time_order,
          laplacian_regularization=True,
          laplacian_weighting=1e-4,
          cartesian=False,
      )
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          qtdmri_fit_lap = qtdmri_mod_lap.fit(S)
          fitted_signal = qtdmri_fit_lap.fitted_signal()
      E_q0_first_tau = fitted_signal[
          np.all([tau == tau.min(), gtab_4d.b0s_mask], axis=0)
      ].item()
      E_q0_last_tau = fitted_signal[
          np.all([tau == tau.max(), gtab_4d.b0s_mask], axis=0)
      ].item()
      assert_almost_equal(float(E_q0_first_tau), 1.0)
      assert_almost_equal(float(E_q0_last_tau), 1.0)
  
      # test if marginal ODF integral in sh is equal to one
      # Integral of Y00 spherical harmonic is 1 / (2 * np.sqrt(np.pi))
      # division with this results in normalization
      odf_sh = qtdmri_fit_lap.odf_sh(s=0, tau=tau.max())
      odf_integral = odf_sh[0] * (2 * np.sqrt(np.pi))
      assert_almost_equal(odf_integral, 1.0)
  
imports: import warnings
  import numpy
  import scipy.integrate
  from numpy.testing import assert_, assert_almost_equal, assert_array_almost_equal, assert_equal, assert_raises
  import pytest
  from dipy.core.gradients import gradient_table_from_qvals_bvecs
  from dipy.data import get_gtab_taiwan_dsi, get_sphere
  from dipy.reconst import qtdmri, mapmri
  from dipy.reconst.shm import descoteaux07_legacy_msg
  from dipy.sims.voxel import multi_tensor, add_noise
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 13 for calling a global function with example usage: test_q0_constraint_and_unity_of_ODFs(radial_order, time_order) without return types