code: def main():
      args = getArguments(getParser())
  
      # prepare logger
      logger = Logger.getInstance()
      if args.debug:
          logger.setLevel(logging.DEBUG)
      elif args.verbose:
          logger.setLevel(logging.INFO)
  
      # load input image
      data_input, header_input = load(args.input)
  
      logger.debug("Original shape = {}.".format(data_input.shape))
  
      # check if supplied dimension parameters is inside the images dimensions
      if args.dimension1 >= data_input.ndim or args.dimension1 < 0:
          raise ArgumentError(
              "The first swap-dimension {} exceeds the number of input volume dimensions {}.".format(
                  args.dimension1, data_input.ndim
              )
          )
      elif args.dimension2 >= data_input.ndim or args.dimension2 < 0:
          raise ArgumentError(
              "The second swap-dimension {} exceeds the number of input volume dimensions {}.".format(
                  args.dimension2, data_input.ndim
              )
          )
  
      # swap axes
      data_output = scipy.swapaxes(
          data_input, args.dimension1, args.dimension2
      )
      # swap pixel spacing and offset
      ps = list(header.get_pixel_spacing(header_input))
      ps[args.dimension1], ps[args.dimension2] = (
          ps[args.dimension2],
          ps[args.dimension1],
      )
      header.set_pixel_spacing(header_input, ps)
      os = list(header.get_offset(header_input))
      os[args.dimension1], os[args.dimension2] = (
          os[args.dimension2],
          os[args.dimension1],
      )
      header.set_offset(header_input, os)
  
      logger.debug("Resulting shape = {}.".format(data_output.shape))
  
      # save resulting volume
      save(data_output, args.output, header_input, args.force)
  
      logger.info("Successfully terminated.")
  
file_path: medpy/bin/medpy_swap_dimensions.py
imports: import argparse
  import logging
  import scipy
  from medpy.core import Logger
  from medpy.io import load, save, header
  from medpy.core.exceptions import ArgumentError
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types