class_docstr: Controls the setup and execution of a pipeline of processes.
class_docstr_tok: ["Controls","the","setup","and","execution","of","a","pipeline","of","processes","."]
docstr: Export object into a different format
  
  Parameters
  ----------
  filename: string
     file to save the code to; overrides prefix
  prefix: string
     prefix to use for output file
  format: string
     one of "python"
  include_config: boolean
     whether to include node and workflow config values
docstr_tok: ["Export","object","into","a","different","format","Parameters","--","--","--","--","--","filename",":","string","file","to","save","the","code","to",";","overrides","prefix","prefix",":","string","prefix","to","use","for","output","file","format",":","string","one","of","``","python","''","include_config",":","boolean","whether","to","include","node","and","workflow","config","values"]
code: def export(
      self,
      filename=None,
      prefix="output",
      format="python",
      include_config=False,
  ):
      """Export object into a different format
  
      Parameters
      ----------
      filename: string
         file to save the code to; overrides prefix
      prefix: string
         prefix to use for output file
      format: string
         one of "python"
      include_config: boolean
         whether to include node and workflow config values
  
      """
      import networkx as nx
  
      formats = ["python"]
      if format not in formats:
          raise ValueError(
              "format must be one of: %s" % "|".join(formats)
          )
      flatgraph = self._create_flat_graph()
      nodes = nx.topological_sort(flatgraph)
  
      all_lines = None
      lines = ["# Workflow"]
      importlines = [
          "from nipype.pipeline.engine import Workflow, Node, MapNode"
      ]
      functions = {}
      if format == "python":
          connect_template = (
              '%s.connect(%%s, %%s, %%s, "%%s")' % self.name
          )
          connect_template2 = (
              '%s.connect(%%s, "%%s", %%s, "%%s")' % self.name
          )
          wfdef = f'{self.name} = Workflow("{self.name}")'
          lines.append(wfdef)
          if include_config:
              lines.append(f"{self.name}.config = {self.config}")
          for idx, node in enumerate(nodes):
              nodename = node.fullname.replace(".", "_")
              # write nodes
              nodelines = format_node(
                  node, format="python", include_config=include_config
              )
              for line in nodelines:
                  if line.startswith("from"):
                      if line not in importlines:
                          importlines.append(line)
                  else:
                      lines.append(line)
              # write connections
              for u, _, d in flatgraph.in_edges(nbunch=node, data=True):
                  for cd in d["connect"]:
                      if isinstance(cd[0], tuple):
                          args = list(cd[0])
                          if args[1] in functions:
                              funcname = functions[args[1]]
                          else:
                              func = create_function_from_source(
                                  args[1]
                              )
                              funcname = [
                                  name
                                  for name in func.__globals__
                                  if name != "__builtins__"
                              ][0]
                              functions[args[1]] = funcname
                          args[1] = funcname
                          args = tuple([arg for arg in args if arg])
                          line_args = (
                              u.fullname.replace(".", "_"),
                              args,
                              nodename,
                              cd[1],
                          )
                          line = connect_template % line_args
                          line = line.replace(
                              "'%s'" % funcname, funcname
                          )
                          lines.append(line)
                      else:
                          line_args = (
                              u.fullname.replace(".", "_"),
                              cd[0],
                              nodename,
                              cd[1],
                          )
                          lines.append(connect_template2 % line_args)
          functionlines = ["# Functions"]
          for function in functions:
              functionlines.append(pickle.loads(function).rstrip())
          all_lines = importlines + functionlines + lines
  
          if not filename:
              filename = f"{prefix}{self.name}.py"
          with open(filename, "w") as fp:
              fp.writelines("\n".join(all_lines))
      return all_lines
  
imports: import os
  import os.path
  import sys
  from datetime import datetime
  from copy import deepcopy
  import pickle
  import shutil
  import numpy
  from ...None import config, logging
  from ...utils.misc import str2bool
  from ...utils.functions import getsource, create_function_from_source
  from ...interfaces.base import traits, TraitedSpec, TraitDictObject, TraitListObject
  from ...utils.filemanip import save_json
  from .utils import generate_expanded_graph, export_graph, write_workflow_prov, write_workflow_resources, format_dot, topological_sort, get_print_name, merge_dict, format_node
  from .base import EngineBase
  from .nodes import MapNode
label_desc: Use image node_id 13 for calling the Workflow obj's underlying member method code with example usage: obj.export(filename, prefix, format, include_config) and returns: all_lines