code: def main():
      # parse cmd arguments
      parser = getParser()
      parser.parse_args()
      args = getArguments(parser)
  
      # prepare logger
      logger = Logger.getInstance()
      if args.debug:
          logger.setLevel(logging.DEBUG)
      elif args.verbose:
          logger.setLevel(logging.INFO)
  
      # load first input image as example
      example_data, example_header = load(args.inputs[0])
  
      # test if the supplied position is valid
      if args.position > example_data.ndim or args.position < 0:
          raise ArgumentError(
              "The supplied position for the new dimension is invalid. It has to be between 0 and {}.".format(
                  example_data.ndim
              )
          )
  
      # prepare empty output volume
      output_data = scipy.zeros(
          [len(args.inputs)] + list(example_data.shape),
          dtype=example_data.dtype,
      )
  
      # add first image to output volume
      output_data[0] = example_data
  
      # load input images and add to output volume
      for idx, image in enumerate(args.inputs[1:]):
          image_data, _ = load(image)
          if not args.ignore and image_data.dtype != example_data.dtype:
              raise ArgumentError(
                  "The dtype {} of image {} differs from the one of the first image {}, which is {}.".format(
                      image_data.dtype,
                      image,
                      args.inputs[0],
                      example_data.dtype,
                  )
              )
          if image_data.shape != example_data.shape:
              raise ArgumentError(
                  "The shape {} of image {} differs from the one of the first image {}, which is {}.".format(
                      image_data.shape,
                      image,
                      args.inputs[0],
                      example_data.shape,
                  )
              )
          output_data[idx + 1] = image_data
  
      # move new dimension to the end or to target position
      for dim in range(output_data.ndim - 1):
          if dim >= args.position:
              break
          output_data = scipy.swapaxes(output_data, dim, dim + 1)
  
      # set pixel spacing
      spacing = list(header.get_pixel_spacing(example_header))
      spacing = tuple(
          spacing[: args.position]
          + [args.spacing]
          + spacing[args.position :]
      )
      example_header.set_voxel_spacing(spacing)
  
      # save created volume
      save(output_data, args.output, example_header, args.force)
  
      logger.info("Successfully terminated.")
  
file_path: medpy/bin/medpy_join_xd_to_xplus1d.py
imports: import argparse
  from argparse import RawTextHelpFormatter
  import logging
  import scipy
  from medpy.io import load, save, header
  from medpy.core import Logger
  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