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 images and cast to bool
      images = []
      for input_ in args.inputs:
          t = load(input_)
          images.append((t[0], t[1]))
  
      # check if their shapes and voxel spacings are all equal
      s0 = images[0][0].shape
      if not numpy.all([i[0].shape == s0 for i in images[1:]]):
          raise argparse.ArgumentError(
              args.input,
              "At least one input image is of a different shape than the others.",
          )
      vs0 = header.get_pixel_spacing(images[0][1])
      if not numpy.all(
          [header.get_pixel_spacing(i[1]) == vs0 for i in images[1:]]
      ):
          raise argparse.ArgumentError(
              args.input,
              "At least one input image has a different voxel spacing than the others.",
          )
  
      # execute operation
      logger.debug(
          "Executing operation {} over {} images.".format(
              args.operation, len(images)
          )
      )
      if "max" == args.operation:
          out = numpy.maximum.reduce([t[0] for t in images])
      elif "min" == args.operation:
          out = numpy.minimum.reduce([t[0] for t in images])
      elif "sum" == args.operation:
          out = numpy.sum([t[0] for t in images], 0).astype(numpy.uint8)
      else:  # avg
          out = numpy.average([t[0] for t in images], 0).astype(
              numpy.float32
          )
  
      # save output
      save(out, args.output, images[0][1], args.force)
  
      logger.info("Successfully terminated.")
  
file_path: medpy/bin/medpy_join_masks.py
imports: import sys
  import argparse
  import logging
  import numpy
  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