code: def _load_mixed_gambles(zmap_imgs):
      """Ravel zmaps (one per subject) along time axis, resulting, \
      in a n_subjects * n_trials 3D niimgs and, and then make \
      gain vector y of same length."""
      X = []
      y = []
      mask = []
      for zmap_img in zmap_imgs:
          # load subject data
          this_X = get_data(zmap_img)
          affine = zmap_img.affine
          finite_mask = np.all(np.isfinite(this_X), axis=-1)
          this_mask = np.logical_and(
              np.all(this_X != 0, axis=-1), finite_mask
          )
          this_y = np.array([np.arange(1, 9)] * 6).ravel()
  
          # gain levels
          if len(this_y) != this_X.shape[-1]:
              raise RuntimeError(
                  f"{zmap_img}: Expecting {len(this_y)} volumes, "
                  f"got {this_X.shape[-1]}!"
              )
  
          # standardize subject data
          this_X -= this_X.mean(axis=-1)[..., np.newaxis]
          std = this_X.std(axis=-1)
          std[std == 0] = 1
          this_X /= std[..., np.newaxis]
  
          # commit subject data
          X.append(this_X)
          y.extend(this_y)
          mask.append(this_mask)
      y = np.array(y)
      X = np.concatenate(X, axis=-1)
      mask = np.sum(mask, axis=0) > 0.5 * len(mask)
      mask = np.logical_and(mask, np.all(np.isfinite(X), axis=-1))
      X = X[mask, :].T
      tmp = np.zeros(list(mask.shape) + [len(X)])
      tmp[mask, :] = X.T
      mask_img = nibabel.Nifti1Image(mask.astype("uint8"), affine)
      X = nibabel.four_to_three(nibabel.Nifti1Image(tmp, affine))
      return X, y, mask_img
  
imports: import fnmatch
  import glob
  import json
  import numbers
  import os
  import re
  import warnings
  from io import BytesIO
  from pathlib import Path
  import nibabel
  import nibabel
  import numpy
  import pandas
  from scipy.io import loadmat
  from sklearn.utils import Bunch
  from nilearn.image import get_data
  from .._utils import check_niimg, fill_doc
  from .._utils.numpy_conversions import csv_to_array
  from ._utils import fetch_files, fetch_single_file, filter_columns, get_dataset_descr, get_dataset_dir, read_md5_sum_file, tree, uncompress_file
label_desc: Use image node_id 10 for calling a global function with example usage: _load_mixed_gambles(zmap_imgs) and returns: X,  y,  mask_img