code: def test_signal_extraction_nans_in_regions_are_replaced_with_zeros():
      shape = (4, 5, 6)
      labels = list(range(N_REGIONS + 1))  # 0 is background
      labels_img = generate_labeled_regions(
          shape, N_REGIONS, labels=labels
      )
      labels_data = get_data(labels_img)
      fmri_img, _ = generate_fake_fmri(
          shape=shape, affine=labels_img.affine, length=N_TIMEPOINTS
      )
  
      mask_img = _create_mask_with_3_regions_from_labels_data(
          labels_data, labels_img.affine
      )
  
      region1 = labels_data == 2
      indices = tuple(ind[:1] for ind in np.where(region1))
      get_data(fmri_img)[indices] = np.nan
  
      labels_signals, labels_labels = img_to_signals_labels(
          imgs=fmri_img, labels_img=labels_img, mask_img=mask_img
      )
  
      assert np.all(labels_signals[:, labels_labels.index(2)] == 0.0)
  
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 31 for calling a global function with example usage: test_signal_extraction_nans_in_regions_are_replaced_with_zeros() without return types