code: def display_landmarks_2d(landmarks, hrois, stats):
      """Plots the landmarks and associated rois as images"""
      shape = stats[0].shape
      n_subjects = len(stats)
      lmax = 0
      grp_map, density = np.zeros(shape), np.zeros(shape)
      if landmarks is not None:
          domain = landmarks.domain
          grp_map = landmarks.map_label(
              domain.coord, 0.8, sigma
          ).reshape(shape)
          density = landmarks.kernel_density(
              k=None, coord=domain.coord, sigma=sigma
          ).reshape(shape)
          lmax = landmarks.k + 2
  
      # Figure 1: input data
      fig_input = plt.figure(figsize=(8, 3.5))
      fig_input.text(0.5, 0.9, "Input activation maps", ha="center")
      vmin, vmax = stats.min(), stats.max()
      for subject in range(n_subjects):
          plt.subplot(n_subjects // 5, 5, subject + 1)
          plt.imshow(
              stats[subject],
              interpolation="nearest",
              vmin=vmin,
              vmax=vmax,
          )
          plt.axis("off")
  
      # Figure 2: individual hrois
      fig_output = plt.figure(figsize=(8, 3.5))
      fig_output.text(
          0.5, 0.9, "Individual landmark regions", ha="center"
      )
      for subject in range(n_subjects):
          plt.subplot(n_subjects // 5, 5, subject + 1)
          lw = -np.ones(shape)
          if hrois[subject].k > 0:
              nls = hrois[subject].get_roi_feature("label")
              nls[nls == -1] = np.size(landmarks) + 2
              for k in range(hrois[subject].k):
                  np.ravel(lw)[hrois[subject].label == k] = nls[k]
  
          plt.imshow(lw, interpolation="nearest", vmin=-1, vmax=lmax)
          plt.axis("off")
  
      # Figure 3: Group-level results
      plt.figure(figsize=(6, 3))
  
      plt.subplot(1, 2, 1)
      plt.imshow(grp_map, interpolation="nearest", vmin=-1, vmax=lmax)
      plt.title(
          "group-level position 80% \n confidence regions", fontsize=10
      )
      plt.axis("off")
      plt.colorbar(shrink=0.8)
  
      plt.subplot(1, 2, 2)
      plt.imshow(density, interpolation="nearest")
      plt.title("Spatial density under h1", fontsize=10)
      plt.axis("off")
      plt.colorbar(shrink=0.8)
  
imports: import numpy
  import scipy.stats
  import nipy.labs.utils.simul_multisubject_fmri_dataset
  from nipy.labs.spatial_models.bayesian_structural_analysis import compute_landmarks
  from nipy.labs.spatial_models.discrete_domain import grid_domain_from_shape
label_desc: Use image node_id 1 for calling a global function with example usage: display_landmarks_2d(landmarks, hrois, stats) without return types