code: def test_connected_regions_different_results_with_different_mask_images(
      maps_and_mask,
  ):
      maps, mask_img = maps_and_mask
      # Test input mask_img
      mask = get_data(mask_img)
      mask[1, 1, 1] = 0
  
      extraction_with_mask_img, _ = connected_regions(
          maps, mask_img=mask_img
      )
  
      assert extraction_with_mask_img.shape[-1] >= 1
  
      extraction_without_mask_img, _ = connected_regions(maps)
  
      assert np.all(
          get_data(extraction_with_mask_img)[mask == 0] == 0.0
      )
      assert not np.all(
          get_data(extraction_without_mask_img)[mask == 0] == 0.0
      )
  
      # mask_img with different shape
      mask = np.zeros(shape=(10, 11, 12), dtype="uint8")
      mask[1:-1, 1:-1, 1:-1] = 1
      affine = np.array(
          [
              [2.0, 0.0, 0.0, 0.0],
              [0.0, 2.0, 0.0, 0.0],
              [0.0, 0.0, 2.0, 0.0],
              [0.0, 0.0, 0.0, 2.0],
          ]
      )
      mask_img = Nifti1Image(mask, affine=affine)
      extraction_not_same_fov_mask, _ = connected_regions(
          maps, mask_img=mask_img
      )
  
      assert maps.shape[:3] == extraction_not_same_fov_mask.shape[:3]
      assert mask_img.shape != extraction_not_same_fov_mask.shape[:3]
  
      extraction_not_same_fov, _ = connected_regions(maps)
  
      assert np.sum(get_data(extraction_not_same_fov) == 0) > np.sum(
          get_data(extraction_not_same_fov_mask) == 0
      )
  
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 13 for calling a global function with example usage: test_connected_regions_different_results_with_different_mask_images(maps_and_mask) without return types