NIPY logo
Home · Quickstart · Documentation · Citation · NiPy
Loading

Table Of Contents

Versions

ReleaseDevel
0.7.0pre-0.8
Download Github

Links

interfaces.base

Module: interfaces.base

Inheritance diagram for nipype.interfaces.base:

Inheritance diagram of nipype.interfaces.base

Package contains interfaces for using existing functionality in other packages

Exaples FSL, matlab/SPM , afni

Requires Packages to be installed

Classes

BaseInterface

class nipype.interfaces.base.BaseInterface(**inputs)

Bases: nipype.interfaces.base.Interface

Implements common interface functionality.

__init__(**inputs)
aggregate_outputs(runtime=None, needed_outputs=None)

Collate expected outputs and check for existence

always_run
can_resume
classmethod help(returnhelp=False)

Prints class help

input_spec

alias of BaseInterfaceInputSpec

run(**inputs)

Execute this interface.

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

Parameters :

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 :

version

BaseInterfaceInputSpec

class nipype.interfaces.base.BaseInterfaceInputSpec(**kwargs)

Bases: nipype.interfaces.base.TraitedSpec

__init__(**kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters :

name : string

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(name, *trait)

Adds a trait attribute to this object.

Parameters :

name : string

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(object, prefix='')
all_trait_names()

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

base_trait(name)

Returns the base trait definition for a trait attribute.

Parameters :

name : string

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 : dictionary

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 : dictionary

Criteria for selecting trait attributes

clone_traits(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 names of the trait attributes to copy.

memo : dictionary

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 :

The newly cloned object. :

configure_traits(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 : string

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 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.

kind : string

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 : Boolean

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 object

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

id : string

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

scrollable : Boolean

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.

copy_traits(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 : dictionary

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 :

A list of attributes that the method was unable to copy, :

which is empty if all the attributes were successfully copied. :

copyable_trait_names(**metadata)

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

default_traits_view()

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

edit_traits(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 : window handle

A user interface component to use as the parent window for the object’s UI window.

kind : string

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 object

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

id : string

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

scrollable : Boolean

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.

editable_traits()

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

get(**kwargs)

Returns traited class as a dict

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

get_hashval(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 :

dict_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(**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_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

Parameters :interfaces : one or more traits Interface (sub)classes.
items()

Name, trait generator for user modifiable traits

on_trait_change(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
on_trait_event(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
print_traits(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 : Boolean

Indicates whether to display additional descriptive information.

remove_trait(name)

Removes a trait attribute from this object.

Parameters :

name : string

Name of the attribute to remove

remove_trait_listener(object, prefix='')
reset_traits(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 :

A list of attributes that the method was unable to reset, which is empty :

if all the attributes were successfully reset. :

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

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(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 : string

Name of the trait attribute on this object

object : object

The object with which to synchronize

alias : string

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

mutual : Boolean or integer

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

remove : Boolean or integer

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

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

Returns the trait definition for the name trait attribute.

Parameters :

name : string

Name of the attribute whose trait definition is to be returned

force : Boolean

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

copy : Boolean

Indicates whether to return the original trait definition or a copy

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

Parameters :

names : list of trait attribute names

Trait attributes whose values are requested

Returns :

A dictionary whose keys are the names passed as arguments and whose :

values are the corresponding trait values :

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 : boolean

Flag indicating whether to remove (True) or add the specified handler as a monitor for this 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 : dictionary

Criteria for selecting trait attributes

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

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

Trait attributes and their values to be set

Returns :

self :

The method returns this object, after setting attributes.

trait_setq(**traits)

Shortcut for setting object trait attributes.

Parameters :

traits : list of key/value pairs

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 : Boolean

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

trait_view(name=None, view_element=None)

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

Parameters :

name : string

Name of a view element

view_element : a ViewElement object

View element to associate

Returns :

A view element. :

trait_view_elements()

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(klass=None)

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

Parameters :

klass : a class

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

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(**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 : dictionary

Criteria for selecting trait attributes

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

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

BaseTraitedSpec

class nipype.interfaces.base.BaseTraitedSpec(**kwargs)

Bases: traits.has_traits.HasTraits

Provide a few methods necessary to support nipype interface api

The inputs attribute of interfaces call certain methods that are not available in traits.HasTraits. These are provided here.

new metadata:

  • usedefault : set this to True if the default value of the trait should be used. Unless this is set, the attributes are set to traits.Undefined

new attribute:

  • get_hashval : returns a tuple containing the state of the trait as a dict and hashvalue corresponding to dict.

XXX Reconsider this in the long run, but it seems like the best solution to move forward on the refactoring.

__init__(**kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters :

name : string

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(name, *trait)

Adds a trait attribute to this object.

Parameters :

name : string

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(object, prefix='')
all_trait_names()

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

base_trait(name)

Returns the base trait definition for a trait attribute.

Parameters :

name : string

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 : dictionary

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 : dictionary

Criteria for selecting trait attributes

clone_traits(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 names of the trait attributes to copy.

memo : dictionary

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 :

The newly cloned object. :

configure_traits(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 : string

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 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.

kind : string

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 : Boolean

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 object

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

id : string

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

scrollable : Boolean

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.

copy_traits(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 : dictionary

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 :

A list of attributes that the method was unable to copy, :

which is empty if all the attributes were successfully copied. :

copyable_trait_names(**metadata)

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

default_traits_view()

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

edit_traits(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 : window handle

A user interface component to use as the parent window for the object’s UI window.

kind : string

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 object

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

id : string

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

scrollable : Boolean

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.

editable_traits()

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

get(**kwargs)

Returns traited class as a dict

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

get_hashval(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 :

dict_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(**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_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

Parameters :interfaces : one or more traits Interface (sub)classes.
items()

Name, trait generator for user modifiable traits

on_trait_change(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
on_trait_event(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
print_traits(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 : Boolean

Indicates whether to display additional descriptive information.

remove_trait(name)

Removes a trait attribute from this object.

Parameters :

name : string

Name of the attribute to remove

remove_trait_listener(object, prefix='')
reset_traits(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 :

A list of attributes that the method was unable to reset, which is empty :

if all the attributes were successfully reset. :

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

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(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 : string

Name of the trait attribute on this object

object : object

The object with which to synchronize

alias : string

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

mutual : Boolean or integer

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

remove : Boolean or integer

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

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

Returns the trait definition for the name trait attribute.

Parameters :

name : string

Name of the attribute whose trait definition is to be returned

force : Boolean

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

copy : Boolean

Indicates whether to return the original trait definition or a copy

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

Parameters :

names : list of trait attribute names

Trait attributes whose values are requested

Returns :

A dictionary whose keys are the names passed as arguments and whose :

values are the corresponding trait values :

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 : boolean

Flag indicating whether to remove (True) or add the specified handler as a monitor for this 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 : dictionary

Criteria for selecting trait attributes

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

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

Trait attributes and their values to be set

Returns :

self :

The method returns this object, after setting attributes.

trait_setq(**traits)

Shortcut for setting object trait attributes.

Parameters :

traits : list of key/value pairs

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 : Boolean

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

trait_view(name=None, view_element=None)

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

Parameters :

name : string

Name of a view element

view_element : a ViewElement object

View element to associate

Returns :

A view element. :

trait_view_elements()

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(klass=None)

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

Parameters :

klass : a class

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

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(**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 : dictionary

Criteria for selecting trait attributes

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

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

Bunch

class nipype.interfaces.base.Bunch(*args, **kwargs)

Bases: object

Dictionary-like class that provides attribute-style access to it’s items.

A Bunch is a simple container that stores it’s items as class attributes. Internally all items are stored in a dictionary and the class exposes several of the dictionary methods.

Notes

The Bunch pattern came from the Python Cookbook:

[1]A. Martelli, D. Hudgeon, “Collecting a Bunch of Named Items”, Python Cookbook, 2nd Ed, Chapter 4.18, 2005.

Examples

>>> from nipype.interfaces.base import Bunch
>>> inputs = Bunch(infile='subj.nii', fwhm=6.0, register_to_mean=True)
>>> inputs
Bunch(fwhm=6.0, infile='subj.nii', register_to_mean=True)
>>> inputs.register_to_mean = False
>>> inputs
Bunch(fwhm=6.0, infile='subj.nii', register_to_mean=False)
__init__(*args, **kwargs)
dictcopy()

returns a deep copy of existing Bunch as a dictionary

get(*args)

Support dictionary get() functionality

items()

iterates over bunch attributes as key, value pairs

iteritems()

iterates over bunch attributes as key, value pairs

set(**kwargs)

Support dictionary get() functionality

update(*args, **kwargs)

update existing attribute, or create new attribute

Note: update is very much like HasTraits.set

CommandLine

class nipype.interfaces.base.CommandLine(command=None, **inputs)

Bases: nipype.interfaces.base.BaseInterface

Implements functionality to interact with command line programs class must be instantiated with a command argument

Parameters :

command : string

define base immutable command you wish to run

args : string, optional

optional arguments passed to base command

Examples

>>> from nipype.interfaces.base import CommandLine
>>> cli = CommandLine(command='ls', environ={'DISPLAY': ':1'})
>>> cli.inputs.args = '-al'
>>> cli.cmdline
'ls -al'
>>> cli.inputs.trait_get()
{'ignore_exception': False, 'args': '-al', 'environ': {'DISPLAY': ':1'}}
>>> cli.inputs.get_hashval()
({'args': '-al'}, 'a2f45e04a34630c5f33a75ea2a533cdd')
__init__(command=None, **inputs)
aggregate_outputs(runtime=None, needed_outputs=None)

Collate expected outputs and check for existence

always_run
can_resume
cmd

sets base command, immutable

cmdline

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

classmethod help(returnhelp=False)
input_spec

alias of CommandLineInputSpec

raise_exception(runtime)
run(**inputs)

Execute this interface.

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

Parameters :

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 :

version
version_from_command(flag='-v')

CommandLineInputSpec

class nipype.interfaces.base.CommandLineInputSpec(**kwargs)

Bases: nipype.interfaces.base.BaseInterfaceInputSpec

__init__(**kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters :

name : string

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(name, *trait)

Adds a trait attribute to this object.

Parameters :

name : string

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(object, prefix='')
all_trait_names()

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

base_trait(name)

Returns the base trait definition for a trait attribute.

Parameters :

name : string

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 : dictionary

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 : dictionary

Criteria for selecting trait attributes

clone_traits(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 names of the trait attributes to copy.

memo : dictionary

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 :

The newly cloned object. :

configure_traits(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 : string

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 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.

kind : string

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 : Boolean

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 object

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

id : string

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

scrollable : Boolean

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.

copy_traits(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 : dictionary

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 :

A list of attributes that the method was unable to copy, :

which is empty if all the attributes were successfully copied. :

copyable_trait_names(**metadata)

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

default_traits_view()

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

edit_traits(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 : window handle

A user interface component to use as the parent window for the object’s UI window.

kind : string

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 object

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

id : string

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

scrollable : Boolean

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.

editable_traits()

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

get(**kwargs)

Returns traited class as a dict

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

get_hashval(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 :

dict_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(**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_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

Parameters :interfaces : one or more traits Interface (sub)classes.
items()

Name, trait generator for user modifiable traits

on_trait_change(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
on_trait_event(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
print_traits(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 : Boolean

Indicates whether to display additional descriptive information.

remove_trait(name)

Removes a trait attribute from this object.

Parameters :

name : string

Name of the attribute to remove

remove_trait_listener(object, prefix='')
reset_traits(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 :

A list of attributes that the method was unable to reset, which is empty :

if all the attributes were successfully reset. :

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

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(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 : string

Name of the trait attribute on this object

object : object

The object with which to synchronize

alias : string

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

mutual : Boolean or integer

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

remove : Boolean or integer

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

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

Returns the trait definition for the name trait attribute.

Parameters :

name : string

Name of the attribute whose trait definition is to be returned

force : Boolean

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

copy : Boolean

Indicates whether to return the original trait definition or a copy

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

Parameters :

names : list of trait attribute names

Trait attributes whose values are requested

Returns :

A dictionary whose keys are the names passed as arguments and whose :

values are the corresponding trait values :

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 : boolean

Flag indicating whether to remove (True) or add the specified handler as a monitor for this 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 : dictionary

Criteria for selecting trait attributes

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

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

Trait attributes and their values to be set

Returns :

self :

The method returns this object, after setting attributes.

trait_setq(**traits)

Shortcut for setting object trait attributes.

Parameters :

traits : list of key/value pairs

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 : Boolean

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

trait_view(name=None, view_element=None)

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

Parameters :

name : string

Name of a view element

view_element : a ViewElement object

View element to associate

Returns :

A view element. :

trait_view_elements()

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(klass=None)

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

Parameters :

klass : a class

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

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(**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 : dictionary

Criteria for selecting trait attributes

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

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

DynamicTraitedSpec

class nipype.interfaces.base.DynamicTraitedSpec(**kwargs)

Bases: nipype.interfaces.base.BaseTraitedSpec

A subclass to handle dynamic traits

This class is a workaround for add_traits and clone_traits not functioning well together.

__init__(**kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters :

name : string

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(name, *trait)

Adds a trait attribute to this object.

Parameters :

name : string

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(object, prefix='')
all_trait_names()

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

base_trait(name)

Returns the base trait definition for a trait attribute.

Parameters :

name : string

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 : dictionary

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 : dictionary

Criteria for selecting trait attributes

clone_traits(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 names of the trait attributes to copy.

memo : dictionary

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 :

The newly cloned object. :

configure_traits(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 : string

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 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.

kind : string

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 : Boolean

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 object

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

id : string

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

scrollable : Boolean

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.

copy_traits(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 : dictionary

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 :

A list of attributes that the method was unable to copy, :

which is empty if all the attributes were successfully copied. :

copyable_trait_names(**metadata)

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

default_traits_view()

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

edit_traits(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 : window handle

A user interface component to use as the parent window for the object’s UI window.

kind : string

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 object

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

id : string

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

scrollable : Boolean

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.

editable_traits()

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

get(**kwargs)

Returns traited class as a dict

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

get_hashval(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 :

dict_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(**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_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

Parameters :interfaces : one or more traits Interface (sub)classes.
items()

Name, trait generator for user modifiable traits

on_trait_change(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
on_trait_event(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
print_traits(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 : Boolean

Indicates whether to display additional descriptive information.

remove_trait(name)

Removes a trait attribute from this object.

Parameters :

name : string

Name of the attribute to remove

remove_trait_listener(object, prefix='')
reset_traits(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 :

A list of attributes that the method was unable to reset, which is empty :

if all the attributes were successfully reset. :

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

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(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 : string

Name of the trait attribute on this object

object : object

The object with which to synchronize

alias : string

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

mutual : Boolean or integer

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

remove : Boolean or integer

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

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

Returns the trait definition for the name trait attribute.

Parameters :

name : string

Name of the attribute whose trait definition is to be returned

force : Boolean

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

copy : Boolean

Indicates whether to return the original trait definition or a copy

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

Parameters :

names : list of trait attribute names

Trait attributes whose values are requested

Returns :

A dictionary whose keys are the names passed as arguments and whose :

values are the corresponding trait values :

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 : boolean

Flag indicating whether to remove (True) or add the specified handler as a monitor for this 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 : dictionary

Criteria for selecting trait attributes

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

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

Trait attributes and their values to be set

Returns :

self :

The method returns this object, after setting attributes.

trait_setq(**traits)

Shortcut for setting object trait attributes.

Parameters :

traits : list of key/value pairs

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 : Boolean

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

trait_view(name=None, view_element=None)

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

Parameters :

name : string

Name of a view element

view_element : a ViewElement object

View element to associate

Returns :

A view element. :

trait_view_elements()

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(klass=None)

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

Parameters :

klass : a class

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

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(**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 : dictionary

Criteria for selecting trait attributes

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

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

InputMultiPath

class nipype.interfaces.base.InputMultiPath(trait=None, value=None, minlen=0, maxlen=9223372036854775807, items=True, **metadata)

Bases: nipype.interfaces.base.MultiPath

Implements a user friendly traits that accepts one or more paths to files or directories. This is the input version which always returns a list. Default value of this trait is _Undefined. It does not accept empty lists.

XXX This should only be used as a final resort. We should stick to established Traits to the extent possible.

XXX This needs to be vetted by somebody who understands traits

>>> from nipype.interfaces.base import InputMultiPath
>>> class A(TraitedSpec):
...     foo = InputMultiPath(File(exists=False))
>>> a = A()
>>> a.foo
<undefined>
>>> a.foo = '/software/temp/foo.txt'
>>> a.foo
['/software/temp/foo.txt']
>>> a.foo = ['/software/temp/foo.txt']
>>> a.foo
['/software/temp/foo.txt']
>>> a.foo = ['/software/temp/foo.txt', '/software/temp/goo.txt']
>>> a.foo
['/software/temp/foo.txt', '/software/temp/goo.txt']
__init__(trait=None, value=None, minlen=0, maxlen=9223372036854775807, items=True, **metadata)

Returns a List trait.

Parameters :

trait : a trait or value that can be converted to a trait using Trait()

The type of item that the list contains. If not specified, the list can contain items of any type.

value : :

Default value for the list

minlen : integer

The minimum length of a list that can be assigned to the trait.

maxlen : integer

The maximum length of a list that can be assigned to the trait.

The length of the list assigned to the trait must be such that:: :

minlen <= len(list) <= maxlen

arg_error(method, arg_num, object, name, value)

Raises a TraitError exception to notify the user that a method on an instance received a positional argument of an incorrect type.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

value : object

The value passed to the argument

as_ctrait()

Returns a CTrait corresponding to the trait defined by this class.

clone(default_value=<missing>, **metadata)

Clones the contents of this object into a new instance of the same class, and then modifies the cloned copy using the specified default_value and metadata. Returns the cloned object as the result.

Note that subclasses can change the signature of this method if needed, but should always call the ‘super’ method if possible.

create_editor()

Returns the default UI editor for the trait.

dup_arg_error(method, arg_num, object, name)

Raises a TraitError exception to notify the user that a method on an instance received an argument as both a keyword argument and a positional argument.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

error(object, name, value)

Raises a TraitError exception.

Parameters :

object : object

The object whose attribute is being assigned

name : string

The name of the attribute being assigned

value : object

The proposed new value for the attribute

full_info(object, name, value)

Returns a description of the trait.

get_default_value()

Returns a tuple of the form: (default_value_type, default_value) which describes the default value for this trait. The default implementation analyzes the value of the trait’s default_value attribute and determines an appropriate default_value_type for default_value. If you need to override this method to provide a different result tuple, the following values are valid values for default_value_type:

  • 0, 1: The default_value item of the tuple is the default value.
  • 2: The object containing the trait is the default value.
  • 3: A new copy of the list specified by default_value is the default value.
  • 4: A new copy of the dictionary specified by default_value is the default value.
  • 5: A new instance of TraitListObject constructed using the default_value list is the default value.
  • 6: A new instance of TraitDictObject constructed using the default_value dictionary is the default value.
  • 7: default_value is a tuple of the form: (callable, args, kw), where callable is a callable, args is a tuple, and kw is either a dictionary or None. The default value is the result obtained by invoking callable(*args, **kw).
  • 8: default_value is a callable. The default value is the result obtained by invoking default_value*(*object), where object is the object containing the trait. If the trait has a validate() method, the validate() method is also called to validate the result.
  • 9: A new instance of TraitSetObject constructed using the default_value set is the default value.
get_editor(trait=None)

Returns a trait editor that allows the user to modify the trait trait.

Parameters :

trait : trait

The trait to be edited

get_value(object, name, trait=None)

Returns the current value of a property-based trait.

info()

Must return a string describing the type of value accepted by the trait handler.

The string should be a phrase describing the type defined by the TraitHandler subclass, rather than a complete sentence. For example, use the phrase, “a square sprocket” instead of the sentence, “The value must be a square sprocket.” The value returned by info() is combined with other information whenever an error occurs and therefore makes more sense to the user if the result is a phrase. The info() method is similar in purpose and use to the info attribute of a validator function.

Note that the result can include information specific to the particular trait handler instance. For example, TraitRange instances return a string indicating the range of values acceptable to the handler (e.g., “an integer in the range from 1 to 9”). If the info() method is not overridden, the default method returns the value of the ‘info_text’ attribute.

init()

Allows the trait to perform any additional initialization needed.

inner_traits()

Returns the inner trait (or traits) for this trait.

is_valid(object, name, value)
items_event()
keyword_error(method, object, name, value)

Raises a TraitError exception to notify the user that a method on an instance received a keyword argument of an incorrect type.

Parameters :

method : function

The method that encountered the error

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

value :

The value passed to the argument

missing_arg_error(method, arg_num, object, name)

Raises a TraitError exception to notify the user that a method on an instance failed to receive a required positional argument.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

repr(value)

Returns a printable representation of a value along with its type.

DEPRECATED: This functionality was only used to provide readable error messages. This functionality has been incorporated into TraitError itself.

Parameters :

value : object

The value to be printed.

return_error(method, object, value)

Raises a TraitError exception to notify the user that a method on an instance returned a value of incorrect type.

Parameters :

method : function

The method that encountered the error

object : object

The object whose method was called

value :

The value returned by the method

set_value(object, name, value)

Sets the cached value of a property-based trait and fires the appropriate trait change event.

validate(object, name, value)

Interface

class nipype.interfaces.base.Interface(**inputs)

Bases: object

This is an abstract definition for Interface objects.

It provides no functionality. It defines the necessary attributes and methods all Interface objects should have.

__init__(**inputs)

Initialize command with given args and inputs.

aggregate_outputs(runtime=None, needed_outputs=None)

Called to populate outputs

always_run
can_resume
classmethod help()

Prints class help

run()

Execute the command.

version

InterfaceResult

class nipype.interfaces.base.InterfaceResult(interface, runtime, inputs=None, outputs=None)

Bases: object

Object that contains the results of running a particular Interface.

Attributes :

version : version of this Interface result object (a readonly property)

interface : class type

A copy of the Interface class that was run to generate this result.

inputs : a traits free representation of the inputs

outputs : Bunch

An Interface specific Bunch that contains all possible files that are generated by the interface. The outputs are used as the inputs to another node when interfaces are used in the pipeline.

runtime : Bunch

Contains attributes that describe the runtime environment when the Interface was run. Contains the attributes:

  • cmdline : The command line string that was executed
  • cwd : The directory the cmdline was executed in.
  • stdout : The output of running the cmdline.
  • stderr : Any error messages output from running cmdline.
  • returncode : The code returned from running the cmdline.
__init__(interface, runtime, inputs=None, outputs=None)
version

MpiCommandLine

class nipype.interfaces.base.MpiCommandLine(command=None, **inputs)

Bases: nipype.interfaces.base.CommandLine

Implements functionality to interact with command line programs that can be run with MPI (i.e. using ‘mpiexec’).

Examples

>>> from nipype.interfaces.base import MpiCommandLine
>>> mpi_cli = MpiCommandLine(command='my_mpi_prog')
>>> mpi_cli.inputs.args = '-v'
>>> mpi_cli.cmdline
'my_mpi_prog -v'
>>> mpi_cli.inputs.use_mpi = True
>>> mpi_cli.inputs.n_procs = 8
>>> mpi_cli.cmdline    
'mpiexec -n 8 my_mpi_prog -v'
__init__(command=None, **inputs)
aggregate_outputs(runtime=None, needed_outputs=None)

Collate expected outputs and check for existence

always_run
can_resume
cmd

sets base command, immutable

cmdline

Adds ‘mpiexec’ to begining of command

classmethod help(returnhelp=False)
input_spec

alias of MpiCommandLineInputSpec

raise_exception(runtime)
run(**inputs)

Execute this interface.

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

Parameters :

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 :

version
version_from_command(flag='-v')

MpiCommandLineInputSpec

class nipype.interfaces.base.MpiCommandLineInputSpec(**kwargs)

Bases: nipype.interfaces.base.CommandLineInputSpec

__init__(**kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters :

name : string

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(name, *trait)

Adds a trait attribute to this object.

Parameters :

name : string

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(object, prefix='')
all_trait_names()

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

base_trait(name)

Returns the base trait definition for a trait attribute.

Parameters :

name : string

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 : dictionary

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 : dictionary

Criteria for selecting trait attributes

clone_traits(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 names of the trait attributes to copy.

memo : dictionary

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 :

The newly cloned object. :

configure_traits(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 : string

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 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.

kind : string

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 : Boolean

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 object

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

id : string

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

scrollable : Boolean

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.

copy_traits(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 : dictionary

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 :

A list of attributes that the method was unable to copy, :

which is empty if all the attributes were successfully copied. :

copyable_trait_names(**metadata)

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

default_traits_view()

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

edit_traits(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 : window handle

A user interface component to use as the parent window for the object’s UI window.

kind : string

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 object

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

id : string

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

scrollable : Boolean

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.

editable_traits()

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

get(**kwargs)

Returns traited class as a dict

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

get_hashval(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 :

dict_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(**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_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

Parameters :interfaces : one or more traits Interface (sub)classes.
items()

Name, trait generator for user modifiable traits

on_trait_change(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
on_trait_event(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
print_traits(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 : Boolean

Indicates whether to display additional descriptive information.

remove_trait(name)

Removes a trait attribute from this object.

Parameters :

name : string

Name of the attribute to remove

remove_trait_listener(object, prefix='')
reset_traits(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 :

A list of attributes that the method was unable to reset, which is empty :

if all the attributes were successfully reset. :

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

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(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 : string

Name of the trait attribute on this object

object : object

The object with which to synchronize

alias : string

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

mutual : Boolean or integer

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

remove : Boolean or integer

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

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

Returns the trait definition for the name trait attribute.

Parameters :

name : string

Name of the attribute whose trait definition is to be returned

force : Boolean

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

copy : Boolean

Indicates whether to return the original trait definition or a copy

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

Parameters :

names : list of trait attribute names

Trait attributes whose values are requested

Returns :

A dictionary whose keys are the names passed as arguments and whose :

values are the corresponding trait values :

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 : boolean

Flag indicating whether to remove (True) or add the specified handler as a monitor for this 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 : dictionary

Criteria for selecting trait attributes

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

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

Trait attributes and their values to be set

Returns :

self :

The method returns this object, after setting attributes.

trait_setq(**traits)

Shortcut for setting object trait attributes.

Parameters :

traits : list of key/value pairs

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 : Boolean

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

trait_view(name=None, view_element=None)

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

Parameters :

name : string

Name of a view element

view_element : a ViewElement object

View element to associate

Returns :

A view element. :

trait_view_elements()

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(klass=None)

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

Parameters :

klass : a class

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

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(**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 : dictionary

Criteria for selecting trait attributes

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

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

MultiPath

class nipype.interfaces.base.MultiPath(trait=None, value=None, minlen=0, maxlen=9223372036854775807, items=True, **metadata)

Bases: traits.trait_types.List

Abstract class - shared functionality of input and output MultiPath

__init__(trait=None, value=None, minlen=0, maxlen=9223372036854775807, items=True, **metadata)

Returns a List trait.

Parameters :

trait : a trait or value that can be converted to a trait using Trait()

The type of item that the list contains. If not specified, the list can contain items of any type.

value : :

Default value for the list

minlen : integer

The minimum length of a list that can be assigned to the trait.

maxlen : integer

The maximum length of a list that can be assigned to the trait.

The length of the list assigned to the trait must be such that:: :

minlen <= len(list) <= maxlen

arg_error(method, arg_num, object, name, value)

Raises a TraitError exception to notify the user that a method on an instance received a positional argument of an incorrect type.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

value : object

The value passed to the argument

as_ctrait()

Returns a CTrait corresponding to the trait defined by this class.

clone(default_value=<missing>, **metadata)

Clones the contents of this object into a new instance of the same class, and then modifies the cloned copy using the specified default_value and metadata. Returns the cloned object as the result.

Note that subclasses can change the signature of this method if needed, but should always call the ‘super’ method if possible.

create_editor()

Returns the default UI editor for the trait.

dup_arg_error(method, arg_num, object, name)

Raises a TraitError exception to notify the user that a method on an instance received an argument as both a keyword argument and a positional argument.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

error(object, name, value)

Raises a TraitError exception.

Parameters :

object : object

The object whose attribute is being assigned

name : string

The name of the attribute being assigned

value : object

The proposed new value for the attribute

full_info(object, name, value)

Returns a description of the trait.

get_default_value()

Returns a tuple of the form: (default_value_type, default_value) which describes the default value for this trait. The default implementation analyzes the value of the trait’s default_value attribute and determines an appropriate default_value_type for default_value. If you need to override this method to provide a different result tuple, the following values are valid values for default_value_type:

  • 0, 1: The default_value item of the tuple is the default value.
  • 2: The object containing the trait is the default value.
  • 3: A new copy of the list specified by default_value is the default value.
  • 4: A new copy of the dictionary specified by default_value is the default value.
  • 5: A new instance of TraitListObject constructed using the default_value list is the default value.
  • 6: A new instance of TraitDictObject constructed using the default_value dictionary is the default value.
  • 7: default_value is a tuple of the form: (callable, args, kw), where callable is a callable, args is a tuple, and kw is either a dictionary or None. The default value is the result obtained by invoking callable(*args, **kw).
  • 8: default_value is a callable. The default value is the result obtained by invoking default_value*(*object), where object is the object containing the trait. If the trait has a validate() method, the validate() method is also called to validate the result.
  • 9: A new instance of TraitSetObject constructed using the default_value set is the default value.
get_editor(trait=None)

Returns a trait editor that allows the user to modify the trait trait.

Parameters :

trait : trait

The trait to be edited

get_value(object, name, trait=None)

Returns the current value of a property-based trait.

info()

Must return a string describing the type of value accepted by the trait handler.

The string should be a phrase describing the type defined by the TraitHandler subclass, rather than a complete sentence. For example, use the phrase, “a square sprocket” instead of the sentence, “The value must be a square sprocket.” The value returned by info() is combined with other information whenever an error occurs and therefore makes more sense to the user if the result is a phrase. The info() method is similar in purpose and use to the info attribute of a validator function.

Note that the result can include information specific to the particular trait handler instance. For example, TraitRange instances return a string indicating the range of values acceptable to the handler (e.g., “an integer in the range from 1 to 9”). If the info() method is not overridden, the default method returns the value of the ‘info_text’ attribute.

init()

Allows the trait to perform any additional initialization needed.

inner_traits()

Returns the inner trait (or traits) for this trait.

is_valid(object, name, value)
items_event()
keyword_error(method, object, name, value)

Raises a TraitError exception to notify the user that a method on an instance received a keyword argument of an incorrect type.

Parameters :

method : function

The method that encountered the error

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

value :

The value passed to the argument

missing_arg_error(method, arg_num, object, name)

Raises a TraitError exception to notify the user that a method on an instance failed to receive a required positional argument.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

repr(value)

Returns a printable representation of a value along with its type.

DEPRECATED: This functionality was only used to provide readable error messages. This functionality has been incorporated into TraitError itself.

Parameters :

value : object

The value to be printed.

return_error(method, object, value)

Raises a TraitError exception to notify the user that a method on an instance returned a value of incorrect type.

Parameters :

method : function

The method that encountered the error

object : object

The object whose method was called

value :

The value returned by the method

set_value(object, name, value)

Sets the cached value of a property-based trait and fires the appropriate trait change event.

validate(object, name, value)

OutputMultiPath

class nipype.interfaces.base.OutputMultiPath(trait=None, value=None, minlen=0, maxlen=9223372036854775807, items=True, **metadata)

Bases: nipype.interfaces.base.MultiPath

Implements a user friendly traits that accepts one or more paths to files or directories. This is the output version which return a single string whenever possible (when it was set to a single value or a list of length 1). Default value of this trait is _Undefined. It does not accept empty lists.

XXX This should only be used as a final resort. We should stick to established Traits to the extent possible.

XXX This needs to be vetted by somebody who understands traits

>>> from nipype.interfaces.base import OutputMultiPath
>>> class A(TraitedSpec):
...     foo = OutputMultiPath(File(exists=False))
>>> a = A()
>>> a.foo
<undefined>
>>> a.foo = '/software/temp/foo.txt'
>>> a.foo
'/software/temp/foo.txt'
>>> a.foo = ['/software/temp/foo.txt']
>>> a.foo
'/software/temp/foo.txt'
>>> a.foo = ['/software/temp/foo.txt', '/software/temp/goo.txt']
>>> a.foo
['/software/temp/foo.txt', '/software/temp/goo.txt']
__init__(trait=None, value=None, minlen=0, maxlen=9223372036854775807, items=True, **metadata)

Returns a List trait.

Parameters :

trait : a trait or value that can be converted to a trait using Trait()

The type of item that the list contains. If not specified, the list can contain items of any type.

value : :

Default value for the list

minlen : integer

The minimum length of a list that can be assigned to the trait.

maxlen : integer

The maximum length of a list that can be assigned to the trait.

The length of the list assigned to the trait must be such that:: :

minlen <= len(list) <= maxlen

arg_error(method, arg_num, object, name, value)

Raises a TraitError exception to notify the user that a method on an instance received a positional argument of an incorrect type.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

value : object

The value passed to the argument

as_ctrait()

Returns a CTrait corresponding to the trait defined by this class.

clone(default_value=<missing>, **metadata)

Clones the contents of this object into a new instance of the same class, and then modifies the cloned copy using the specified default_value and metadata. Returns the cloned object as the result.

Note that subclasses can change the signature of this method if needed, but should always call the ‘super’ method if possible.

create_editor()

Returns the default UI editor for the trait.

dup_arg_error(method, arg_num, object, name)

Raises a TraitError exception to notify the user that a method on an instance received an argument as both a keyword argument and a positional argument.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

error(object, name, value)

Raises a TraitError exception.

Parameters :

object : object

The object whose attribute is being assigned

name : string

The name of the attribute being assigned

value : object

The proposed new value for the attribute

full_info(object, name, value)

Returns a description of the trait.

get(object, name)
get_default_value()

Returns a tuple of the form: (default_value_type, default_value) which describes the default value for this trait. The default implementation analyzes the value of the trait’s default_value attribute and determines an appropriate default_value_type for default_value. If you need to override this method to provide a different result tuple, the following values are valid values for default_value_type:

  • 0, 1: The default_value item of the tuple is the default value.
  • 2: The object containing the trait is the default value.
  • 3: A new copy of the list specified by default_value is the default value.
  • 4: A new copy of the dictionary specified by default_value is the default value.
  • 5: A new instance of TraitListObject constructed using the default_value list is the default value.
  • 6: A new instance of TraitDictObject constructed using the default_value dictionary is the default value.
  • 7: default_value is a tuple of the form: (callable, args, kw), where callable is a callable, args is a tuple, and kw is either a dictionary or None. The default value is the result obtained by invoking callable(*args, **kw).
  • 8: default_value is a callable. The default value is the result obtained by invoking default_value*(*object), where object is the object containing the trait. If the trait has a validate() method, the validate() method is also called to validate the result.
  • 9: A new instance of TraitSetObject constructed using the default_value set is the default value.
get_editor(trait=None)

Returns a trait editor that allows the user to modify the trait trait.

Parameters :

trait : trait

The trait to be edited

get_value(object, name, trait=None)

Returns the current value of a property-based trait.

info()

Must return a string describing the type of value accepted by the trait handler.

The string should be a phrase describing the type defined by the TraitHandler subclass, rather than a complete sentence. For example, use the phrase, “a square sprocket” instead of the sentence, “The value must be a square sprocket.” The value returned by info() is combined with other information whenever an error occurs and therefore makes more sense to the user if the result is a phrase. The info() method is similar in purpose and use to the info attribute of a validator function.

Note that the result can include information specific to the particular trait handler instance. For example, TraitRange instances return a string indicating the range of values acceptable to the handler (e.g., “an integer in the range from 1 to 9”). If the info() method is not overridden, the default method returns the value of the ‘info_text’ attribute.

init()

Allows the trait to perform any additional initialization needed.

inner_traits()

Returns the inner trait (or traits) for this trait.

is_valid(object, name, value)
items_event()
keyword_error(method, object, name, value)

Raises a TraitError exception to notify the user that a method on an instance received a keyword argument of an incorrect type.

Parameters :

method : function

The method that encountered the error

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

value :

The value passed to the argument

missing_arg_error(method, arg_num, object, name)

Raises a TraitError exception to notify the user that a method on an instance failed to receive a required positional argument.

Parameters :

method : function

The method that encountered the error

arg_num : integer

The position of the incorrect argument in the argument list

object : object

The object whose method was called

name : string

The name of the parameter corresponding to the incorrect argument

repr(value)

Returns a printable representation of a value along with its type.

DEPRECATED: This functionality was only used to provide readable error messages. This functionality has been incorporated into TraitError itself.

Parameters :

value : object

The value to be printed.

return_error(method, object, value)

Raises a TraitError exception to notify the user that a method on an instance returned a value of incorrect type.

Parameters :

method : function

The method that encountered the error

object : object

The object whose method was called

value :

The value returned by the method

set(object, name, value)
set_value(object, name, value)

Sets the cached value of a property-based trait and fires the appropriate trait change event.

validate(object, name, value)

SEMLikeCommandLine

class nipype.interfaces.base.SEMLikeCommandLine(command=None, **inputs)

Bases: nipype.interfaces.base.CommandLine

By default in SEM derived interface all outputs have corresponding inputs. However, some SEM commands create outputs that are not defined in the XML. In those cases one has to create a subclass of the autogenerated one and overload the _list_outputs method. _outputs_from_inputs should still be used but only for the reduced (by excluding those that do not have corresponding inputs list of outputs.

__init__(command=None, **inputs)
aggregate_outputs(runtime=None, needed_outputs=None)

Collate expected outputs and check for existence

always_run
can_resume
cmd

sets base command, immutable

cmdline

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

classmethod help(returnhelp=False)
input_spec

alias of CommandLineInputSpec

raise_exception(runtime)
run(**inputs)

Execute this interface.

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

Parameters :

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 :

version
version_from_command(flag='-v')

StdOutCommandLine

class nipype.interfaces.base.StdOutCommandLine(command=None, **inputs)

Bases: nipype.interfaces.base.CommandLine

__init__(command=None, **inputs)
aggregate_outputs(runtime=None, needed_outputs=None)

Collate expected outputs and check for existence

always_run
can_resume
cmd

sets base command, immutable

cmdline

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

classmethod help(returnhelp=False)
input_spec

alias of StdOutCommandLineInputSpec

raise_exception(runtime)
run(**inputs)

Execute this interface.

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

Parameters :

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 :

version
version_from_command(flag='-v')

StdOutCommandLineInputSpec

class nipype.interfaces.base.StdOutCommandLineInputSpec(**kwargs)

Bases: nipype.interfaces.base.CommandLineInputSpec

__init__(**kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters :

name : string

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(name, *trait)

Adds a trait attribute to this object.

Parameters :

name : string

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(object, prefix='')
all_trait_names()

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

base_trait(name)

Returns the base trait definition for a trait attribute.

Parameters :

name : string

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 : dictionary

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 : dictionary

Criteria for selecting trait attributes

clone_traits(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 names of the trait attributes to copy.

memo : dictionary

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 :

The newly cloned object. :

configure_traits(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 : string

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 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.

kind : string

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 : Boolean

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 object

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

id : string

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

scrollable : Boolean

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.

copy_traits(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 : dictionary

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 :

A list of attributes that the method was unable to copy, :

which is empty if all the attributes were successfully copied. :

copyable_trait_names(**metadata)

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

default_traits_view()

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

edit_traits(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 : window handle

A user interface component to use as the parent window for the object’s UI window.

kind : string

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 object

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

id : string

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

scrollable : Boolean

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.

editable_traits()

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

get(**kwargs)

Returns traited class as a dict

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

get_hashval(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 :

dict_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(**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_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

Parameters :interfaces : one or more traits Interface (sub)classes.
items()

Name, trait generator for user modifiable traits

on_trait_change(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
on_trait_event(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
print_traits(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 : Boolean

Indicates whether to display additional descriptive information.

remove_trait(name)

Removes a trait attribute from this object.

Parameters :

name : string

Name of the attribute to remove

remove_trait_listener(object, prefix='')
reset_traits(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 :

A list of attributes that the method was unable to reset, which is empty :

if all the attributes were successfully reset. :

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

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(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 : string

Name of the trait attribute on this object

object : object

The object with which to synchronize

alias : string

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

mutual : Boolean or integer

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

remove : Boolean or integer

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

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

Returns the trait definition for the name trait attribute.

Parameters :

name : string

Name of the attribute whose trait definition is to be returned

force : Boolean

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

copy : Boolean

Indicates whether to return the original trait definition or a copy

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

Parameters :

names : list of trait attribute names

Trait attributes whose values are requested

Returns :

A dictionary whose keys are the names passed as arguments and whose :

values are the corresponding trait values :

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 : boolean

Flag indicating whether to remove (True) or add the specified handler as a monitor for this 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 : dictionary

Criteria for selecting trait attributes

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

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

Trait attributes and their values to be set

Returns :

self :

The method returns this object, after setting attributes.

trait_setq(**traits)

Shortcut for setting object trait attributes.

Parameters :

traits : list of key/value pairs

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 : Boolean

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

trait_view(name=None, view_element=None)

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

Parameters :

name : string

Name of a view element

view_element : a ViewElement object

View element to associate

Returns :

A view element. :

trait_view_elements()

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(klass=None)

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

Parameters :

klass : a class

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

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(**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 : dictionary

Criteria for selecting trait attributes

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

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

Stream

class nipype.interfaces.base.Stream(name, impl)

Bases: object

Function to capture stdout and stderr streams with timestamps

http://stackoverflow.com/questions/4984549/merge-and-sync-stdout-and-stderr/5188359#5188359

__init__(name, impl)
fileno()

Pass-through for file descriptor.

read(drain=0)

Read from the file descriptor. If ‘drain’ set, read until EOF.

TraitedSpec

class nipype.interfaces.base.TraitedSpec(**kwargs)

Bases: nipype.interfaces.base.BaseTraitedSpec

Create a subclass with strict traits.

This is used in 90% of the cases.

__init__(**kwargs)

Initialize handlers and inputs

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

Parameters :

name : string

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(name, *trait)

Adds a trait attribute to this object.

Parameters :

name : string

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(object, prefix='')
all_trait_names()

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

base_trait(name)

Returns the base trait definition for a trait attribute.

Parameters :

name : string

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 : dictionary

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 : dictionary

Criteria for selecting trait attributes

clone_traits(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 names of the trait attributes to copy.

memo : dictionary

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 :

The newly cloned object. :

configure_traits(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 : string

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 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.

kind : string

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 : Boolean

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 object

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

id : string

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

scrollable : Boolean

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.

copy_traits(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 : dictionary

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 :

A list of attributes that the method was unable to copy, :

which is empty if all the attributes were successfully copied. :

copyable_trait_names(**metadata)

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

default_traits_view()

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

edit_traits(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 : window handle

A user interface component to use as the parent window for the object’s UI window.

kind : string

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 object

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

id : string

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

scrollable : Boolean

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.

editable_traits()

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

get(**kwargs)

Returns traited class as a dict

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

get_hashval(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 :

dict_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(**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_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

Parameters :interfaces : one or more traits Interface (sub)classes.
items()

Name, trait generator for user modifiable traits

on_trait_change(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
on_trait_event(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 : string

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 : Boolean

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

dispatch : string

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

  • ‘same’: Run notifications on the same thread as this one.
  • ‘ui’: Run notifications on the UI thread, and allow them to be queued and deferred.
  • ‘fast_ui’: Run notifications on the UI thread, and process them immediately.
  • ‘new’: Run notifications in a new thread.
print_traits(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 : Boolean

Indicates whether to display additional descriptive information.

remove_trait(name)

Removes a trait attribute from this object.

Parameters :

name : string

Name of the attribute to remove

remove_trait_listener(object, prefix='')
reset_traits(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 :

A list of attributes that the method was unable to reset, which is empty :

if all the attributes were successfully reset. :

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

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(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 : string

Name of the trait attribute on this object

object : object

The object with which to synchronize

alias : string

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

mutual : Boolean or integer

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

remove : Boolean or integer

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

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

Returns the trait definition for the name trait attribute.

Parameters :

name : string

Name of the attribute whose trait definition is to be returned

force : Boolean

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

copy : Boolean

Indicates whether to return the original trait definition or a copy

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

Parameters :

names : list of trait attribute names

Trait attributes whose values are requested

Returns :

A dictionary whose keys are the names passed as arguments and whose :

values are the corresponding trait values :

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 : boolean

Flag indicating whether to remove (True) or add the specified handler as a monitor for this 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 : dictionary

Criteria for selecting trait attributes

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

Shortcut for setting object trait attributes.

Parameters :

trait_change_notify : Boolean

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 : list of key/value pairs

Trait attributes and their values to be set

Returns :

self :

The method returns this object, after setting attributes.

trait_setq(**traits)

Shortcut for setting object trait attributes.

Parameters :

traits : list of key/value pairs

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 : Boolean

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

trait_view(name=None, view_element=None)

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

Parameters :

name : string

Name of a view element

view_element : a ViewElement object

View element to associate

Returns :

A view element. :

trait_view_elements()

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(klass=None)

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

Parameters :

klass : a class

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

  • Group
  • Item
  • View
  • ViewElement
  • ViewSubElement
traits(**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 : dictionary

Criteria for selecting trait attributes

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

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

Functions

nipype.interfaces.base.load_template(name)

Load a template from the script_templates directory

Parameters :

name : str

The name of the file to load

Returns :

template : string.Template

nipype.interfaces.base.run_command(runtime, timeout=0.01)

Run a command, read stdout and stderr, prefix with timestamp. The returned runtime contains a merged stdout+stderr log with timestamps

http://stackoverflow.com/questions/4984549/merge-and-sync-stdout-and-stderr/5188359#5188359