code: def test_second_level_contrast_computation(tmp_path, rng):
      func_img, mask = fake_fmri_data(file_path=tmp_path)
  
      model = SecondLevelModel(mask_img=mask)
  
      # fit model
      Y = [func_img] * 4
      X = pd.DataFrame([[1]] * 4, columns=["intercept"])
      model = model.fit(Y, design_matrix=X)
  
      ncol = len(model.design_matrix_.columns)
      c1, _ = np.eye(ncol)[0, :], np.zeros(ncol)
  
      # smoke test for different contrasts in fixed effects
      model.compute_contrast(second_level_contrast=c1)
      z_image = model.compute_contrast(
          second_level_contrast=c1, output_type="z_score"
      )
      stat_image = model.compute_contrast(
          second_level_contrast=c1, output_type="stat"
      )
      p_image = model.compute_contrast(
          second_level_contrast=c1, output_type="p_value"
      )
      effect_image = model.compute_contrast(
          second_level_contrast=c1, output_type="effect_size"
      )
      variance_image = model.compute_contrast(
          second_level_contrast=c1, output_type="effect_variance"
      )
  
      # Test output_type='all', and verify images are equivalent
      all_images = model.compute_contrast(
          second_level_contrast=c1, output_type="all"
      )
      assert_array_equal(
          get_data(all_images["z_score"]), get_data(z_image)
      )
      assert_array_equal(
          get_data(all_images["stat"]), get_data(stat_image)
      )
      assert_array_equal(
          get_data(all_images["p_value"]), get_data(p_image)
      )
      assert_array_equal(
          get_data(all_images["effect_size"]), get_data(effect_image)
      )
      assert_array_equal(
          get_data(all_images["effect_variance"]),
          get_data(variance_image),
      )
  
      # formula should work (passing variable name directly)
      model.compute_contrast("intercept")
      # or simply pass nothing
      model.compute_contrast()
  
      # formula as contrasts
      X = pd.DataFrame(rng.uniform(size=(4, 2)), columns=["r1", "r2"])
      model = model.fit(Y, design_matrix=X)
      model.compute_contrast(second_level_contrast="r1 - r2")
  
imports: import os
  from pathlib import Path
  import numpy
  import pandas
  import pytest
  from nibabel import Nifti1Image, load
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from scipy import stats
  from nilearn._utils import testing
  from nilearn._utils.data_gen import generate_fake_fmri_data_and_design, write_fake_bold_img, write_fake_fmri_data_and_design
  from nilearn.glm.first_level import FirstLevelModel, run_glm
  from nilearn.glm.second_level import SecondLevelModel, non_parametric_inference
  from nilearn.glm.second_level.second_level import _check_confounds, _check_design_matrix, _check_effect_maps, _check_first_level_contrast, _check_input_as_first_level_model, _check_output_type, _check_second_level_input, _infer_effect_maps, _process_second_level_input_as_dataframe, _process_second_level_input_as_firstlevelmodels, _sort_input_dataframe
  from nilearn.image import concat_imgs, get_data, new_img_like, smooth_img
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 42 for calling a global function with example usage: test_second_level_contrast_computation(tmp_path, rng) without return types