code: def create_mapping_from_multimod_arrayfiles(
      array_files,
      field,
      modalities,
      mod_to_train,
      cutoff,
      masking_function,
  ):
      """
      Performs the mapping creation based on a list of files. For each of the
      files (potentially multimodal), the landmarks are defined for each
      modality and stored in a database. The average of these landmarks is
      returned providing the landmarks to use for the linear mapping of any
      new incoming data
  
      :param array_files: List of image files to use
      :param modalities: Name of the modalities used for the
          standardisation and the corresponding order in the multimodal files
      :param cutoff: Minimum and maximum landmarks percentile values to use for
          the mapping
      :param masking_function: Describes how the mask is defined for each image.
      :return:
      """
      perc_database = {}
      for i, p in enumerate(array_files):
          print_progress_bar(
              i,
              len(array_files),
              prefix="normalisation histogram training",
              decimals=1,
              length=10,
              fill="*",
          )
          img_data = p[field].get_data()
          assert img_data.shape[4] == len(
              modalities
          ), "number of modalities are not consistent in the input image"
          for mod_i, m in enumerate(modalities):
              if m not in mod_to_train:
                  continue
              if m not in perc_database.keys():
                  perc_database[m] = []
              for t in range(img_data.shape[3]):
                  img_3d = img_data[..., t, mod_i]
                  if masking_function is not None:
                      mask_3d = masking_function(img_3d)
                  else:
                      mask_3d = np.ones_like(img_3d, dtype=np.bool)
                  perc = __compute_percentiles(img_3d, mask_3d, cutoff)
                  perc_database[m].append(perc)
      mapping = {}
      for m in list(perc_database):
          perc_database[m] = np.vstack(perc_database[m])
          s1, s2 = create_standard_range()
          mapping[m] = tuple(
              __averaged_mapping(perc_database[m], s1, s2)
          )
      return mapping
  
file_path: NiftyNet/niftynet/utilities/histogram_standardisation.py
imports: from __future__ import absolute_import, print_function, division
  import os
  import numpy
  import numpy.ma
  import tensorflow
  from niftynet.io.misc_io import touch_folder
  from niftynet.utilities.util_common import look_up_operations, print_progress_bar
label_desc: Use image node_id 3 for calling a global function with example usage: create_mapping_from_multimod_arrayfiles(array_files, field, modalities, mod_to_train, cutoff, masking_function) and returns: mapping