code: def replace_suffix(
      input_filepath,
      input_suffix,
      output_suffix,
      suffix_delimiter=None,
      file_extension=None,
  ):
      """Replaces an input_suffix in a filename with an output_suffix. Can be used
      to generate or remove suffixes by leaving one or the other option blank.
  
      Parameters
      ----------
      input_filepath: str
          The filename to be transformed.
      input_suffix: str
          The suffix to be replaced
      output_suffix: str
          The suffix to replace with.
      suffix_delimiter: str
          Optional, overrides input_suffix. Replaces whatever
          comes after suffix_delimiter with output_suffix.
  
      Returns
      -------
      output_filepath: str
          The transformed filename
      """
  
      # Temp code to deal with directories, TODO
      if os.path.isdir(input_filepath):
          output_filepath = (
              input_filepath + output_suffix + file_extension
          )
          return output_filepath
  
      else:
          if "." in os.path.basename(input_filepath):
              split_filename = nifti_splitext(input_filepath)
          else:
              split_filename = [input_filepath, ""]
  
          if suffix_delimiter is not None:
              input_suffix = str.split(
                  split_filename[0], suffix_delimiter
              )[-1]
  
          if input_suffix not in os.path.basename(input_filepath):
              print(("ERROR!", input_suffix, "not in input_filepath."))
              return []
  
          else:
              if input_suffix == "":
                  prefix = split_filename[0]
              else:
                  prefix = input_suffix.join(
                      str.split(split_filename[0], input_suffix)[0:-1]
                  )
              prefix = prefix + output_suffix
              output_filepath = prefix + split_filename[1]
  
              if file_extension is not None:
                  replace_extension(output_filepath, file_extension)
  
              return output_filepath
  
file_path: DeepNeuro/deepneuro/utilities/util.py
imports: import glob
  import math
  import numpy
  import os
  import fnmatch
  import sys
label_desc: Use image node_id 8 for calling a global function with example usage: replace_suffix(input_filepath, input_suffix, output_suffix, suffix_delimiter, file_extension) and returns: output_filepath, list, output_filepath