code: def fname_presuffix(
      fname, prefix="", suffix="", newpath=None, use_ext=True
  ):
      """Manipulates path and name of input filename
  
      Parameters
      ----------
      fname : string
          A filename (may or may not include path)
      prefix : string
          Characters to prepend to the filename
      suffix : string
          Characters to append to the filename
      newpath : string
          Path to replace the path of the input fname
      use_ext : boolean
          If True (default), appends the extension of the original file
          to the output name.
  
      Returns
      -------
      Absolute path of the modified filename
  
      >>> from nipype.utils.filemanip import fname_presuffix
      >>> fname = 'foo.nii.gz'
      >>> fname_presuffix(fname,'pre','post','/tmp')
      '/tmp/prefoopost.nii.gz'
  
      >>> from nipype.interfaces.base import Undefined
      >>> fname_presuffix(fname, 'pre', 'post', Undefined) == \
              fname_presuffix(fname, 'pre', 'post')
      True
  
      """
      pth, fname, ext = split_filename(fname)
      if not use_ext:
          ext = ""
  
      # No need for isdefined: bool(Undefined) evaluates to False
      if newpath:
          pth = op.abspath(newpath)
      return op.join(pth, prefix + fname + suffix + ext)
  
imports: import sys
  import pickle
  import errno
  import subprocess
  import gzip
  import hashlib
  import locale
  from hashlib import md5
  import os
  import os.path
  import re
  import shutil
  import contextlib
  import posixpath
  from pathlib import Path
  import simplejson
  from time import sleep, time
  from ..None import logging, config, __version__
  from .misc import is_container
label_desc: Use image node_id 2 for calling a global function with example usage: fname_presuffix(fname, prefix, suffix, newpath, use_ext) and returns: op