def __init__(self, **kwargs): """ Initialize the Process class. """ # Inheritance super(Process, self).__init__() # Initialize the process identifiers self.name = self.__class__.__name__ self.id = self.__class__.__module__ + "." + self.name # Parameter to store which tools will be used dusring the processing self.versions = { "capsul": get_tool_version("capsul") } # Initialize the log file name self.log_file = None self.study_config = None default_values = getattr(self, 'default_values', None) if default_values: self.default_values = default_values.copy() else: self.default_values = {} for k, v in six.iteritems(kwargs): self.default_values[k] = v
def __init__(self, **kwargs): """ Initialize the Process class. """ # Inheritance super(Process, self).__init__() # Initialize the process identifiers self.name = self.__class__.__name__ self.id = self.__class__.__module__ + "." + self.name # Parameter to store which tools will be used dusring the processing self.versions = { "capsul": get_tool_version("capsul") } # Initialize the log file name self.log_file = None default_values = getattr(self, 'default_values', None) if default_values: self.default_values = default_values.copy() else: self.default_values = {} for k, v in kwargs.iteritems(): self.default_values[k] = v
def __init__(self): """ Initialize the Process class. """ # Inheritance super(Process, self).__init__() # Initialize the process identifiers self.name = self.__class__.__name__ self.id = self.__class__.__module__ + "." + self.name # Parameter to store which tools will be used dusring the processing self.versions = { "capsul": get_tool_version("capsul") } # Initialize the log file name self.log_file = None
def __init__(self, nipype_instance, *args, **kwargs): """ Initialize the NipypeProcess class. NipypeProcess instance get automatically an additional user trait 'output_directory'. This class also fix also some lake of the nipye version '0.9.2'. Parameters ---------- nipype_instance: nipype interface (mandatory) the nipype interface we want to wrap in capsul. Attributes ---------- _nipype_interface : Interface private attribute to store the nipye interface _nipype_module : str private attribute to store the nipye module name _nipype_class : str private attribute to store the nipye class name _nipype_interface_name : str private attribute to store the nipye interface name """ # Set some class attributes that characterize the nipype interface self._nipype_interface = nipype_instance self._nipype_module = nipype_instance.__class__.__module__ self._nipype_class = nipype_instance.__class__.__name__ self._nipype_interface_name = self._nipype_module.split(".")[2] # Inheritance: activate input files copy for spm interfaces. if self._nipype_interface_name == "spm": # Copy only 'copyfile' nipype traits inputs_to_copy = self._nipype_interface.inputs.traits( copyfile=True).keys() super(NipypeProcess, self).__init__( activate_copy=True, inputs_to_copy=inputs_to_copy, *args, **kwargs) else: super(NipypeProcess, self).__init__( activate_copy=False, *args, **kwargs) # Replace the process name and identification attributes self.id = ".".join([self._nipype_module, self._nipype_class]) self.name = self._nipype_interface.__class__.__name__ # Set the nipype and nipype interface versions if self._nipype_interface_name != "spm": self.versions.update({ "nipype": get_tool_version("nipype"), self._nipype_interface_name: self._nipype_interface.version }) else: from nipype.interfaces.spm import SPMCommand from nipype.interfaces.matlab import MatlabCommand self.versions.update({ "nipype": get_tool_version("nipype"), self._nipype_interface_name: "{0}-{1}|{2}-{3}".format( SPMCommand._matlab_cmd, MatlabCommand._default_paths, SPMCommand._paths, SPMCommand._use_mcr) }) # Add a new trait to store the processing output directory super(Process, self).add_trait( "output_directory", Directory(Undefined, exists=True, optional=True))
def test_version_python(self): """ Method to test if we can get a python module version from its string description and the nipype insterfaces versions. """ self.assertEqual(capsul.__version__, get_tool_version("capsul")) self.assertEqual(get_tool_version("error_capsul"), None)