interfaces.matlab

Module: interfaces.matlab

Inheritance diagram for nipype.interfaces.matlab:

Inheritance diagram of nipype.interfaces.matlab

General matlab interface code

Classes

MatlabCommand

class nipype.interfaces.matlab.MatlabCommand(matlab_cmd=None, **inputs)

Bases: nipype.interfaces.base.core.CommandLine

Interface that runs matlab code

>>> import nipype.interfaces.matlab as matlab
>>> mlab = matlab.MatlabCommand(mfile=False)  # don't write script file
>>> mlab.inputs.script = "which('who')"
>>> out = mlab.run()  # doctest: +SKIP
Attributes:
always_run

Should the interface be always run even if the inputs were not changed? Only applies to interfaces being run within a workflow context.

can_resume

Defines if the interface can reuse partial results after interruption.

cmd

sets base command, immutable

cmdline

command plus any arguments (args)

output_spec
terminal_output
version

interfaces should implement a version property

Methods

aggregate_outputs(self[, runtime, …]) Collate expected outputs and check for existence
help([returnhelp]) Prints class help
input_spec alias of MatlabInputSpec
load_inputs_from_json(self, json_file[, …]) A convenient way to load pre-set inputs from a JSON file.
run(self[, cwd, ignore_exception]) Execute this interface.
save_inputs_to_json(self, json_file) A convenient way to save current inputs to a JSON file.
set_default_matlab_cmd(matlab_cmd) Set the default MATLAB command line for MATLAB classes.
set_default_mfile(mfile) Set the default MATLAB script file format for MATLAB classes.
set_default_paths(paths) Set the default MATLAB paths for MATLAB classes.
set_default_terminal_output(output_type) Set the default terminal output for CommandLine Interfaces.
raise_exception  
version_from_command  
__init__(self, matlab_cmd=None, **inputs)

initializes interface to matlab (default ‘matlab -nodesktop -nosplash’)

aggregate_outputs(self, runtime=None, needed_outputs=None)

Collate expected outputs and check for existence

always_run

Should the interface be always run even if the inputs were not changed? Only applies to interfaces being run within a workflow context.

can_resume

Defines if the interface can reuse partial results after interruption. Only applies to interfaces being run within a workflow context.

cmd

sets base command, immutable

cmdline

command plus any arguments (args) validates arguments and generates command line

classmethod help(returnhelp=False)

Prints class help

input_spec

alias of MatlabInputSpec

load_inputs_from_json(self, json_file, overwrite=True)

A convenient way to load pre-set inputs from a JSON file.

output_spec = None
raise_exception(self, runtime)
references_ = []
resource_monitor = True
run(self, cwd=None, ignore_exception=None, **inputs)

Execute this interface.

This interface will not raise an exception if runtime.returncode is non-zero.

Parameters:
cwd : specify a folder where the interface should be run
inputs : allows the interface settings to be updated
Returns:
results : an InterfaceResult object containing a copy of the instance
that was executed, provenance information and, if successful, results
save_inputs_to_json(self, json_file)

A convenient way to save current inputs to a JSON file.

classmethod set_default_matlab_cmd(matlab_cmd)

Set the default MATLAB command line for MATLAB classes.

This method is used to set values for all MATLAB subclasses. However, setting this will not update the output type for any existing instances. For these, assign the <instance>.inputs.matlab_cmd.

classmethod set_default_mfile(mfile)

Set the default MATLAB script file format for MATLAB classes.

This method is used to set values for all MATLAB subclasses. However, setting this will not update the output type for any existing instances. For these, assign the <instance>.inputs.mfile.

classmethod set_default_paths(paths)

Set the default MATLAB paths for MATLAB classes.

This method is used to set values for all MATLAB subclasses. However, setting this will not update the output type for any existing instances. For these, assign the <instance>.inputs.paths.

classmethod set_default_terminal_output(output_type)

Set the default terminal output for CommandLine Interfaces.

This method is used to set default terminal output for CommandLine Interfaces. However, setting this will not update the output type for any existing instances. For these, assign the <instance>.terminal_output.

terminal_output
version

interfaces should implement a version property

version_from_command(self, flag='-v', cmd=None)

MatlabInputSpec

class nipype.interfaces.matlab.MatlabInputSpec(**kwargs)

Bases: nipype.interfaces.base.specs.CommandLineInputSpec

Basic expected inputs to Matlab interface

Methods

add_class_trait(name, \*trait) Adds a named trait attribute to this class.
add_trait(self, name, \*trait) Adds a trait attribute to this object.
add_trait_category(category) Adds a trait category to a class.
all_trait_names(self) Returns the list of all trait names, including implicitly defined traits.
base_trait(self, name) Returns the base trait definition for a trait attribute.
class_default_traits_view() Returns the name of the default traits view for the class.
class_editable_traits() Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current class.
class_trait_names(\*\*metadata) Returns a list of the names of all trait attributes whose definitions match the set of metadata criteria specified.
class_trait_view_elements() Returns the ViewElements object associated with the class.
class_traits(\*\*metadata) Returns a dictionary containing the definitions of all of the trait attributes of the class that match the set of metadata criteria.
class_visible_traits() Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current class, that should be GUI visible
clone_traits(self[, traits, memo, copy]) Clones a new object from this one, optionally copying only a specified set of traits.
configure_traits(self[, filename, view, …]) Creates and displays a dialog box for editing values of trait attributes, as if it were a complete, self-contained GUI application.
copy_traits(self, other[, traits, memo, copy]) Copies another object’s trait attributes into this one.
copyable_trait_names(self, \*\*metadata) Returns the list of trait names to copy or clone by default.
default_traits_view(self) Returns the name of the default traits view for the object’s class.
edit_traits(self[, view, parent, kind, …]) Displays a user interface window for editing trait attribute values.
editable_traits(self) Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current object.
get(self, \*\*kwargs) Returns traited class as a dict
get_hashval(self[, hash_method]) Return a dictionary of our items with hashes for each file.
get_traitsfree(self, \*\*kwargs) Returns traited class as a dict
has_metadata(self, name, metadata[, value, …]) Return has_metadata for the requested trait name in this interface
has_traits_interface(self, \*interfaces) Returns whether the object implements a specified traits interface.
items(self) Name, trait generator for user modifiable traits
on_trait_change(self, handler[, name, …]) Causes the object to invoke a handler whenever a trait attribute matching a specified pattern is modified, or removes the association.
on_trait_event(self, handler[, name, …]) Causes the object to invoke a handler whenever a trait attribute matching a specified pattern is modified, or removes the association.
print_traits(self[, show_help]) Prints the values of all explicitly-defined, non-event trait attributes on the current object, in an easily readable format.
remove_trait(self, name) Removes a trait attribute from this object.
reset_traits(self[, traits]) Resets some or all of an object’s trait attributes to their default values.
set(self[, trait_change_notify]) Shortcut for setting object trait attributes.
set_trait_dispatch_handler(name, klass[, …]) Sets a trait notification dispatch handler.
sync_trait(self, trait_name, object[, …]) Synchronizes the value of a trait attribute on this object with a trait attribute on another object.
trait(self, name[, force, copy]) Returns the trait definition for the name trait attribute.
trait_context(self) Returns the default context to use for editing or configuring traits.
trait_get(self, \*\*kwargs) Returns traited class as a dict
trait_items_event(event_trait,name,items_event)
trait_monitor(handler[, remove]) Adds or removes the specified handler from the list of active monitors.
trait_names(self, \*\*metadata) Returns a list of the names of all trait attributes whose definitions match the set of metadata criteria specified.
trait_property_changed(…)
trait_set(self[, trait_change_notify]) Shortcut for setting object trait attributes.
trait_setq(self, \*\*traits) Shortcut for setting object trait attributes.
trait_subclasses([all]) Returns a list of the immediate (or all) subclasses of this class.
trait_view(self[, name, view_element]) Gets or sets a ViewElement associated with an object’s class.
trait_view_elements(self) Returns the ViewElements object associated with the object’s class.
trait_views(self[, klass]) Returns a list of the names of all view elements associated with the current object’s class.
traits(self, \*\*metadata) Returns a dictionary containing the definitions of all of the trait attributes of this object that match the set of metadata criteria.
traits_init()
traits_inited([True])
validate_trait(self, name, value) Validates whether a value is legal for a trait.
visible_traits(self) Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current object, that should be GUI visible
add_trait_listener  
class_trait_view  
remove_trait_listener  
__init__(self, **kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters:
name : str

Name of the attribute to add.

*trait :

A trait or a value that can be converted to a trait using Trait() Trait definition of the attribute. It can be a single value or a list equivalent to an argument list for the Trait() function.

add_trait(self, name, *trait)

Adds a trait attribute to this object.

Parameters:
name : str

Name of the attribute to add.

*trait :

Trait or a value that can be converted to a trait by Trait(). Trait definition for name. If more than one value is specified, it is equivalent to passing the entire list of values to Trait().

classmethod add_trait_category(category)

Adds a trait category to a class.

add_trait_listener(self, object, prefix='')
all_trait_names(self)

Returns the list of all trait names, including implicitly defined traits.

base_trait(self, name)

Returns the base trait definition for a trait attribute.

Parameters:
name : str

Name of the attribute whose trait definition is returned.

classmethod class_default_traits_view()

Returns the name of the default traits view for the class.

classmethod class_editable_traits()

Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current class.

classmethod class_trait_names(**metadata)

Returns a list of the names of all trait attributes whose definitions match the set of metadata criteria specified.

Parameters:
**metadata :

Criteria for selecting trait attributes.

classmethod class_trait_view(name=None, view_element=None)
classmethod class_trait_view_elements()

Returns the ViewElements object associated with the class.

The returned object can be used to access all the view elements associated with the class.

classmethod class_traits(**metadata)

Returns a dictionary containing the definitions of all of the trait attributes of the class that match the set of metadata criteria.

Parameters:
**metadata :

Criteria for selecting trait attributes.

classmethod class_visible_traits()

Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current class, that should be GUI visible

clone_traits(self, traits=None, memo=None, copy=None, **metadata)

Clones a new object from this one, optionally copying only a specified set of traits.

Parameters:
traits : list of strings

The list of names of the trait attributes to copy.

memo : dict

A dictionary of objects that have already been copied.

copy : str

The type of copy deep or shallow to perform on any trait that does not have explicit ‘copy’ metadata. A value of None means ‘copy reference’.

Returns:
new :

The newly cloned object.

configure_traits(self, filename=None, view=None, kind=None, edit=True, context=None, handler=None, id='', scrollable=None, **args)

Creates and displays a dialog box for editing values of trait attributes, as if it were a complete, self-contained GUI application.

Parameters:
filename : str

The name (including path) of a file that contains a pickled representation of the current object. When this parameter is specified, the method reads the corresponding file (if it exists) to restore the saved values of the object’s traits before displaying them. If the user confirms the dialog box (by clicking OK), the new values are written to the file. If this parameter is not specified, the values are loaded from the in-memory object, and are not persisted when the dialog box is closed.

view : View or str

A View object (or its name) that defines a user interface for editing trait attribute values of the current object. If the view is defined as an attribute on this class, use the name of the attribute. Otherwise, use a reference to the view object. If this attribute is not specified, the View object returned by trait_view() is used.

kind : str

The type of user interface window to create. See the traitsui.view.kind_trait trait for values and their meanings. If kind is unspecified or None, the kind attribute of the View object is used.

edit : bool

Indicates whether to display a user interface. If filename specifies an existing file, setting edit to False loads the saved values from that file into the object without requiring user interaction.

context : object or dictionary

A single object or a dictionary of string/object pairs, whose trait attributes are to be edited. If not specified, the current object is used

handler : Handler

A handler object used for event handling in the dialog box. If None, the default handler for Traits UI is used.

id : str

A unique ID for persisting preferences about this user interface, such as size and position. If not specified, no user preferences are saved.

scrollable : bool

Indicates whether the dialog box should be scrollable. When set to True, scroll bars appear on the dialog box if it is not large enough to display all of the items in the view at one time.

Returns:
True on success.
copy_traits(self, other, traits=None, memo=None, copy=None, **metadata)

Copies another object’s trait attributes into this one.

Parameters:
other : object

The object whose trait attribute values should be copied.

traits : list of strings

A list of names of trait attributes to copy. If None or unspecified, the set of names returned by trait_names() is used. If ‘all’ or an empty list, the set of names returned by all_trait_names() is used.

memo : dict

A dictionary of objects that have already been copied.

copy : None | ‘deep’ | ‘shallow’

The type of copy to perform on any trait that does not have explicit ‘copy’ metadata. A value of None means ‘copy reference’.

Returns:
unassignable : list of strings

A list of attributes that the method was unable to copy, which is empty if all the attributes were successfully copied.

copyable_trait_names(self, **metadata)

Returns the list of trait names to copy or clone by default.

default_traits_view(self)

Returns the name of the default traits view for the object’s class.

edit_traits(self, view=None, parent=None, kind=None, context=None, handler=None, id='', scrollable=None, **args)

Displays a user interface window for editing trait attribute values.

Parameters:
view : View or string

A View object (or its name) that defines a user interface for editing trait attribute values of the current object. If the view is defined as an attribute on this class, use the name of the attribute. Otherwise, use a reference to the view object. If this attribute is not specified, the View object returned by trait_view() is used.

parent : toolkit control

The reference to a user interface component to use as the parent window for the object’s UI window.

kind : str

The type of user interface window to create. See the traitsui.view.kind_trait trait for values and their meanings. If kind is unspecified or None, the kind attribute of the View object is used.

context : object or dictionary

A single object or a dictionary of string/object pairs, whose trait attributes are to be edited. If not specified, the current object is used.

handler : Handler

A handler object used for event handling in the dialog box. If None, the default handler for Traits UI is used.

id : str

A unique ID for persisting preferences about this user interface, such as size and position. If not specified, no user preferences are saved.

scrollable : bool

Indicates whether the dialog box should be scrollable. When set to True, scroll bars appear on the dialog box if it is not large enough to display all of the items in the view at one time.

Returns:
A UI object.
editable_traits(self)

Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current object.

get(self, **kwargs)

Returns traited class as a dict

Augments the trait get function to return a dictionary without notification handles

get_hashval(self, hash_method=None)

Return a dictionary of our items with hashes for each file.

Searches through dictionary items and if an item is a file, it calculates the md5 hash of the file contents and stores the file name and hash value as the new key value.

However, the overall bunch hash is calculated only on the hash value of a file. The path and name of the file are not used in the overall hash calculation.

Returns:
list_withhash : dict

Copy of our dictionary with the new file hashes included with each file.

hashvalue : str

The md5 hash value of the traited spec

get_traitsfree(self, **kwargs)

Returns traited class as a dict

Augments the trait get function to return a dictionary without any traits. The dictionary does not contain any attributes that were Undefined

has_metadata(self, name, metadata, value=None, recursive=True)

Return has_metadata for the requested trait name in this interface

has_traits_interface(self, *interfaces)

Returns whether the object implements a specified traits interface.

Parameters:
*interfaces :

One or more traits Interface (sub)classes.

items(self)

Name, trait generator for user modifiable traits

on_trait_change(self, handler, name=None, remove=False, dispatch='same', priority=False, deferred=False, target=None)

Causes the object to invoke a handler whenever a trait attribute matching a specified pattern is modified, or removes the association.

Parameters:
handler : function

A trait notification function for the name trait attribute, with one of the signatures described below.

name : str

The name of the trait attribute whose value changes trigger the notification. The name can specify complex patterns of trait changes using an extended name syntax, which is described below.

remove : bool

If True, removes the previously-set association between handler and name; if False (the default), creates the association.

dispatch : str

A string indicating the thread on which notifications must be run. Possible values are:

value dispatch
same Run notifications on the same thread as this one.
ui Run notifications on the UI thread. If the current thread is the UI thread, the notifications are executed immediately; otherwise, they are placed on the UI event queue.
fast_ui Alias for ui.
new Run notifications in a new thread.
on_trait_event(self, handler, name=None, remove=False, dispatch='same', priority=False, deferred=False, target=None)

Causes the object to invoke a handler whenever a trait attribute matching a specified pattern is modified, or removes the association.

Parameters:
handler : function

A trait notification function for the name trait attribute, with one of the signatures described below.

name : str

The name of the trait attribute whose value changes trigger the notification. The name can specify complex patterns of trait changes using an extended name syntax, which is described below.

remove : bool

If True, removes the previously-set association between handler and name; if False (the default), creates the association.

dispatch : str

A string indicating the thread on which notifications must be run. Possible values are:

value dispatch
same Run notifications on the same thread as this one.
ui Run notifications on the UI thread. If the current thread is the UI thread, the notifications are executed immediately; otherwise, they are placed on the UI event queue.
fast_ui Alias for ui.
new Run notifications in a new thread.
package_version = <Version('1.2.1.dev0+gbfbd0ab25')>
print_traits(self, show_help=False, **metadata)

Prints the values of all explicitly-defined, non-event trait attributes on the current object, in an easily readable format.

Parameters:
show_help : bool

Indicates whether to display additional descriptive information.

remove_trait(self, name)

Removes a trait attribute from this object.

Parameters:
name : str

Name of the attribute to remove.

Returns:
result : bool

True if the trait was successfully removed.

remove_trait_listener(self, object, prefix='')
reset_traits(self, traits=None, **metadata)

Resets some or all of an object’s trait attributes to their default values.

Parameters:
traits : list of strings

Names of trait attributes to reset.

Returns:
unresetable : list of strings

A list of attributes that the method was unable to reset, which is empty if all the attributes were successfully reset.

set(self, trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters:
trait_change_notify : bool

If True (the default), then each value assigned may generate a trait change notification. If False, then no trait change notifications will be generated. (see also: trait_setq)

**traits :

Key/value pairs, the trait attributes and their values to be set

Returns:
self :

The method returns this object, after setting attributes.

classmethod set_trait_dispatch_handler(name, klass, override=False)

Sets a trait notification dispatch handler.

sync_trait(self, trait_name, object, alias=None, mutual=True, remove=False)

Synchronizes the value of a trait attribute on this object with a trait attribute on another object.

Parameters:
name : str

Name of the trait attribute on this object.

object : object

The object with which to synchronize.

alias : str

Name of the trait attribute on other; if None or omitted, same as name.

mutual : bool or int

Indicates whether synchronization is mutual (True or non-zero) or one-way (False or zero)

remove : bool or int

Indicates whether synchronization is being added (False or zero) or removed (True or non-zero)

trait(self, name, force=False, copy=False)

Returns the trait definition for the name trait attribute.

Parameters:
name : str

Name of the attribute whose trait definition is to be returned.

force : bool

Indicates whether to return a trait definition if name is not explicitly defined.

copy : bool

Indicates whether to return the original trait definition or a copy.

trait_context(self)

Returns the default context to use for editing or configuring traits.

trait_get(self, **kwargs)

Returns traited class as a dict

Augments the trait get function to return a dictionary without notification handles

trait_items_event(event_trait, name, items_event)
classmethod trait_monitor(handler, remove=False)

Adds or removes the specified handler from the list of active monitors.

Parameters:
handler : function

The function to add or remove as a monitor.

remove : bool

Flag indicating whether to remove (True) or add the specified handler as a monitor for this class.

trait_names(self, **metadata)

Returns a list of the names of all trait attributes whose definitions match the set of metadata criteria specified.

Parameters:
**metadata :

Criteria for selecting trait attributes.

trait_property_changed(name, old_value[, new_value])
trait_set(self, trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters:
trait_change_notify : bool

If True (the default), then each value assigned may generate a trait change notification. If False, then no trait change notifications will be generated. (see also: trait_setq)

**traits :

Key/value pairs, the trait attributes and their values to be set

Returns:
self :

The method returns this object, after setting attributes.

trait_setq(self, **traits)

Shortcut for setting object trait attributes.

Parameters:
**traits :

Key/value pairs, the trait attributes and their values to be set. No trait change notifications will be generated for any values assigned (see also: trait_set).

Returns:
self :

The method returns this object, after setting attributes.

classmethod trait_subclasses(all=False)

Returns a list of the immediate (or all) subclasses of this class.

Parameters:
all : bool

Indicates whether to return all subclasses of this class. If False, only immediate subclasses are returned.

trait_view(self, name=None, view_element=None)

Gets or sets a ViewElement associated with an object’s class.

Parameters:
name : str

Name of a view element

view_element : ViewElement

View element to associate

Returns:
A view element.
trait_view_elements(self)

Returns the ViewElements object associated with the object’s class.

The returned object can be used to access all the view elements associated with the class.

trait_views(self, klass=None)

Returns a list of the names of all view elements associated with the current object’s class.

Parameters:
klass : class

A class, such that all returned names must correspond to instances of this class. Possible values include:

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(self, **metadata)

Returns a dictionary containing the definitions of all of the trait attributes of this object that match the set of metadata criteria.

Parameters:
**metadata :

Criteria for selecting trait attributes.

traits_init()
traits_inited([True])
validate_trait(self, name, value)

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

visible_traits(self)

Returns an alphabetically sorted list of the names of non-event trait attributes associated with the current object, that should be GUI visible

wrappers = {'extended': <class 'traits.trait_notifiers.ExtendedTraitChangeNotifyWrapper'>, 'fast_ui': <class 'traits.trait_notifiers.FastUITraitChangeNotifyWrapper'>, 'new': <class 'traits.trait_notifiers.NewTraitChangeNotifyWrapper'>, 'same': <class 'traits.trait_notifiers.TraitChangeNotifyWrapper'>, 'ui': <class 'traits.trait_notifiers.FastUITraitChangeNotifyWrapper'>}

Function

nipype.interfaces.matlab.get_matlab_command()