code: def save_data_array(
      filefolder,
      filename,
      array_to_save,
      image_object=None,
      interp_order=3,
      reshape=True,
  ):
      """
      write image data array to hard drive using image_object
      properties such as affine, pixdim and axcodes.
  
      :param filefolder:
      :param filename:
      :param array_to_save:
      :param image_object:
      :param interp_order:
      :param reshape:
      :return:
      """
      if image_object is not None:
          affine = image_object.original_affine[0]
          image_pixdim = image_object.output_pixdim[0]
          image_axcodes = image_object.output_axcodes[0]
          dst_pixdim = image_object.original_pixdim[0]
          dst_axcodes = image_object.original_axcodes[0]
          original_shape = image_object.original_shape
      else:
          affine = np.eye(4)
          image_pixdim, dst_pixdim = (), ()
          image_axcodes, dst_axcodes = (), ()
          original_shape = ()
  
      if reshape:
          input_ndim = array_to_save.ndim
          if input_ndim == 1:
              # feature vector, should be saved with shape (1, 1, 1, 1, mod)
              while array_to_save.ndim < 5:
                  array_to_save = np.expand_dims(array_to_save, axis=0)
          elif input_ndim in (2, 3):
              # 2D or 3D images should be saved with shape (x, y, z, 1, 1)
              while array_to_save.ndim < 5:
                  array_to_save = np.expand_dims(array_to_save, axis=-1)
          elif input_ndim == 4:
              # recover a time dimension for nifti format output
              array_to_save = np.expand_dims(array_to_save, axis=3)
  
      if image_pixdim and dst_pixdim:
          if original_shape:
              # generating image_pixdim from original shape
              # so that `do_resampling` returns deterministic shape
              spatial_shape = np.asarray(
                  array_to_save.shape[:3], dtype=np.float
              )
              original_shape = np.asarray(
                  original_shape[:3], dtype=np.float
              )
              if image_axcodes and dst_axcodes:
                  transf, _, _ = compute_orientation(
                      image_axcodes, dst_axcodes
                  )
                  original_shape = tuple(
                      original_shape[k]
                      for k in transf[:, 0].astype(np.int)
                  )
              image_pixdim = dst_pixdim * np.divide(
                  original_shape, spatial_shape
              )
          array_to_save = do_resampling(
              array_to_save, image_pixdim, dst_pixdim, interp_order
          )
  
      if image_axcodes and dst_axcodes:
          array_to_save = do_reorientation(
              array_to_save, image_axcodes, dst_axcodes
          )
      save_volume_5d(array_to_save, filename, filefolder, affine)
  
imports: from __future__ import absolute_import, print_function, unicode_literals
  import errno
  import importlib
  import logging
  import os
  import re
  import sys
  import warnings
  import nibabel
  import numpy
  import pandas
  import scipy.ndimage
  import tensorflow
  from tensorflow.core.framework import summary_pb2
  from niftynet.io.image_loader import load_image_obj
  from niftynet.utilities.niftynet_global_config import NiftyNetGlobalConfig
  from niftynet.utilities.util_import import require_module
label_desc: Use image node_id 12 for calling a global function with example usage: save_data_array(filefolder, filename, array_to_save, image_object, interp_order, reshape) without return types