code: def get_boutiques_output(outputs, name, spec, interface, tool_inputs):
      """
      Returns a dictionary containing the Boutiques output corresponding
      to a Nipype output.
  
      Args:
        * outputs: outputs of the Nipype interface.
        * name: name of the Nipype output.
        * spec: Nipype output spec.
        * interface: Nipype interface.
        * tool_inputs: list of tool inputs (as produced by method
          get_boutiques_input).
  
      Assumes that:
        * Output names are unique.
        * Input values involved in the path template are defined.
        * Output files are written in the current directory.
        * There is a single output value (output lists are not supported).
      """
      output = {}
      output["name"] = name.replace("_", " ").capitalize()
  
      # Check if the output name was already used as an input name
      # If so, append '_outfile' to the end of the ID
      unique_id = True
      for inp in tool_inputs:
          if inp["id"] == name:
              unique_id = False
              break
      output["id"] = name if unique_id else name + "_outfile"
  
      output["path-template"] = ""
  
      # No real way to determine if an output is always
      # produced, regardless of the input values.
      output["optional"] = True
  
      output["description"] = get_description_from_spec(
          outputs, name, spec
      )
  
      # Path template creation.
  
      try:
          output_value = interface._list_outputs()[name]
      except TypeError:
          output_value = None
      except AttributeError:
          output_value = None
      except KeyError:
          output_value = None
  
      # Handle multi-outputs
      if (
          isinstance(output_value, list)
          or type(spec.handler).__name__ == "OutputMultiObject"
          or type(spec.handler).__name__ == "List"
      ):
          output["list"] = True
          if output_value:
              # Check if all extensions are the same
              extensions = []
              for val in output_value:
                  extensions.append(os.path.splitext(val)[1])
              # If extensions all the same, set path template as
              # wildcard + extension. Otherwise just use a wildcard
              if len(set(extensions)) == 1:
                  output["path-template"] = "*" + extensions[0]
              else:
                  output["path-template"] = "*"
              return output
  
      # If an output value is defined, use its relative path, if one exists.
      # Otherwise, put blank string as placeholder and try to fill it on
      # another iteration.
      if output_value:
          output["path-template"] = os.path.relpath(output_value)
      else:
          output["path-template"] = ""
  
      return output
  
file_path: nipype/nipype/utils/nipype2boutiques.py
imports: import os
  import sys
  import simplejson
  from ..scripts.instance import import_module
label_desc: Use image node_id 4 for calling a global function with example usage: get_boutiques_output(outputs, name, spec, interface, tool_inputs) and returns: output, output