code: def test_clean_detrending():
      n_samples = 21
      n_features = 501  # Must be higher than 500
      signals, _, _ = generate_signals(
          n_features=n_features, length=n_samples
      )
      trends = generate_trends(n_features=n_features, length=n_samples)
      x = signals + trends
      x_orig = x.copy()
  
      # if NANs, data out should be False with ensure_finite=True
      y = signals + trends
      y[20, 150] = np.nan
      y[5, 500] = np.nan
      y[15, 14] = np.inf
      y_orig = y.copy()
  
      y_clean = nisignal.clean(y, ensure_finite=True)
      assert np.any(np.isfinite(y_clean)), True
      # clean should not modify inputs
      # using assert_almost_equal instead of array_equal due to NaNs
      np.testing.assert_almost_equal(y_orig, y, decimal=13)
  
      # test boolean is not given to signal.clean
      with pytest.raises(TypeError):
          nisignal.clean(x, low_pass=False)
      with pytest.raises(TypeError):
          nisignal.clean(x, high_pass=False)
  
      # This should remove trends
      x_detrended = nisignal.clean(
          x,
          standardize=False,
          detrend=True,
          low_pass=None,
          high_pass=None,
      )
      np.testing.assert_almost_equal(x_detrended, signals, decimal=13)
      # clean should not modify inputs
      assert np.array_equal(x_orig, x)
  
      # This should do nothing
      x_undetrended = nisignal.clean(
          x,
          standardize=False,
          detrend=False,
          low_pass=None,
          high_pass=None,
      )
      assert not abs(x_undetrended - signals).max() < 0.06
      # clean should not modify inputs
      assert np.array_equal(x_orig, x)
  
imports: import os.path
  import numpy
  import pytest
  import scipy.signal
  from pandas import read_csv
  from nilearn import signal
  from nilearn.conftest import _rng
  from nilearn.signal import clean
label_desc: Use image node_id 9 for calling a global function with example usage: test_clean_detrending() without return types