code: def test_threshold_maps_ratio(maps):
      """Check _threshold_maps_ratio with randomly generated maps."""
      # test that there is no side effect
      get_data(maps)[:3] = 100
      maps_data = get_data(maps).copy()
      thr_maps = _threshold_maps_ratio(maps, threshold=1.0)
      np.testing.assert_array_equal(get_data(maps), maps_data)
  
      # make sure that n_regions (4th dimension) are kept same even
      # in thresholded image
      assert thr_maps.shape[-1] == maps.shape[-1]
  
imports: import numpy
  import pytest
  from nibabel import Nifti1Image
  from scipy.ndimage import label
  from nilearn._utils.data_gen import generate_labeled_regions, generate_maps
  from nilearn._utils.exceptions import DimensionError
  from nilearn.conftest import _affine_eye, _img_4d_zeros, _shape_3d_default
  from nilearn.image import get_data
  from nilearn.regions import RegionExtractor, connected_label_regions, connected_regions
  from nilearn.regions.region_extractor import _remove_small_regions, _threshold_maps_ratio
label_desc: Use image node_id 8 for calling a global function with example usage: test_threshold_maps_ratio(maps) without return types