code: def test_plot_carpet(img_4d_mni, img_3d_ones_mni, img_4d_long_mni):
      """Check contents of plot_carpet figure against data in image."""
      display = plot_carpet(
          img_4d_mni, img_3d_ones_mni, detrend=False, title="TEST"
      )
      # Next two lines retrieve the numpy array from the plot
      ax = display.axes[0]
      plotted_array = ax.images[0].get_array()
      assert plotted_array.shape == (
          np.prod(img_4d_mni.shape[:-1]),
          img_4d_mni.shape[-1],
      )
      # Make sure that the values in the figure match the values in the image
      np.testing.assert_almost_equal(
          plotted_array.sum(), img_4d_mni.get_fdata().sum(), decimal=3
      )
      # Save execution time and memory
      plt.close(display)
  
      fig, ax = plt.subplots()
      display = plot_carpet(
          img_4d_long_mni,
          img_3d_ones_mni,
          t_r=None,
          detrend=True,
          title="TEST",
          figure=fig,
          axes=ax,
      )
      # Next two lines retrieve the numpy array from the plot
      ax = display.axes[0]
      plotted_array = ax.images[0].get_array()
      # Check size
      n_items = np.prod(img_4d_long_mni.shape[:-1]) * np.ceil(
          img_4d_long_mni.shape[-1] / 2
      )
      assert plotted_array.size == n_items
      plt.close(display)
  
file_path: nilearn/nilearn/plotting/tests/test_img_plotting/test_plot_carpet.py
imports: import warnings
  import matplotlib.pyplot
  import numpy
  import pytest
  from nilearn.plotting import plot_carpet
label_desc: Use image node_id 1 for calling a global function with example usage: test_plot_carpet(img_4d_mni, img_3d_ones_mni, img_4d_long_mni) without return types