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)
      img = img.astype(numpy.bool_)
  
      # check spacing values
      if not len(args.spacing) == img.ndim:
          parser.error(
              "The image has {} dimensions, but {} spacing parameters have been supplied.".format(
                  img.ndim, len(args.spacing)
              )
          )
  
      # check if output image exists
      if not args.force:
          if os.path.exists(args.output):
              parser.error(
                  "The output image {} already exists.".format(
                      args.output
                  )
              )
  
      logger.debug("target voxel spacing: {}".format(args.spacing))
  
      # determine number of required complete slices for up-sampling
      vs = header.get_pixel_spacing(hdr)
      rcss = [
          int(y // x - 1) for x, y in zip(args.spacing, vs)
      ]  # TODO: For option b, remove the - 1; better: no option b, since I am rounding later anyway
  
      # remove negatives and round up to next even number
      rcss = [x if x > 0 else 0 for x in rcss]
      rcss = [x if 0 == x % 2 else x + 1 for x in rcss]
      logger.debug(
          "intermediate slices to add per dimension: {}".format(rcss)
      )
  
      # for each dimension requiring up-sampling, from the highest down, perform shape based slice interpolation
      logger.info(
          "Adding required slices using shape based interpolation."
      )
      for dim, rcs in enumerate(rcss):
          if rcs > 0:
              logger.debug(
                  "adding {} intermediate slices to dimension {}".format(
                      rcs, dim
                  )
              )
              img = shape_based_slice_interpolation(img, dim, rcs)
              logger.debug(
                  "resulting new image shape: {}".format(img.shape)
              )
  
      # compute and set new voxel spacing
      nvs = [x / (y + 1.0) for x, y in zip(vs, rcss)]
      header.set_pixel_spacing(hdr, nvs)
      logger.debug("intermediate voxel spacing: {}".format(nvs))
  
      # interpolate with nearest neighbour
      logger.info(
          "Re-sampling the image with a b-spline order of {}.".format(
              args.order
          )
      )
      img, hdr = resample(
          img, hdr, args.spacing, args.order, mode="nearest"
      )
  
      # saving the resulting image
      save(img, args.output, hdr, args.force)
  
file_path: medpy/bin/medpy_binary_resampling.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