code: def get_reference_info(reference):
      """Will compare the spatial attribute of 2 references.
  
      Parameters
      ----------
      reference : Nifti or Trk filename, Nifti1Image or TrkFile, Nifti1Header or
          trk.header (dict), TrxFile or trx.header (dict)
          Reference that provides the spatial attribute.
      Returns
      -------
      output : tuple
          - affine ndarray (4,4), np.float32, transformation of VOX to RASMM
          - dimensions ndarray (3,), int16, volume shape for each axis
          - voxel_sizes  ndarray (3,), float32, size of voxel for each axis
          - voxel_order, string, Typically 'RAS' or 'LPS'
      """
  
      is_nifti = False
      is_trk = False
      is_sft = False
      is_trx = False
      if isinstance(reference, str):
          _, ext = split_name_with_gz(reference)
          ext = ext.lower()
          if ext in [".nii", ".nii.gz"]:
              header = nib.load(reference).header
              is_nifti = True
          elif ext == ".trk":
              header = nib.streamlines.load(
                  reference, lazy_load=True
              ).header
              is_trk = True
          elif ext == ".trx":
              header = trx_file_memmap.load(reference).header
              is_trx = True
      elif isinstance(reference, trx_file_memmap.TrxFile):
          header = reference.header
          is_trx = True
      elif isinstance(reference, nib.nifti1.Nifti1Image):
          header = reference.header
          is_nifti = True
      elif isinstance(reference, nib.streamlines.trk.TrkFile):
          header = reference.header
          is_trk = True
      elif isinstance(reference, nib.nifti1.Nifti1Header):
          header = reference
          is_nifti = True
      elif isinstance(reference, dict) and "magic_number" in reference:
          header = reference
          is_trk = True
      elif isinstance(reference, dict) and "NB_VERTICES" in reference:
          header = reference
          is_trx = True
      elif isinstance(
          reference, dipy.io.stateful_tractogram.StatefulTractogram
      ):
          is_sft = True
  
      if is_nifti:
          affine = header.get_best_affine()
          dimensions = header["dim"][1:4]
          voxel_sizes = header["pixdim"][1:4]
  
          if not affine[0:3, 0:3].any():
              raise ValueError(
                  "Invalid affine, contains only zeros."
                  "Cannot determine voxel order from transformation"
              )
          voxel_order = "".join(nib.aff2axcodes(affine))
      elif is_trk:
          affine = header["voxel_to_rasmm"]
          dimensions = header["dimensions"]
          voxel_sizes = header["voxel_sizes"]
          voxel_order = header["voxel_order"]
      elif is_sft:
          (
              affine,
              dimensions,
              voxel_sizes,
              voxel_order,
          ) = reference.space_attributes
      elif is_trx:
          affine = header["VOXEL_TO_RASMM"]
          dimensions = header["DIMENSIONS"]
          voxel_sizes = nib.affines.voxel_sizes(affine)
          voxel_order = "".join(nib.aff2axcodes(affine))
      else:
          raise TypeError(
              "Input reference is not one of the supported format"
          )
  
      if isinstance(voxel_order, np.bytes_):
          voxel_order = voxel_order.decode("utf-8")
  
      is_reference_info_valid(
          affine, dimensions, voxel_sizes, voxel_order
      )
  
      return (
          affine.astype(np.float32),
          dimensions,
          voxel_sizes,
          voxel_order,
      )
  
imports: import logging
  import numbers
  import os
  from dipy.utils.optpkg import optional_package
  import dipy
  import nibabel
  from nibabel.streamlines import detect_format
  from nibabel import Nifti1Image
  import numpy
  from trx import trx_file_memmap
label_desc: Use image node_id 7 for calling a global function with example usage: get_reference_info(reference) and returns: affine,  dimensions,  voxel_sizes,  voxel_order