Table Of Contents

Previous topic

MARS api reference

Next topic

4-D Reconstruction User Guide

This Page

ALT api reference

vplants.mars_alt.alt.lineage_editor

class MyApp(img1, img2)[source]

Bases: enthought.traits.has_traits.HasTraits

classmethod add_class_trait(name, *trait)

Adds a named trait attribute to this class.

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_lineage()[source]
add_trait(name, *trait)

Adds a trait attribute to this object.

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.

name : string
Name of the attribute whose trait definition is returned.

This method is similar to the trait() method, and returns a different result only in the case where the trait attribute defined by name is a delegate. In this case, the base_trait() method follows the delegation chain until a non-delegated trait attribute is reached, and returns the definition of that attribute’s trait as the result.

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.

metadata : dictionary
Criteria for selecting trait attributes

This method is similar to the traits() method, but returns only the names of the matching trait attributes, not the trait definitions.

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.

metadata : dictionary
Criteria for selecting trait attributes

The keys of the returned dictionary are the trait attribute names, and the values are their corresponding trait definition objects.

If no metadata information is specified, then all explicitly defined trait attributes defined for the class are returned.

Otherwise, the metadata keyword dictionary is assumed to define a set of search criteria for selecting trait attributes of interest. The metadata dictionary keys correspond to the names of trait metadata attributes to examine, and the values correspond to the values the metadata attribute must have in order to be included in the search results.

The metadata values either may be simple Python values like strings or integers, or may be lambda expressions or functions that return True if the trait attribute is to be included in the result. A lambda expression or function must receive a single argument, which is the value of the trait metadata attribute being tested. If more than one metadata keyword is specified, a trait attribute must match the metadata values of all keywords to be included in the result.

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

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

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

The newly cloned object.

Creates a new object that is a clone of the current object. If traits is None (the default), then all explicit trait attributes defined for this object are cloned. If traits is ‘all’ or an empty list, the list of traits returned by all_trait_names() is used; otherwise, traits must be a list of the names of the trait attributes to be cloned.

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.

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 enthought.traits.ui.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.

This method is intended for use in applications that do not normally have a GUI. Control does not resume in the calling application until the user closes the dialog box.

The method attempts to open and unpickle the contents of filename before displaying the dialog box. When editing is complete, the method attempts to pickle the updated contents of the object back to filename. If the file referenced by filename does not exist, the object is not modified before displaying the dialog box. If filename is unspecified or None, no pickling or unpickling occurs.

If edit is True (the default), a dialog box for editing the current object is displayed. If edit is False or None, no dialog box is displayed. You can use edit=False if you want the object to be restored from the contents of filename, without being modified by the user.

copy_traits(other, traits=None, memo=None, copy=None, **metadata)

Copies another object’s trait attributes into this one.

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

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.

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 enthought.traits.ui.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(*names, **metadata)

Shortcut for getting object trait attributes.

names : list of trait attribute names
Trait attributes whose values are requested

A dictionary whose keys are the names passed as arguments and whose values are the corresponding trait values

Looks up the value of each trait whose name is passed as an argument and returns a dictionary containing the resulting name/value pairs. If any name does not correspond to a defined trait, it is not included in the result.

If no names are specified, the result is a dictionary containing name/value pairs for all traits defined on the object.

get_mapping()[source]
has_traits_interface(*interfaces)

Returns whether the object implements a specified traits interface.

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

Tests whether the object implements one or more of the interfaces specified by interfaces. Return True if it does, and False otherwise.

load_mapping()[source]
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.

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.

Multiple handlers can be defined for the same object, or even for the same trait attribute on the same object. If name is not specified or is None, handler is invoked when any trait attribute on the object is changed.

The name parameter is a single xname or a list of xname names, where an xname is an extended name of the form:

xname2[('.'|':') xname2]*

An xname2 is of the form:

( xname3 | '['xname3[','xname3]*']' ) ['*']

An xname3 is of the form:

xname | ['+'|'-'][name] | name['?' | ('+'|'-')[name]]

A name is any valid Python attribute name. The semantic meaning of this notation is as follows:

  • item1.item2 means item1 is a trait containing an object (or objects if item1 is a list or dict) with a trait called item2. Changes to either item1 or item2 cause a notification to be generated.
  • item1:item2 means item1 is a trait containing an object (or objects if item1 is a list or dict) with a trait called item2. Changes to item2 cause a notification to be generated, while changes to item1 do not (i.e., the ‘:’ indicates that changes to the link object should not be reported).
  • [ item1, item2, ..., itemN ]: A list which matches any of the specified items. Note that at the topmost level, the surrounding square brackets are optional.
  • name?: If the current object does not have an attribute called name, the reference can be ignored. If the ‘?’ character is omitted, the current object must have a trait called name, otherwise an exception will be raised.
  • prefix+: Matches any trait on the object whose name begins with prefix.
  • +metadata_name: Matches any trait on the object having metadata_name metadata.
  • -metadata_name: Matches any trait on the object which does not have metadata_name metadata.
  • prefix+metadata_name: Matches any trait on the object whose name begins with prefix and which has metadata_name metadata.
  • prefix-metadata_name: Matches any trait on the object whose name begins with prefix and which does not have metadata_name metadata.
  • +: Matches all traits on the object.
  • pattern*: Matches object graphs where pattern occurs one or more times (useful for setting up listeners on recursive data structures like trees or linked lists).

Some examples of valid names and their meaning are as follows:

  • ‘foo,bar,baz’: Listen for trait changes to object.foo, object.bar, and object.baz.
  • [‘foo’,’bar’,’baz’]: Equivalent to ‘foo,bar,baz’, but may be more useful in cases where the individual items are computed.
  • ‘foo.bar.baz’: Listen for trait changes to object.foo.bar.baz and report changes to object.foo, object.foo.bar or object.foo.bar.baz.
  • ‘foo:bar:baz’: Listen for changes to object.foo.bar.baz, and only report changes to object.foo.bar.baz.
  • ‘foo.[bar,baz]’: Listen for trait changes to object.foo.bar and object.foo.baz.
  • ‘[left,right]*.name’: Listen for trait changes to the name trait of each node of a tree having left and right links to other tree nodes, and where object the method is applied to the root node of the tree.
  • +dirty: Listen for trait changes on any trait in the object which has the ‘dirty’ metadata set.
  • ‘foo.+dirty’: Listen for trait changes on any trait in object.foo which has the ‘dirty’ metadata set.
  • ‘foo.[bar,-dirty]’: Listen for trait changes on object.foo.bar or any trait on object.foo which does not have ‘dirty’ metadata set.

Note that any of the intermediate (i.e., non-final) links in a pattern can be traits of type Instance, List or Dict. In the case of List and Dict traits, the subsequent portion of the pattern is applied to each item in the list, or value in the dictionary.

For example, if the self.children is a list, ‘children.name’ listens for trait changes to the name trait for each item in the self.children list.

Note that items added to or removed from a list or dictionary in the pattern will cause the handler routine to be invoked as well, since this is treated as an implied change to the item’s trait being monitored.

The signature of the handler supplied also has an effect on how changes to intermediate traits are processed. The five valid handler signatures are:

  1. handler()
  2. handler(new)
  3. handler(name,new)
  4. handler(object,name,new)
  5. handler(object,name,old,new)

For signatures 1, 4 and 5, any change to any element of a path being listened to invokes the handler with information about the particular element that was modified (e.g., if the item being monitored is ‘foo.bar.baz’, a change to ‘bar’ will call handler with the following information:

  • object: object.foo
  • name: bar
  • old: old value for object.foo.bar
  • new: new value for object.foo.bar

If one of the intermediate links is a List or Dict, the call to handler may report an _items changed event. If in the previous example, bar is a List, and a new item is added to bar, then the information passed to handler would be:

  • object: object.foo
  • name: bar_items
  • old: Undefined
  • new: TraitListEvent whose added trait contains the new item added to bar.

For signatures 2 and 3, the handler does not receive enough information to discern between a change to the final trait being listened to and a change to an intermediate link. In this case, the event dispatcher will attempt to map a change to an intermediate link to its effective change on the final trait. This only works if all of the intermediate links are single values (such as an Instance or Any trait) and not Lists or Dicts. If the modified intermediate trait or any subsequent intermediate trait preceding the final trait is a List or Dict, then a TraitError is raised, since the effective value for the final trait cannot in general be resolved unambiguously. To prevent TraitErrors in this case, use the ‘:’ separator to suppress notifications for changes to any of the intermediate links.

Handler signature 1 also has the special characteristic that if a final trait is a List or Dict, it will automatically handle ‘_items’ changed events for the final trait as well. This can be useful in cases where the handler only needs to know that some aspect of the final trait has been changed. For all other handler signatures, you must explicitly specify the ‘xxx_items’ trait if you want to be notified of changes to any of the items of the ‘xxx’ trait.

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.

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.

Multiple handlers can be defined for the same object, or even for the same trait attribute on the same object. If name is not specified or is None, handler is invoked when any trait attribute on the object is changed.

The name parameter is a single xname or a list of xname names, where an xname is an extended name of the form:

xname2[('.'|':') xname2]*

An xname2 is of the form:

( xname3 | '['xname3[','xname3]*']' ) ['*']

An xname3 is of the form:

xname | ['+'|'-'][name] | name['?' | ('+'|'-')[name]]

A name is any valid Python attribute name. The semantic meaning of this notation is as follows:

  • item1.item2 means item1 is a trait containing an object (or objects if item1 is a list or dict) with a trait called item2. Changes to either item1 or item2 cause a notification to be generated.
  • item1:item2 means item1 is a trait containing an object (or objects if item1 is a list or dict) with a trait called item2. Changes to item2 cause a notification to be generated, while changes to item1 do not (i.e., the ‘:’ indicates that changes to the link object should not be reported).
  • [ item1, item2, ..., itemN ]: A list which matches any of the specified items. Note that at the topmost level, the surrounding square brackets are optional.
  • name?: If the current object does not have an attribute called name, the reference can be ignored. If the ‘?’ character is omitted, the current object must have a trait called name, otherwise an exception will be raised.
  • prefix+: Matches any trait on the object whose name begins with prefix.
  • +metadata_name: Matches any trait on the object having metadata_name metadata.
  • -metadata_name: Matches any trait on the object which does not have metadata_name metadata.
  • prefix+metadata_name: Matches any trait on the object whose name begins with prefix and which has metadata_name metadata.
  • prefix-metadata_name: Matches any trait on the object whose name begins with prefix and which does not have metadata_name metadata.
  • +: Matches all traits on the object.
  • pattern*: Matches object graphs where pattern occurs one or more times (useful for setting up listeners on recursive data structures like trees or linked lists).

Some examples of valid names and their meaning are as follows:

  • ‘foo,bar,baz’: Listen for trait changes to object.foo, object.bar, and object.baz.
  • [‘foo’,’bar’,’baz’]: Equivalent to ‘foo,bar,baz’, but may be more useful in cases where the individual items are computed.
  • ‘foo.bar.baz’: Listen for trait changes to object.foo.bar.baz and report changes to object.foo, object.foo.bar or object.foo.bar.baz.
  • ‘foo:bar:baz’: Listen for changes to object.foo.bar.baz, and only report changes to object.foo.bar.baz.
  • ‘foo.[bar,baz]’: Listen for trait changes to object.foo.bar and object.foo.baz.
  • ‘[left,right]*.name’: Listen for trait changes to the name trait of each node of a tree having left and right links to other tree nodes, and where object the method is applied to the root node of the tree.
  • +dirty: Listen for trait changes on any trait in the object which has the ‘dirty’ metadata set.
  • ‘foo.+dirty’: Listen for trait changes on any trait in object.foo which has the ‘dirty’ metadata set.
  • ‘foo.[bar,-dirty]’: Listen for trait changes on object.foo.bar or any trait on object.foo which does not have ‘dirty’ metadata set.

Note that any of the intermediate (i.e., non-final) links in a pattern can be traits of type Instance, List or Dict. In the case of List and Dict traits, the subsequent portion of the pattern is applied to each item in the list, or value in the dictionary.

For example, if the self.children is a list, ‘children.name’ listens for trait changes to the name trait for each item in the self.children list.

Note that items added to or removed from a list or dictionary in the pattern will cause the handler routine to be invoked as well, since this is treated as an implied change to the item’s trait being monitored.

The signature of the handler supplied also has an effect on how changes to intermediate traits are processed. The five valid handler signatures are:

  1. handler()
  2. handler(new)
  3. handler(name,new)
  4. handler(object,name,new)
  5. handler(object,name,old,new)

For signatures 1, 4 and 5, any change to any element of a path being listened to invokes the handler with information about the particular element that was modified (e.g., if the item being monitored is ‘foo.bar.baz’, a change to ‘bar’ will call handler with the following information:

  • object: object.foo
  • name: bar
  • old: old value for object.foo.bar
  • new: new value for object.foo.bar

If one of the intermediate links is a List or Dict, the call to handler may report an _items changed event. If in the previous example, bar is a List, and a new item is added to bar, then the information passed to handler would be:

  • object: object.foo
  • name: bar_items
  • old: Undefined
  • new: TraitListEvent whose added trait contains the new item added to bar.

For signatures 2 and 3, the handler does not receive enough information to discern between a change to the final trait being listened to and a change to an intermediate link. In this case, the event dispatcher will attempt to map a change to an intermediate link to its effective change on the final trait. This only works if all of the intermediate links are single values (such as an Instance or Any trait) and not Lists or Dicts. If the modified intermediate trait or any subsequent intermediate trait preceding the final trait is a List or Dict, then a TraitError is raised, since the effective value for the final trait cannot in general be resolved unambiguously. To prevent TraitErrors in this case, use the ‘:’ separator to suppress notifications for changes to any of the intermediate links.

Handler signature 1 also has the special characteristic that if a final trait is a List or Dict, it will automatically handle ‘_items’ changed events for the final trait as well. This can be useful in cases where the handler only needs to know that some aspect of the final trait has been changed. For all other handler signatures, you must explicitly specify the ‘xxx_items’ trait if you want to be notified of changes to any of the items of the ‘xxx’ trait.

picker_callback1(picker_obj)[source]
picker_callback2(picker_obj)[source]
picker_return_callback1(picker_obj)[source]
picker_return_callback2(picker_obj)[source]
populate_scene1()[source]
populate_scene2()[source]
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.

show_help : Boolean
Indicates whether to display additional descriptive information.
remove_trait(name)

Removes a trait attribute from this object.

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.

traits : list of strings
Names of trait attributes to reset

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

Resets each of the traits whose names are specified in the traits list to their default values. If traits is None or omitted, the method resets all explicitly-defined object trait attributes to their default values. Note that this does not affect wildcard trait attraibutes or trait attributes added via add_trait(), unless they are explicitly named in traits.

set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

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
self
The method returns this object, after setting attributes.

Treats each keyword argument to the method as the name of a trait attribute and sets the corresponding trait attribute to the value specified. This is a useful shorthand when a number of trait attributes need to be set on an object, or a trait attribute value needs to be set in a lambda function. For example, you can write:

person.trait_set(name='Bill', age=27)

instead of:

person.name = 'Bill'
person.age = 27
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.

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)

In mutual synchronization, any change to the value of the specified trait attribute of either object results in the same value being assigned to the corresponding trait attribute of the other object. In one-way synchronization, any change to the value of the attribute on this object causes the corresponding trait attribute of object to be updated, but not vice versa.

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

Returns the trait definition for the name trait attribute.

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

If force is False (the default) and name is the name of an implicitly defined trait attribute that has never been referenced explicitly (i.e., has not yet been defined), the result is None. In all other cases, the result is the trait definition object associated with name.

If copy is True, and a valid trait definition is found for name, a copy of the trait found is returned. In all other cases, the trait definition found is returned unmodified (the default).

trait_context()

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

trait_get(*names, **metadata)

Shortcut for getting object trait attributes.

names : list of trait attribute names
Trait attributes whose values are requested

A dictionary whose keys are the names passed as arguments and whose values are the corresponding trait values

Looks up the value of each trait whose name is passed as an argument and returns a dictionary containing the resulting name/value pairs. If any name does not correspond to a defined trait, it is not included in the result.

If no names are specified, the result is a dictionary containing name/value pairs for all traits defined on the object.

trait_items_event

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.

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.

If remove is omitted or False, the specified handler is added to the list of active monitors; if remove is True, the handler is removed from the active monitor list.

trait_names(**metadata)

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

metadata : dictionary
Criteria for selecting trait attributes

This method is similar to the traits() method, but returns only the names of the matching trait attributes, not the trait definitions.

trait_property_changed

trait_property_changed(name,old_value[,new_value])

trait_set(trait_change_notify=True, **traits)

Shortcut for setting object trait attributes.

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
self
The method returns this object, after setting attributes.

Treats each keyword argument to the method as the name of a trait attribute and sets the corresponding trait attribute to the value specified. This is a useful shorthand when a number of trait attributes need to be set on an object, or a trait attribute value needs to be set in a lambda function. For example, you can write:

person.trait_set(name='Bill', age=27)

instead of:

person.name = 'Bill'
person.age = 27
trait_setq(**traits)

Shortcut for setting object trait attributes.

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).
self
The method returns this object, after setting attributes.

Treats each keyword argument to the method as the name of a trait attribute and sets the corresponding trait attribute to the value specified. This is a useful shorthand when a number of trait attributes need to be set on an object, or a trait attribute value needs to be set in a lambda function. For example, you can write:

person.trait_setq(name='Bill', age=27)

instead of:

person.name = 'Bill'
person.age = 27
classmethod trait_subclasses(all=False)

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

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.

name : string
Name of a view element
view_element : a ViewElement object
View element to associate

A view element.

If both name and view_element are specified, the view element is associated with name for the current object’s class. (That is, view_element is added to the ViewElements object associated with the current object’s class, indexed by name.)

If only name is specified, the function returns the view element object associated with name, or None if name has no associated view element. View elements retrieved by this function are those that are bound to a class attribute in the class definition, or that are associated with a name by a previous call to this method.

If neither name nor view_element is specified, the method returns a View object, based on the following order of preference:

  1. If there is a View object named traits_view associated with the current object, it is returned.
  2. If there is exactly one View object associated the current object, it is returned.
  3. Otherwise, it returns a View object containing items for all the non-event trait attributes on the current object.
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.

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

If klass is specified, the list of names is filtered such that only objects that are instances of the specified class are returned.

traits(**metadata)

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

metadata : dictionary
Criteria for selecting trait attributes

The keys of the returned dictionary are the trait attribute names, and the values are their corresponding trait definition objects.

If no metadata information is specified, then all explicitly defined trait attributes defined for the object are returned.

Otherwise, the metadata keyword dictionary is assumed to define a set of search criteria for selecting trait attributes of interest. The metadata dictionary keys correspond to the names of trait metadata attributes to examine, and the values correspond to the values the metadata attribute must have in order to be included in the search results.

The metadata values either may be simple Python values like strings or integers, or may be lambda expressions or functions that return True if the trait attribute is to be included in the result. A lambda expression or function must receive a single argument, which is the value of the trait metadata attribute being tested. If more than one metadata keyword is specified, a trait attribute must match the metadata values of all keywords to be included in the result.

traits_init

traits_init()

traits_inited

traits_inited([True])

validate_trait(name, value)

Validates whether a value is legal for a trait.

Returns the validated value if it is valid.

class MyLineage[source]

Bases: object

add_daughter(label)[source]
add_mother(label)[source]
get_current_mother()[source]
get_daughters(label)[source]
get_id()[source]
get_mothers()[source]
load_mapping(mapping)[source]
remove_daughter(label)[source]
remove_mother(label)[source]
set_current_mother(label)[source]
set_id(label)[source]
img2polydata(image, subdivision=64)[source]

Convert a SpatialImage to a PolyData object with cells surface

: Parameters :

vplants.mars_alt.alt.alt_preparation

alt_preparation(mapping, imgFus0, imgFus1, imgSeg0, imgSeg1)[source]

convert the initial set of cell lineages to voxel correspondances.

Parameters :
  • mapping (dictionnary) - initial set of cell lineages
  • imgFus0 (openalea.image.SpatialImage) - parent fusion image
  • imgFus1 (openalea.image.SpatialImage) - daughter fusion image
  • imgSeg0 (openalea.image.SpatialImage) - parent segmented image
  • imgSeg1 (openalea.image.SpatialImage) - daughter segmented image
Return :
  • imgFusResampled (openalea.image.SpatialImage) - resampled fused image
  • imgSegResampled (openalea.image.SpatialImage) - resampled segmented image
mapping2barycenter(tissue0, tissue1, mapping)[source]

convert the initial set of cell lineages to voxel correspondances.

Parameters :
  • tissue0 (openalea.image.SpatialImage) - graph of fusion image T0
  • tissue1 (openalea.image.SpatialImage) - graph of fusion image T1
  • mapping (dictionnary) - initial set of cell lineages
Return :
  • points0 (list) - barycenters of the parent cells
  • points1 (list) - barycenters of the daughter cells

vplants.mars_alt.alt.deformation_field

deformation_field(imgSeg1, imgSeg2, mapping, sigma)[source]
Principles :

This module implements an interpolation of the vector field based on a set of high confidence lineages.

Algorithm :

First the vector that links the centre of mass (point1) in each one of the parent cells and the center of mass (point2) of its descendants is computed.

Then, the dense vector field is computed by interpolating between these vectors using an smoothed SKIZ. The SKIZ is obtained and smoothed by using a Gaussian filter (:math:`sigma`=5).

Parameters :
  • imgSeg1 (openalea.image.SpatialImage) - segmented image representing the parent cells
  • imgSeg2 (openalea.image.SpatialImage) - segmented image representing the daugther cells
  • `mapping’ (dict) - expert mapping for initialisation
  • ‘sigma’ (float, optional) - standard deviation of the Gaussian function. Default Sigma = 5.
Returns :

vector field

Returns Type:

openalea.image.SpatialImage

Examples :

from vplants.mars_alt import deformation_field

vectorfield = deformation_field(image, pts1, pts2, sigma=3)

gaussian_filter(imgSeg1, sigma)[source]

Implement a gaussian filter on each component of a 3D image.

skiz(image, points, vectors=None)[source]

Compute the Skeleton of Influence Zone - also know as Generalized Voronoi Diagram.

Compute a labelled image ...

Parameters :
  • image : initial 3d image to get its shape
  • points : a list of 3d points
  • vectors: a list of 3d points
Returns :
  • labelled image with the same shape of the initial one.

vplants.mars_alt.alt.candidate_lineaging

candidate_lineaging(im_0, im_1, dist=3, ndiv=8, bkgdLabel=1, rfernandezCompatible=True, candidate_method='cell_shape')[source]

Given two images of an organ at t0 and t1, tries to find cell lineages.

Parameters :
  • im_0 : segmented image of organ a t0

  • im_1 : segmented image of organ a t1

  • dist : distance between mother boundary and child barycenter beyond which child is disregarded.

  • ndiv : a limit to the number of divisions a cell can have between two images.

  • bkgdLabel : value of the background label of the input images.

  • candidate_method : name of the method to use. “cell_shape” means that the distance dist is computed

    starting from the mother cell’s boundary. “cell_as_box” considers cells as boxes and the distance is computed from the mother cell’s barycenter corrected by the mean radius of cells. The mean radius of cell is the mean diagonal of all cells’ bouding boxes.

Returns :

Mapping of mother to candidate children with a score (or a distance) for each child.

Returns Type:

dict

equal_lineages(d1, d2, epsilon=1e-10)[source]

Compare two mappings and return True. If the mappings are candidate mappings then the values are list of (child, score) tuples. In that case the epsilon is used to compare the scores (if difference of scores < epsilon, then they are the same).

Parameters :
  • d1 (dict) - a mapping from mother label to child labels. Child labels can be (label, score(float)) tuples.

  • d2 (dict) - a mapping from mother label to child labels. Child labels can be (label, score(float)) tuples.

  • epsilon (float) - In case child list contains scores, scores between d1 and d2 childs are the same if

    their difference is below epsilon.

Returns :

True if keys are the same in d1 and d2, if m1 has the same child labels as m2 and if child score differences are below epsilon. Else False.

Return Type:

bool

get_bounding_boxes(image, bkgdLabel)[source]

Gets the bounding box in real coordinates for each label in image.

Parameters :
  • imgSeg (openalea.image.SpatialImage) - segmented image representing the cells
  • bkgdLabel (int) - value of the background label
Returns :

A dictionnary mapping cell labels to bounding boxes in real coordinates.

get_closest_per_label(boxDict0, boxDict1, distance, ndiv, bkgdLabel, as_scores=True, labelOffset=0)[source]

Return a candidate mapping given two sets of cell bounding boxes.

Parameters :
  • boxDict0 (dict) - dictionnary mapping mother cells to their bounding boxes.

  • boxDict1 (dict) - dictionnary mapping child cells to their bounding boxes.

  • distance (float) - distance to mother’s bounding box beyond which child cells are disregarded.

    Child cells that have their barycenters within the mother BB have a distance of 0.0.

  • ndiv (int) - number of possible divisions between two images

  • bkgdLabel (int) - value of the background label.

  • as_scores (bool) - return scores instead of relative distances.

  • labelOffset (bool) - offset to make returned labels start at a given value.

Returns :

vector field

Returns Type:

openalea.image.SpatialImage

point_in_box(pt, box, margin=0.0)[source]

Test if 3D pt is is box.

Parameters :
  • pt (3-uple) - the point to test
  • box (3-uple-of-2-uples) - the box ((minX, maxX), (minY, maxY), (minZ, maxZ))
  • margin (float) - a distance to consider for non-strict matching.
Returns :

If it’s beyond the box (adjusted by the margin) : returns -1 If it is strictly inside (or on the border) of the box : return 0 If it is in the margin, return 1.

py_get_candidate_successors(imgSeg1, imgSeg2, distance, ndiv, bkgdLabel, as_scores=True, rfernandezLabelSpace=False)[source]

Estimates candidate lineages between cells in imgSeg1 and cells in imgSeg2.

This method approximates the cells as boxes. Images must be 3D (even if only one pixel wide in Z).

Parameters:
  • imgSeg1 (openalea.image.SpatialImage) - segmented image representing the parent cells

  • imgSeg2 (openalea.image.SpatialImage) - segmented image representing the daugther cells

  • distance (float) - distance between mother boundary and child barycenter beyond which child is disregarded.

  • ndiv (int) - number of divisions between two images.

  • bkgdLabel (int) - label to consider as the background.

  • as_scores (bool, optional) - if True, the returned mapping contains scores (highest confidence is 1.0,

    lowest confidence is 0.0) else the mapping contains relative distances (highest confidence is 0.0, lowest condidence is one).

  • rfernandezLabelSpace (bool, optional) - Returned labels are compatible with the rest of the tools (background label is 1).

Returns :Mapping of mother to candidate children with a score (or a distance) for each child.
Returns Type:dict
rfernandez_get_candidate_successors(imgSeg1, imgSeg2, distance, ndiv, bkgdLabel, as_scores=True, rfernandezLabelSpace=False)[source]

Estimates candidate lineages between cells in imgSeg1 and cells in imgSeg2.

This method uses the original implementation from Romain Fernandez. Images most be 3D (even if only one pixel wide in Z) and in ushort.

Parameters:
  • imgSeg1 (openalea.image.SpatialImage) - segmented image representing the parent cells (encoded in ushorts).

  • imgSeg2 (openalea.image.SpatialImage) - segmented image representing the daugther cells (encoded in ushorts).

  • distance (float) - distance between mother boundary and child barycenter beyond which child is discarded.

  • ndiv (int) - number of divisions between two images.

  • bkgdLabel (int) - label to consider as the background.

  • as_scores (bool, optional) - if True, the returned mapping contains scores (highest confidence is 1.0,

    lowest confidence is 0.0) else the mapping contains relative distances (highest confidence is 0.0, lowest condidence is one).

  • rfernandezLabelSpace (bool, optional) - Returned labels are compatible with the rest of the tools (background label is 1).

Returns :Mapping of mother to candidate children with a score (or a distance) for each child.
Returns Type:dict

vplants.mars_alt.alt.flow_graph

flow_graph(maxLabel0, maxLabel1, candidates=None, expert_lineage=None, ndiv=8, flow_method='rf_flow')[source]

Given two images of an organ at t0 and t1, tries to find cell lineages.

Careful: Image labels are expected to start from 2 (1 being the background)

Parameters :
  • maxLabel0 (int) - the highest label for mothers

  • maxLabel1 (int) - the highest label for children

  • candidates (dict) - a dictionnary mapping mother labels to a list of child labels+scores. Labels should start at 2, 1 being the background.

  • expert_lineage (dict) - a dictionnary mapping mother labels to a list of child labels. Labels should start at 2, 1 being the background.

  • ndiv : an limit to the number of divisions a cell can have between the two images

  • flow_method : name of the flow graph solving. “rf_flow” is the original published implementation by Romain Fernandez.

    “nx_simplex” is the simplex method provided by networkx.

Returns :

A dictionnary mapping mothers to children.

merge_expert_and_candidates(expert, candidates)[source]

Merges an expert lineaging and a candidate lineaging into one candidate lineaging.

nx_flow_solving(ndiv, candidates, maxLabel0, maxLabel1)[source]

Build and solve lineage flow graph from candidates lineage.

Careful: Image labels are expected to start from 2 (1 being the background)

We use networkX’ simplex graph solver.

Here are the rules to build the graph:
  • one source node, one sink node
  • one virtual mother node to connect cells in t1 that have no mom in t0
  • one virtual child node to connect cells in t0 that have no child in t1
  • a set of real mothers, each of them receiving flow from source node
  • a set of real children, each of them receiving flow from one real mother node and sending flow to sink
  • sink sends back flow to source
The flow bounds (min&max capacities) are:
  • mother->candidate child : 0 <= flow <= 1
  • source->real mothers : 1 <= flow <= ndivmax (ndiv)
  • source->virt mother : 0 <= flow <= count(real children) aka Nj
  • real child->sink : flow == 1
  • virt child->sink : 0 <= flow <= count(real mothers) aka Ni
  • sink -> source : max(Nj,Ni) <= flow <= Nj + Ni
The flow costs are:
  • mother->candidate child : cost=1-Score(Mother->Child)
  • mom/child->virtual : cost=2

NOTE: minimal capacities are represented by equal demands on the node after the edge.

Parameters :
  • ndiv (int) : a limit to the number of divisions a cell can have between two images.

  • candidates (dict) : a mapping of mothers-to-children-and-score as returned by

    vplants.mars_alt.alt.candidate_lineaging.candidate_lineaging.

  • maxLabel0 (int) : the highest label for mothers

  • maxLabel1 (int) : the highest label for children

  • nMothers (int - to be discarded) : number of mothers (can be inferred from maxLabel0).

  • nChildren (int - to be discarded) : number of children (can be inferred from maxLabel1).

Returns :

A dictionnary mapping mothers to children.

rfernandez_flow_solving(ndiv, candidates, maxLabel0, maxLabel1)[source]

Build and solve lineage flow graph from candidates lineage.

Look at the Nature Methods paper <http://www-sop.inria.fr/asclepios/biblio/REP/publi.php?name=Author/FERNANDEZ-R.html> for details concerning this implementation.

Careful: Image labels are expected to start from 2 (1 being the background)

Parameters :
  • ndiv (int) : a limit to the number of divisions a cell can have between two images.

  • candidates (dict) : a mapping of mothers-to-children-and-score as returned by

    vplants.mars_alt.alt.candidate_lineaging.candidate_lineaging.

  • maxLabel0 (int) : the highest label for mothers

  • maxLabel1 (int) : the highest label for children

  • nMothers (int - to be discarded) : number of mothers (can be inferred from maxLabel0).

  • nChildren (int - to be discarded) : number of children (can be inferred from maxLabel1).

Returns :

A dictionnary mapping mothers to children.