code: def test_connected_label_regions_check_labels_as_numpy_array(
      labels_img,
  ):
      """Test the names of the brain regions given in labels."""
      # labels given in numpy array
      # Test labels for 9 regions in n_regions
      labels = [f"region_{x}" for x in "abcdefghi"]
      labels = np.asarray(labels)
      _, new_labels2 = connected_label_regions(
          labels_img, labels=labels
      )
  
      assert new_labels2 != ""
      # By default min_size is less, so newly generated labels can be more.
      assert len(new_labels2) >= len(labels)
  
      # If number of labels provided are wrong (which means less than number of
      # unique labels in labels_img), then we raise an error
  
      # Test whether error raises
      unique_labels = set(np.unique(np.asarray(get_data(labels_img))))
      unique_labels.remove(0)
  
      # labels given are less than n_regions=9
      provided_labels = [f"region_{x}" for x in "acfghi"]
  
      assert len(provided_labels) < len(unique_labels)
  
      with pytest.raises(ValueError):
          connected_label_regions(labels_img, labels=provided_labels)
  
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 27 for calling a global function with example usage: test_connected_label_regions_check_labels_as_numpy_array(labels_img) without return types