code: def test_signal_extraction_with_maps(
      affine_eye, shape_3d_default, rng
  ):
      # Generate signal imgs
      maps_img, mask_img = generate_maps(shape_3d_default, N_REGIONS)
      maps_data = get_data(maps_img)
      data = np.zeros(shape_3d_default + (N_TIMEPOINTS,))
      signals = np.zeros((N_TIMEPOINTS, maps_data.shape[-1]))
      for n in range(maps_data.shape[-1]):
          signals[:, n] = rng.standard_normal(size=N_TIMEPOINTS)
          data[maps_data[..., n] > 0, :] = signals[:, n]
      imgs = Nifti1Image(data, affine_eye)
  
      # Get signals
      signals_r, _ = img_to_signals_maps(
          imgs=imgs, maps_img=maps_img, mask_img=mask_img
      )
      assert_almost_equal(signals, signals_r)
  
      # Recover image
      img_r = signals_to_img_maps(signals, maps_img, mask_img=mask_img)
      assert_almost_equal(get_data(img_r), get_data(imgs))
  
      # Same thing without mask
      signals_r, _ = img_to_signals_maps(imgs, maps_img)
      assert_almost_equal(signals, signals_r)
      img_r = signals_to_img_maps(signals, maps_img)
      assert_almost_equal(get_data(img_r), get_data(imgs))
  
imports: import warnings
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from numpy.testing import assert_almost_equal, assert_equal
  from nilearn._utils.data_gen import generate_fake_fmri, generate_labeled_regions, generate_maps, generate_timeseries
  from nilearn._utils.exceptions import DimensionError
  from nilearn._utils.testing import write_imgs_to_path
  from nilearn.conftest import _affine_eye, _shape_3d_default
  from nilearn.image import get_data, new_img_like
  from nilearn.maskers import NiftiLabelsMasker
  from nilearn.regions.signal_extraction import _check_shape_and_affine_compatibility, _trim_maps, img_to_signals_labels, img_to_signals_maps, signals_to_img_labels, signals_to_img_maps
label_desc: Use image node_id 27 for calling a global function with example usage: test_signal_extraction_with_maps(affine_eye, shape_3d_default, rng) without return types