code: def test_z_score_t_values(rng):
      # Randomly draw samples from the standard Student’s t distribution
      t_val = rng.standard_t(10, size=10)
      # Estimate the p-values using the Survival Function (SF)
      p_val = sps.t.sf(t_val, 1e10)
      # Estimate the p-values using the Cumulative Distribution Function (CDF)
      cdf_val = sps.t.cdf(t_val, 1e10)
      # Set a minimum threshold for p-values to avoid infinite z-scores
      p_val = np.array(
          np.minimum(np.maximum(p_val, 1.0e-300), 1.0 - 1.0e-16)
      )
      cdf_val = np.array(
          np.minimum(np.maximum(cdf_val, 1.0e-300), 1.0 - 1.0e-16)
      )
      # Compute z-score from the p-value estimated with the SF
      z_val_sf = norm.isf(p_val)
      # Compute z-score from the p-value estimated with the CDF
      z_val_cdf = norm.ppf(cdf_val)
      # Create the final array of z-scores, ...
      z_val = np.zeros(p_val.size)
      # ... in which z-scores < 0 estimated w/ SF are replaced by z-scores < 0
      # estimated w/ CDF
      z_val[np.atleast_1d(z_val_sf < 0)] = z_val_cdf[z_val_sf < 0]
      # ... and z-scores >=0 estimated from SF are kept.
      z_val[np.atleast_1d(z_val_sf >= 0)] = z_val_sf[z_val_sf >= 0]
  
      # Test 'z_score' function in 'nilearn/glm/contrasts.py'
      assert_array_almost_equal(
          z_score(p_val, one_minus_pvalue=cdf_val), z_val
      )
  
      # Test 'z_score' function in 'nilearn/glm/contrasts.py',
      # when one_minus_pvalue is None
      assert_array_almost_equal(norm.sf(z_score(p_val)), p_val)
  
imports: import numpy
  import pytest
  import scipy.linalg
  import scipy.stats
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from scipy.stats import norm
  from nilearn._utils.data_gen import generate_fake_fmri
  from nilearn.glm._utils import full_rank, multiple_fast_inverse, multiple_mahalanobis, pad_contrast, positive_reciprocal, z_score
  from nilearn.glm.first_level import FirstLevelModel, make_first_level_design_matrix
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 2 for calling a global function with example usage: test_z_score_t_values(rng) without return types