code: def _create_image(file_list, idx, modalities, data_param):
      """
      data_param consists of description of each modality
      This function combines modalities according to the 'modalities'
      parameter and create <niftynet.io.input_type.SpatialImage*D>
      """
      try:
          file_path = tuple(
              file_list.iloc[idx][mod] for mod in modalities
          )
          any_missing = any(
              [
                  pandas.isnull(file_name) or not bool(file_name)
                  for file_name in file_path
              ]
          )
          if any_missing:
              # todo: enable missing modalities again
              # the file_path of a multimodal image will contain `nan`, e.g.
              # this should be handled by `ImageFactory.create_instance`
              # ('testT1.nii.gz', 'testT2.nii.gz', nan, 'testFlair.nii.gz')
              return None
  
          interp_order, pixdim, axcodes, loader = [], [], [], []
          for mod in modalities:
              mod_spec = (
                  data_param[mod]
                  if isinstance(data_param[mod], dict)
                  else vars(data_param[mod])
              )
              interp_order.append(
                  mod_spec.get("interp_order", DEFAULT_INTERP_ORDER)
              )
              pixdim.append(mod_spec.get("pixdim", None))
              axcodes.append(mod_spec.get("axcodes", None))
              loader.append(mod_spec.get("loader", None))
  
      except KeyError:
          tf.logging.fatal(
              "Specified modality names %s "
              "not found in config: input sections %s.",
              modalities,
              list(data_param),
          )
          raise
      except AttributeError:
          tf.logging.fatal(
              "Data params must contain: interp_order, pixdim, axcodes.\n"
              "Reader must be initialised with a dataframe as file_list."
          )
          raise
  
      image_properties = {
          "file_path": file_path,
          "name": modalities,
          "interp_order": interp_order,
          "output_pixdim": pixdim,
          "output_axcodes": axcodes,
          "loader": loader,
      }
      return ImageFactory.create_instance(**image_properties)
  
imports: from __future__ import absolute_import, division, print_function
  from copy import deepcopy
  import argparse
  import numpy
  import pandas
  import tensorflow
  from six import string_types
  from niftynet.io.misc_io import dtype_casting
  from niftynet.io.image_sets_partitioner import COLUMN_UNIQ_ID
  from niftynet.io.image_type import ImageFactory
  from niftynet.layer.base_layer import Layer, DataDependentLayer, RandomisedLayer
  from niftynet.utilities.user_parameters_helper import make_input_tuple
  from niftynet.utilities.util_common import print_progress_bar, ParserNamespace
  from niftynet.io.image_sets_partitioner import ImageSetsPartitioner
  from niftynet.utilities.util_common import look_up_operations
label_desc: Use image node_id 3 for calling a global function with example usage: _create_image(file_list, idx, modalities, data_param) and returns: ImageFactory, None