code: def test_find_cut_coords(affine_eye, rng):
      data = np.zeros((100, 100, 100))
      x_map, y_map, z_map = 50, 10, 40
      data[
          x_map - 30 : x_map + 30,
          y_map - 3 : y_map + 3,
          z_map - 10 : z_map + 10,
      ] = 1
  
      # identity affine
      img = nibabel.Nifti1Image(data, affine_eye)
      mask_img = compute_epi_mask(img)
      x, y, z = find_xyz_cut_coords(img, mask_img=mask_img)
  
      np.testing.assert_allclose(
          (x, y, z),
          (x_map, y_map, z_map),
          # Need such a high tolerance for the test to
          # pass. x, y, z = [49.5, 9.5, 39.5]
          rtol=6e-2,
      )
  
      # non-trivial affine
      affine = np.diag([1.0 / 2, 1 / 3.0, 1 / 4.0, 1.0])
      img = nibabel.Nifti1Image(data, affine)
      mask_img = compute_epi_mask(img)
      x, y, z = find_xyz_cut_coords(img, mask_img=mask_img)
      np.testing.assert_allclose(
          (x, y, z),
          (x_map / 2.0, y_map / 3.0, z_map / 4.0),
          # Need such a high tolerance for the test to
          # pass. x, y, z = [24.75, 3.17, 9.875]
          rtol=6e-2,
      )
  
      # regression test (cf. #473)
      # test case: no data exceeds the activation threshold
      # Cut coords should be the center of mass rather than
      # the center of the image (10, 10, 10).
      data = np.ones((36, 43, 36))
      img = nibabel.Nifti1Image(data, affine_eye)
      x, y, z = find_xyz_cut_coords(img, activation_threshold=1.1)
      np.testing.assert_array_equal([x, y, z], [17.5, 21.0, 17.5])
  
      data = np.zeros((20, 20, 20))
      data[4:6, 4:6, 4:6] = 1000
      img = nibabel.Nifti1Image(data, 2 * affine_eye)
      mask_data = np.ones((20, 20, 20), dtype="uint8")
      mask_img = nibabel.Nifti1Image(mask_data, 2 * affine_eye)
      cut_coords = find_xyz_cut_coords(img, mask_img=mask_img)
      np.testing.assert_array_equal(cut_coords, [9.0, 9.0, 9.0])
  
      # Check that a warning is given when all values are masked
      # and that the center of mass is returned
      img = nibabel.Nifti1Image(data, affine_eye)
      mask_data[np.argwhere(data == 1000)] = 0
      mask_img = nibabel.Nifti1Image(mask_data, affine_eye)
      with pytest.warns(
          UserWarning,
          match=(
              "Could not determine cut coords: All values were masked."
          ),
      ):
          cut_coords = find_xyz_cut_coords(img, mask_img=mask_img)
      np.testing.assert_array_equal(cut_coords, [4.5, 4.5, 4.5])
  
      # Check that a warning is given when all values are masked
      # due to thresholding and that the center of mass is returned
      mask_data = np.ones((20, 20, 20), dtype="uint8")
      mask_img = nibabel.Nifti1Image(mask_data, affine_eye)
      with pytest.warns(
          UserWarning,
          match=(
              "Could not determine cut coords: "
              "All voxels were masked by the thresholding."
          ),
      ):
          cut_coords = find_xyz_cut_coords(
              img, mask_img=mask_img, activation_threshold=10**3
          )
      np.testing.assert_array_equal(cut_coords, [4.5, 4.5, 4.5])
  
      # regression test (cf. #922)
      # pseudo-4D images as input (i.e., X, Y, Z, 1)
      # previously raised "ValueError: too many values to unpack"
      data_3d = rng.standard_normal(size=(10, 10, 10))
      data_4d = data_3d[..., np.newaxis]
      img_3d = nibabel.Nifti1Image(data_3d, affine_eye)
      img_4d = nibabel.Nifti1Image(data_4d, affine_eye)
      assert find_xyz_cut_coords(img_3d) == find_xyz_cut_coords(img_4d)
  
      # test passing empty image returns coordinates pointing to AC-PC line
      data = np.zeros((20, 30, 40))
      img = nibabel.Nifti1Image(data, affine_eye)
      cut_coords = find_xyz_cut_coords(img)
      assert cut_coords == [0.0, 0.0, 0.0]
      with pytest.warns(UserWarning):
          cut_coords = find_xyz_cut_coords(img)
  
file_path: nilearn/nilearn/plotting/tests/test_find_cuts.py
imports: import nibabel
  import numpy
  import pytest
  from nilearn.masking import compute_epi_mask
  from nilearn.plotting.find_cuts import _transform_cut_coords, find_cut_slices, find_parcellation_cut_coords, find_probabilistic_atlas_cut_coords, find_xyz_cut_coords
label_desc: Use image node_id 1 for calling a global function with example usage: test_find_cut_coords(affine_eye, rng) without return types