code: def main():
      if len(sys.argv) <= 1:
          usage()
  
      if sys.version_info < (2, 4):
          import sets
          from sets import Set
  
          setAvailable = False
      else:
          setAvailable = True
  
      deleteExtensions = True
      primaryExtensions = [".nii.gz", ".nii", ".hdr.gz", ".hdr"]
      secondaryExtensions = [".img.gz", ".img"]
      allExtensions = primaryExtensions + secondaryExtensions
      validExtensions = primaryExtensions
      startingArg = 1
  
      if sys.argv[1] == "-extensions":
          validExtensions = allExtensions
          deleteExtensions = False
          startingArg = 2
      if sys.argv[1] == "-extension":
          deleteExtensions = False
          startingArg = 2
  
      filelist = []
      for arg in range(startingArg, len(sys.argv)):
          #      #These if enables a "pedantic" style mode currently not used
          #      if isImage(sys.argv[arg],allExtensions)[0]:
          #         filelist.extend(glob.glob(sys.argv[arg]))
          #      else:
          #         for currentExtension in validExtensions:
          #            filelist.extend(glob.glob(sys.argv[arg]+currentExtension))
          for currentExtension in validExtensions:
              filelist.extend(
                  glob.glob(
                      removeImageExtension(sys.argv[arg], allExtensions)
                      + currentExtension
                  )
              )
  
      if deleteExtensions:
          for file in range(0, len(filelist)):
              filelist[file] = removeImageExtension(
                  filelist[file], allExtensions
              )
      if setAvailable:
          filelist = list(set(filelist))
      else:
          filelist = list(Set(filelist))
      filelist.sort()
  
      for file in range(0, len(filelist)):
          print(filelist[file], end=" ")
          if file < len(filelist) - 1:
              print(" ", end=" ")
  
imports: import sys
  import glob
label_desc: Use image node_id 4 for calling a global function with example usage: main() without return types