code: def test_example():
      # Test example runs correctly
      eg_img = pjoin(dirname(__file__), "some_blobs.nii")
      nim = load(eg_img)
      arr = nim.get_fdata() ** 2 > 0
      mask_image = Nifti1Image(arr.astype("u1"), get_affine(nim))
      domain = grid_domain_from_image(mask_image)
      data = nim.get_fdata()
      values = data[data != 0]
  
      # parameters
      threshold = 3.0  # blob-forming threshold
      smin = 5  # size threshold on blobs
  
      # compute the  nested roi object
      nroi = HROI_as_discrete_domain_blobs(
          domain, values, threshold=threshold, smin=smin
      )
      # compute region-level activation averages
      activation = [
          values[nroi.select_id(id, roi=False)] for id in nroi.get_id()
      ]
      nroi.set_feature("activation", activation)
      average_activation = nroi.representative_feature("activation")
      averages = [
          blob.mean() for blob in nroi.get_feature("activation")
      ]
      assert_almost_equal(averages, average_activation, 6)
      # Test repeat
      assert_array_equal(
          average_activation, nroi.representative_feature("activation")
      )
      # Binary image is default
      bin_wim = nroi.to_image()
      bin_vox = bin_wim.get_fdata()
      assert_array_equal(np.unique(bin_vox), [0, 1])
      id_wim = nroi.to_image("id", roi=True, descrip="description")
      id_vox = id_wim.get_fdata()
      mask = bin_vox.astype(bool)
      assert_array_equal(id_vox[~mask], -1)
      ids = nroi.get_id()
      assert_array_equal(np.unique(id_vox), [-1] + list(ids))
      # Test activation
      wim = nroi.to_image("activation", roi=True, descrip="description")
      # Sadly, all cast to int
      assert_array_equal(
          np.unique(wim.get_fdata().astype(np.int32)), [-1, 3, 4, 5]
      )
      # end blobs or leaves
      lroi = nroi.copy()
      lroi.reduce_to_leaves()
      assert lroi.k == 14
      assert len(lroi.get_feature("activation")) == lroi.k
  
imports: from os.path import dirname
  from os.path import join
  import numpy
  from nibabel import Nifti1Image, load
  from numpy.testing import assert_almost_equal, assert_array_equal
  from nipy.io.nibcompat import get_affine
  from ..discrete_domain import domain_from_binary_array, grid_domain_from_image
  from ..hroi import HROI_as_discrete_domain_blobs
  from ..mroi import subdomain_from_array, subdomain_from_balls
label_desc: Use image node_id 15 for calling a global function with example usage: test_example() without return types