code: def test_surrogate_array_3d_mask():
      """Check that 3D version works when a mask is provided"""
      shape = (5, 6, 7)
      mask = np.random.rand(*shape) > 0.5
      mask_img = Nifti1Image(mask.astype(np.uint8), np.eye(4))
      img = surrogate_3d_dataset(mask=mask_img)
      mean_image = img[mask].mean()
      assert (img[mask == 0] == 0).all()
  
file_path: nipy/nipy/labs/utils/tests/test_simul_multisubject_fmri_dataset.py
imports: import numpy
  from nibabel import Nifti1Image
  from ..simul_multisubject_fmri_dataset import surrogate_2d_dataset, surrogate_3d_dataset, surrogate_4d_dataset
label_desc: Use image node_id 4 for calling a global function with example usage: test_surrogate_array_3d_mask() without return types