class_docstr: Change the name of a file based on a mapped format string.
  
  To use additional inputs that will be defined at run-time, the class
  constructor must be called with the format template, and the fields
  identified will become inputs to the interface.
  
  Additionally, you may set the parse_string input, which will be run
  over the input filename with a regular expressions search, and will
  fill in additional input fields from matched groups. Fields set with
  inputs have precedence over fields filled in with the regexp match.
  
  Examples
  --------
  
  >>> from nipype.interfaces.utility import Rename
  >>> rename1 = Rename()
  >>> rename1.inputs.in_file = os.path.join(datadir, "zstat1.nii.gz") # datadir is a directory with exemplary files, defined in conftest.py
  >>> rename1.inputs.format_string = "Faces-Scenes.nii.gz"
  >>> res = rename1.run()          # doctest: +SKIP
  >>> res.outputs.out_file         # doctest: +SKIP
  'Faces-Scenes.nii.gz"            # doctest: +SKIP
  
  >>> rename2 = Rename(format_string="%(subject_id)s_func_run%(run)02d")
  >>> rename2.inputs.in_file = os.path.join(datadir, "functional.nii")
  >>> rename2.inputs.keep_ext = True
  >>> rename2.inputs.subject_id = "subj_201"
  >>> rename2.inputs.run = 2
  >>> res = rename2.run()          # doctest: +SKIP
  >>> res.outputs.out_file         # doctest: +SKIP
  'subj_201_func_run02.nii'        # doctest: +SKIP
  
  >>> rename3 = Rename(format_string="%(subject_id)s_%(seq)s_run%(run)02d.nii")
  >>> rename3.inputs.in_file = os.path.join(datadir, "func_epi_1_1.nii")
  >>> rename3.inputs.parse_string = r"func_(?P<seq>\w*)_.*"
  >>> rename3.inputs.subject_id = "subj_201"
  >>> rename3.inputs.run = 2
  >>> res = rename3.run()          # doctest: +SKIP
  >>> res.outputs.out_file         # doctest: +SKIP
  'subj_201_epi_run02.nii'         # doctest: +SKIP
class_docstr_tok: ["Change","the","name","of","a","file","based","on","a","mapped","format","string",".","To","use","additional","inputs","that","will","be","defined","at","run-time",",","the","class","constructor","must","be","called","with","the","format","template",",","and","the","fields","identified","will","become","inputs","to","the","interface",".","Additionally",",","you","may","set","the","parse_string","input",",","which","will","be","run","over","the","input","filename","with","a","regular","expressions","search",",","and","will","fill","in","additional","input","fields","from","matched","groups",".","Fields","set","with","inputs","have","precedence","over","fields","filled","in","with","the","regexp","match",".","Examples","--","--","--","--",">",">",">","from","nipype.interfaces.utility","import","Rename",">",">",">","rename1","=","Rename","(",")",">",">",">","rename1.inputs.in_file","=","os.path.join","(","datadir",",","``","zstat1.nii.gz","''",")","#","datadir","is","a","directory","with","exemplary","files",",","defined","in","conftest.py",">",">",">","rename1.inputs.format_string","=","``","Faces-Scenes.nii.gz","''",">",">",">","res","=","rename1.run","(",")","#","doctest",":","+SKIP",">",">",">","res.outputs.out_file","#","doctest",":","+SKIP","'Faces-Scenes.nii.gz","''","#","doctest",":","+SKIP",">",">",">","rename2","=","Rename","(","format_string=","''","%","(","subject_id",")","s_func_run","%","(","run",")","02d","''",")",">",">",">","rename2.inputs.in_file","=","os.path.join","(","datadir",",","``","functional.nii","''",")",">",">",">","rename2.inputs.keep_ext","=","True",">",">",">","rename2.inputs.subject_id","=","``","subj_201","''",">",">",">","rename2.inputs.run","=","2",">",">",">","res","=","rename2.run","(",")","#","doctest",":","+SKIP",">",">",">","res.outputs.out_file","#","doctest",":","+SKIP","'subj_201_func_run02.nii","'","#","doctest",":","+SKIP",">",">",">","rename3","=","Rename","(","format_string=","''","%","(","subject_id",")","s_","%","(","seq",")","s_run","%","(","run",")","02d.nii","''",")",">",">",">","rename3.inputs.in_file","=","os.path.join","(","datadir",",","``","func_epi_1_1.nii","''",")",">",">",">","rename3.inputs.parse_string","=","r","''","func_","(","?","P","<","seq",">","\\w","*",")","_",".","*","''",">",">",">","rename3.inputs.subject_id","=","``","subj_201","''",">",">",">","rename3.inputs.run","=","2",">",">",">","res","=","rename3.run","(",")","#","doctest",":","+SKIP",">",">",">","res.outputs.out_file","#","doctest",":","+SKIP","'subj_201_epi_run02.nii","'","#","doctest",":","+SKIP"]
code: def _rename(self):
      fmt_dict = dict()
      if isdefined(self.inputs.parse_string):
          if (
              isdefined(self.inputs.use_fullpath)
              and self.inputs.use_fullpath
          ):
              m = re.search(
                  self.inputs.parse_string, self.inputs.in_file
              )
          else:
              m = re.search(
                  self.inputs.parse_string,
                  os.path.split(self.inputs.in_file)[1],
              )
          if m:
              fmt_dict.update(m.groupdict())
      for field in self.fmt_fields:
          val = getattr(self.inputs, field)
          if isdefined(val):
              fmt_dict[field] = getattr(self.inputs, field)
      if self.inputs.keep_ext:
          fmt_string = "".join(
              [
                  self.inputs.format_string,
                  split_filename(self.inputs.in_file)[2],
              ]
          )
      else:
          fmt_string = self.inputs.format_string
      return fmt_string % fmt_dict
  
imports: import os
  import re
  import numpy
  from ..base import traits, TraitedSpec, DynamicTraitedSpec, File, Undefined, isdefined, OutputMultiPath, InputMultiPath, BaseInterface, BaseInterfaceInputSpec, Str, SimpleInterface
  from ..io import IOBase, add_traits
  from ...utils.filemanip import ensure_list, copyfile, split_filename
label_desc: Use image node_id 2 for calling the Rename obj's underlying member method code with example usage: obj._rename() and returns: unknown