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 data
      input_data, input_header = load(args.input)
  
      logger.debug("Old shape = {}.".format(input_data.shape))
  
      # compute new shape
      new_shape = list(input_data.shape)
      new_shape[args.dimension] = 1 + (
          new_shape[args.dimension] - 1
      ) / (args.discard + 1)
  
      # prepare output image
      output_data = scipy.zeros(new_shape, dtype=input_data.dtype)
  
      # prepare slicers
      slicer_in = [slice(None)] * input_data.ndim
      slicer_out = [slice(None)] * input_data.ndim
  
      # prepare skip-counter and output image slice counter
      skipc = 0
      slicec = 0
  
      logger.debug(
          "Shrinking from {} to {}...".format(
              input_data.shape, new_shape
          )
      )
      for idx in range(input_data.shape[args.dimension]):
          if 0 == skipc:
              # transfer slice
              slicer_in[args.dimension] = slice(idx, idx + 1)
              slicer_out[args.dimension] = slice(slicec, slicec + 1)
              output_data[slicer_out] = input_data[slicer_in]
  
              # resert resp. increase counter
              skipc = args.discard
              slicec += 1
  
          else:  # skip slice
              # decrease skip counter
              skipc -= 1
  
      # set new pixel spacing
      new_spacing = list(header.get_pixel_spacing(input_header))
      new_spacing[args.dimension] = new_spacing[args.dimension] * float(
          args.discard + 1
      )
      logger.debug(
          "Setting pixel spacing from {} to {}....".format(
              header.get_pixel_spacing(input_header), new_spacing
          )
      )
      header.set_pixel_spacing(input_header, tuple(new_spacing))
  
      save(output_data, args.output, input_header, args.force)
  
file_path: medpy/bin/medpy_shrink_image.py
imports: import argparse
  import logging
  import scipy
  from medpy.core import Logger
  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