code: def do_reorientation_idx(
      idx_array, init_axcodes, final_axcodes, init_spatial_size
  ):
      """
      Perform the indices change based on the the orientation transformation
      :param idx_array: array of indices to transform when reorienting
      :param init_axcodes: initial orientation codes
      :param final_axcodes: target orientation codes
      :param init_spatial_size: initial image spatial size
      :return: new_idx the array of transformed indices and orientation transform
      """
      new_idx = idx_array
      if final_axcodes is None:
          ornt_transf, ornt_init, ornt_fin = compute_orientation(
              init_axcodes, init_axcodes
          )
          return new_idx, ornt_transf
      ornt_transf, ornt_init, ornt_fin = compute_orientation(
          init_axcodes, final_axcodes
      )
      # print(ornt_transf, ornt_init, "orientation prior idx transfo",
      #       idx_array.shape, init_spatial_size)
      if np.array_equal(ornt_init, ornt_fin):
          return new_idx, ornt_transf
      else:
          # print(ornt_transf[:, 0])
          # print(idx_array[:, np.asarray(ornt_transf[:,0],dtype=np.int32)])
          new_idx = idx_array[
              :, np.asarray(ornt_transf[:, 0], dtype=np.int32)
          ]
          # print("obtained new first", init_spatial_size)
          reorder_axes = np.squeeze(
              np.asarray(ornt_transf[:, 0], dtype=np.int32)
          )
          fin_spatial_size = [
              init_spatial_size[k] for k in reorder_axes
          ]
          for i in range(ornt_transf.shape[0]):
              if ornt_transf[i, 1] < 0:
                  new_idx[:, i] = fin_spatial_size[i] - np.asarray(
                      new_idx[:, i]
                  )
                  print("Updated idx for %d" % i)
          return new_idx, ornt_transf
  
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 8 for calling a global function with example usage: do_reorientation_idx(idx_array, init_axcodes, final_axcodes, init_spatial_size) and returns: new_idx,  ornt_transf, new_idx,  ornt_transf, new_idx,  ornt_transf