code: def signals_to_img_maps(region_signals, maps_img, mask_img=None):
      """Create image from region signals defined as maps.
  
      region_signals, mask_img must have the same shapes and affines.
  
      Parameters
      ----------
      region_signals : :class:`numpy.ndarray`
          signals to process, as a 2D array. A signal is a column.
          There must be as many signals as maps:
  
              .. code-block:: python
  
                  region_signals.shape[1] == maps_img.shape[-1]
  
      maps_img : Niimg-like object
          See :ref:`extracting_data`.
          Region definitions using maps.
  
      mask_img : Niimg-like object, optional
          See :ref:`extracting_data`.
          Boolean array giving :term:`voxels<voxel>` to process.
          Integer arrays also accepted, zero meaning False.
  
      Returns
      -------
      img : :class:`nibabel.nifti1.Nifti1Image`
          Reconstructed image. affine and shape are those of maps_img.
  
      See Also
      --------
      nilearn.regions.signals_to_img_labels
      nilearn.regions.img_to_signals_maps
      nilearn.maskers.NiftiMapsMasker
  
      """
      maps_img = _utils.check_niimg_4d(maps_img)
      maps_data = safe_get_data(maps_img, ensure_finite=True)
  
      maps_mask = np.ones(maps_data.shape[:3], dtype=bool)
  
      use_mask = _check_shape_and_affine_compatibility(
          maps_img, mask_img
      )
      if use_mask:
          mask_img = _utils.check_niimg_3d(mask_img)
          maps_data, maps_mask, _ = _trim_maps(
              maps_data,
              safe_get_data(mask_img, ensure_finite=True),
              keep_empty=True,
          )
          maps_mask = _utils.as_ndarray(maps_mask, dtype=bool)
          assert maps_mask.shape == maps_data.shape[:3]
  
      data = np.dot(region_signals, maps_data[maps_mask, :].T)
      return masking.unmask(
          data, new_img_like(maps_img, maps_mask, maps_img.affine)
      )
  
file_path: nilearn/nilearn/regions/signal_extraction.py
imports: import warnings
  import numpy
  from nibabel import Nifti1Image
  from scipy import linalg, ndimage
  from ..None import _utils, masking
  from .._utils.niimg import safe_get_data
  from ..image import new_img_like
label_desc: Use image node_id 9 for calling a global function with example usage: signals_to_img_maps(region_signals, maps_img, mask_img) and returns: masking