code: def main():
      parser = getParser()
      args = getArguments(parser)
  
      # prepare logger
      logger = Logger.getInstance()
      if args.debug:
          logger.setLevel(logging.DEBUG)
      elif args.verbose:
          logger.setLevel(logging.INFO)
  
      # loading input images
      img, hdr = load(args.input)
  
      # check shape dimensionality
      if not len(args.shape) == img.ndim:
          parser.error(
              "The image has {} dimensions, but {} shape parameters have been supplied.".format(
                  img.ndim, len(args.shape)
              )
          )
  
      # check if output image exists
      if not args.force and os.path.exists(args.output):
          parser.error(
              "The output image {} already exists.".format(args.output)
          )
  
      # compute required cropping and extention
      slicers_cut = []
      slicers_extend = []
      for dim in range(len(img.shape)):
          slicers_cut.append(slice(None))
          slicers_extend.append(slice(None))
          if args.shape[dim] != img.shape[dim]:
              difference = abs(img.shape[dim] - args.shape[dim])
              cutoff_left = difference / 2
              cutoff_right = difference / 2 + difference % 2
              if args.shape[dim] > img.shape[dim]:
                  slicers_extend[-1] = slice(
                      cutoff_left, -1 * cutoff_right
                  )
              else:
                  slicers_cut[-1] = slice(
                      cutoff_left, -1 * cutoff_right
                  )
  
      # crop original image
      img = img[slicers_cut]
  
      # create output image and place input image centered
      out = numpy.zeros(args.shape, img.dtype)
      out[slicers_extend] = img
  
      # saving the resulting image
      save(out, args.output, hdr, args.force)
  
file_path: medpy/bin/medpy_fit_into_shape.py
imports: import os
  import logging
  import argparse
  import numpy
  from scipy.ndimage import zoom
  from scipy.ndimage import distance_transform_edt, binary_erosion
  from scipy.ndimage import label
  from medpy.core import Logger
  from medpy.filter import resample, bounding_box
  from medpy.utilities import argparseu
  from medpy.io import load, save, header
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types