code: def test_plot_stat_map_threshold_for_affine_with_rotation(rng):
      """Tests for plot_stat_map with thresholding and resampling.
  
      Threshold was not being applied when affine has a rotation.
      See https://github.com/nilearn/nilearn/issues/599 for more details.
      """
      data = rng.standard_normal(size=(10, 10, 10))
      # matrix with rotation
      affine = np.array(
          [
              [-3.0, 1.0, 0.0, 1.0],
              [-1.0, -3.0, 0.0, -2.0],
              [0.0, 0.0, 3.0, 3.0],
              [0.0, 0.0, 0.0, 1.0],
          ]
      )
      img = Nifti1Image(data, affine)
      display = plot_stat_map(
          img,
          bg_img=None,
          threshold=1.0,
          display_mode="z",
          cut_coords=1,
      )
      # Next two lines retrieve the numpy array from the plot
      ax = list(display.axes.values())[0].ax
      plotted_array = ax.images[0].get_array()
      # Given the high threshold the array should be partly masked
      assert plotted_array.mask.any()
      # Save execution time and memory
      plt.close()
  
imports: import matplotlib.pyplot
  import numpy
  import pytest
  from nibabel import Nifti1Image
  from nilearn.conftest import _rng
  from nilearn.datasets import load_mni152_template
  from nilearn.image import get_data
  from nilearn.image.resampling import coord_transform
  from nilearn.plotting import plot_stat_map
  from nilearn.plotting.find_cuts import find_cut_slices
label_desc: Use image node_id 6 for calling a global function with example usage: test_plot_stat_map_threshold_for_affine_with_rotation(rng) without return types