class_docstr: Experimental Slicer wrapper. Work in progress.
code: def __init__(self, module, **inputs):
      warnings.warn("slicer is Not fully implemented", RuntimeWarning)
      super().__init__(
          command="Slicer3 --launch %s " % module, name=module, **inputs
      )
      dom = self._grab_xml(module)
      self._outputs_filenames = {}
  
      self._outputs_nodes = []
  
      undefined_traits = {}
  
      for paramGroup in dom.getElementsByTagName("parameters"):
          for param in paramGroup.childNodes:
              if param.nodeName in [
                  "label",
                  "description",
                  "#text",
                  "#comment",
              ]:
                  continue
              traitsParams = {}
  
              name = param.getElementsByTagName("name")[
                  0
              ].firstChild.nodeValue
  
              longFlagNode = param.getElementsByTagName("longflag")
              if longFlagNode:
                  traitsParams["argstr"] = (
                      "--" + longFlagNode[0].firstChild.nodeValue + " "
                  )
              else:
                  traitsParams["argstr"] = "--" + name + " "
  
              argsDict = {
                  "file": "%s",
                  "integer": "%d",
                  "double": "%f",
                  "float": "%f",
                  "image": "%s",
                  "transform": "%s",
                  "boolean": "",
                  "string-enumeration": "%s",
                  "string": "%s",
              }
  
              if param.nodeName.endswith("-vector"):
                  traitsParams["argstr"] += argsDict[
                      param.nodeName[:-7]
                  ]
              else:
                  traitsParams["argstr"] += argsDict[param.nodeName]
  
              index = param.getElementsByTagName("index")
              if index:
                  traitsParams["position"] = index[
                      0
                  ].firstChild.nodeValue
  
              desc = param.getElementsByTagName("description")
              if index:
                  traitsParams["desc"] = desc[0].firstChild.nodeValue
  
              name = param.getElementsByTagName("name")[
                  0
              ].firstChild.nodeValue
  
              typesDict = {
                  "integer": traits.Int,
                  "double": traits.Float,
                  "float": traits.Float,
                  "image": File,
                  "transform": File,
                  "boolean": traits.Bool,
                  "string": traits.Str,
                  "file": File,
              }
  
              if param.nodeName == "string-enumeration":
                  type = traits.Enum
                  values = [
                      el.firstChild.nodeValue
                      for el in param.getElementsByTagName("element")
                  ]
              elif param.nodeName.endswith("-vector"):
                  type = traits.List
                  values = [typesDict[param.nodeName[:-7]]]
                  traitsParams["sep"] = ","
              else:
                  values = []
                  type = typesDict[param.nodeName]
  
              if (
                  param.nodeName
                  in ["file", "directory", "image", "transform"]
                  and param.getElementsByTagName("channel")[
                      0
                  ].firstChild.nodeValue
                  == "output"
              ):
                  self.inputs.add_trait(
                      name,
                      traits.Either(traits.Bool, File, **traitsParams),
                  )
                  undefined_traits[name] = Undefined
  
                  # traitsParams["exists"] = True
                  self._outputs_filenames[
                      name
                  ] = self._gen_filename_from_param(param)
                  # undefined_output_traits[name] = Undefined
                  # self._outputs().add_trait(name, File(*values, **traitsParams))
                  self._outputs_nodes.append(param)
              else:
                  if param.nodeName in [
                      "file",
                      "directory",
                      "image",
                      "transform",
                  ]:
                      traitsParams["exists"] = True
                  self.inputs.add_trait(
                      name, type(*values, **traitsParams)
                  )
                  undefined_traits[name] = Undefined
  
      self.inputs.trait_set(
          trait_change_notify=False, **undefined_traits
      )
      for name in list(undefined_traits.keys()):
          _ = getattr(self.inputs, name)
  
file_path: nipype/nipype/interfaces/dynamic_slicer.py
imports: import os
  import warnings
  import xml.dom.minidom
  from .base import CommandLine, CommandLineInputSpec, DynamicTraitedSpec, traits, Undefined, File, isdefined
label_desc: Use image node_id 3 to create a new SlicerCommandLine object from inherited base classes: CommandLine with example: obj = SlicerCommandLine(module)