code: def test_high_level_glm_with_data(in_tmp_path):
      shapes, rk = ((7, 6, 5, 20), (7, 6, 5, 19)), 3
      mask, fmri_data, design_matrices = write_fake_fmri_data(
          shapes, rk
      )
  
      # without mask
      multi_session_model = FMRILinearModel(
          fmri_data, design_matrices, mask=None
      )
      multi_session_model.fit()
      (z_image,) = multi_session_model.contrast([np.eye(rk)[1]] * 2)
      assert np.sum(z_image.get_fdata() == 0) == 0
  
      # compute the mask
      multi_session_model = FMRILinearModel(
          fmri_data, design_matrices, m=0, M=0.01, threshold=0.0
      )
      multi_session_model.fit()
      (z_image,) = multi_session_model.contrast([np.eye(rk)[1]] * 2)
      assert z_image.get_fdata().std() < 3.0
  
      # with mask
      multi_session_model = FMRILinearModel(
          fmri_data, design_matrices, mask
      )
      multi_session_model.fit()
      (
          z_image,
          effect_image,
          variance_image,
      ) = multi_session_model.contrast(
          [np.eye(rk)[:2]] * 2,
          output_effects=True,
          output_variance=True,
      )
      assert_array_equal(
          z_image.get_fdata() == 0.0, load(mask).get_fdata() == 0.0
      )
      assert (
          variance_image.get_fdata()[load(mask).get_fdata() > 0, 0]
          > 0.001
      ).all()
  
      # without scaling
      multi_session_model.fit(do_scaling=False)
      (z_image,) = multi_session_model.contrast([np.eye(rk)[1]] * 2)
      assert z_image.get_fdata().std() < 3.0
  
imports: import numpy
  import pytest
  from nibabel import Nifti1Image, load, save
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from nipy.io.nibcompat import get_affine
  from nipy.testing import funcfile
  from nipy.testing.decorators import if_example_data
  from ..glm import FMRILinearModel, GeneralLinearModel, data_scaling
label_desc: Use image node_id 4 for calling a global function with example usage: test_high_level_glm_with_data(in_tmp_path) without return types