code: def _simu_img(tmp_path, demean):
      """Simulate an nifti image based on confound file \
      with some parts confounds and some parts noise."""
      file_nii, _ = create_tmp_filepath(tmp_path, copy_confounds=True)
      # set the size of the image matrix
      nx = 5
      ny = 5
      # the actual number of slices will actually be double of that
      # as we will stack slices with confounds on top of slices with noise
      nz = 2
      # Load a simple 6 parameters motion models as confounds
      # demean set to False just for simulating signal based on the original
      # state
      confounds, _ = load_confounds(
          file_nii, strategy=("motion",), motion="basic", demean=False
      )
  
      X = _handle_non_steady(confounds)
      X = X.values
      # the number of time points is based on the example confound file
      nt = X.shape[0]
      # initialize an empty 4D volume
      vol = np.zeros([nx, ny, 2 * nz, nt])
      vol_conf = np.zeros([nx, ny, 2 * nz])
      vol_rand = np.zeros([nx, ny, 2 * nz])
  
      # create random noise and a random mixture of confounds standardized
      # to zero mean and unit variance
      rng = _rng()
      beta = rng.random((nx * ny * nz, X.shape[1]))
      tseries_rand = scale(rng.random((nx * ny * nz, nt)), axis=1)
      # create the confound mixture
      tseries_conf = scale(np.matmul(beta, X.transpose()), axis=1)
  
      # fill the first half of the 4D data with the random mixture
      vol[:, :, 0:nz, :] = tseries_conf.reshape(nx, ny, nz, nt)
      vol_conf[:, :, 0:nz] = 1
  
      # create random noise in the second half of the 4D data
      vol[:, :, range(nz, 2 * nz), :] = tseries_rand.reshape(
          nx, ny, nz, nt
      )
      vol_rand[:, :, range(nz, 2 * nz)] = 1
  
      # Shift the mean to non-zero
      vol = vol + 10
  
      # create an nifti image with the data, and corresponding mask
      img = Nifti1Image(vol, np.eye(4))
      mask_conf = Nifti1Image(vol_conf, np.eye(4))
      mask_rand = Nifti1Image(vol_rand, np.eye(4))
  
      # generate the associated confounds for testing
      test_confounds, _ = load_confounds(
          file_nii, strategy=("motion",), motion="basic", demean=demean
      )
      # match how we extend the length to increase the degree of freedom
      test_confounds = _handle_non_steady(test_confounds)
      sample_mask = np.arange(test_confounds.shape[0])[1:]
      return img, mask_conf, mask_rand, test_confounds, sample_mask
  
imports: import re
  import numpy
  import pandas
  import pytest
  from nibabel import Nifti1Image
  from scipy.stats import pearsonr
  from sklearn.preprocessing import scale
  from nilearn._utils.data_gen import create_fake_bids_dataset
  from nilearn._utils.fmriprep_confounds import to_camel_case
  from nilearn.conftest import _rng
  from nilearn.interfaces.bids import get_bids_files
  from nilearn.interfaces.fmriprep import load_confounds
  from nilearn.interfaces.fmriprep.load_confounds import _check_strategy, _load_single_confounds_file
  from nilearn.interfaces.fmriprep.tests._testing import create_tmp_filepath, get_legal_confound
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 1 for calling a global function with example usage: _simu_img(tmp_path, demean) and returns: img,  mask_conf,  mask_rand,  test_confounds,  sample_mask