motile_plugin.data_model.actions
This module contains all the low level actions used to control a Tracks object. Low level actions should control these aspects of Tracks:
synchronizing segmentation and nodes (including bi-directional access). Currently,
this means updating the seg_id and time attributes on the node, and updating the seg_time_to_node dictionary. - Updating attributes that are controlled by the segmentation. Currently, position and area for nodes, and IOU for edges. - Keeping track of information needed to undo the given action. For removing a node, this means keeping track of the incident edges that were removed, along with their attributes.
The low level actions do not contain application logic, such as manipulating track ids, or validation of “allowed” actions. The actions should work on candidate graphs as well as solution graphs. Action groups can be constructed to represent application-level actions constructed from many low-level actions.
Classes
Action for adding new nodes. If a segmentation should also be added, the |
|
Action of deleting existing nodes |
|
Action for updating the segmentation associated with nodes |
|
Action for updating the segmentation associated with nodes |
|
Action for adding new edges |
|
Action for deleting edges |
|
Module Contents
- class motile_plugin.data_model.actions.TracksAction(tracks: motile_plugin.data_model.tracks.Tracks)
- tracks
- abstract inverse() TracksAction
Get the inverse action of this action. Can be used to undo and redo an action.
- Raises:
NotImplementedError: if the inverse is not implemented in the subclass
- Returns:
- TracksAction: An action that un-does this action, bringing the tracks
back to the exact state it had before applying this action.
- class motile_plugin.data_model.actions.ActionGroup(tracks: motile_plugin.data_model.tracks.Tracks, actions: list[TracksAction])
Bases:
TracksAction
- actions
- inverse() ActionGroup
Get the inverse action of this action. Can be used to undo and redo an action.
- Raises:
NotImplementedError: if the inverse is not implemented in the subclass
- Returns:
- TracksAction: An action that un-does this action, bringing the tracks
back to the exact state it had before applying this action.
- class motile_plugin.data_model.actions.AddNodes(tracks: motile_plugin.data_model.tracks.Tracks, nodes: list[motile_plugin.data_model.tracks.Node], attributes: dict[str, list[Any]], pixels: list[motile_plugin.data_model.tracks.SegMask] | None = None)
Bases:
TracksAction
Action for adding new nodes. If a segmentation should also be added, the pixels for each node should be provided. The label to set the pixels will be taken from the seg_id attribute. The existing pixel values are assumed to be zero - you must explicitly update any other segmentations that were overwritten using an UpdateNodes action if you want to be able to undo the action.
- nodes
- times
- positions
- seg_ids
- pixels
- attributes
- inverse()
Invert the action to delete nodes instead
- _apply()
Apply the action, and set segmentation if provided in self.pixels
- class motile_plugin.data_model.actions.DeleteNodes(tracks: motile_plugin.data_model.tracks.Tracks, nodes: list[motile_plugin.data_model.tracks.Node], pixels: list[motile_plugin.data_model.tracks.SegMask] | None = None)
Bases:
TracksAction
Action of deleting existing nodes If the tracks contain a segmentation, this action also constructs a reversible operation for setting involved pixels to zero
- nodes
- attributes
- pixels
- inverse()
Invert this action, and provide inverse segmentation operation if given
- _apply()
ASSUMES THERE ARE NO INCIDENT EDGES - raises valueerror if an edge will be removed by this operation Steps: - For each node
set pixels to 0 if self.pixels is provided
Remove nodes from graph
- class motile_plugin.data_model.actions.UpdateNodeSegs(tracks: motile_plugin.data_model.tracks.Tracks, nodes: list[motile_plugin.data_model.tracks.Node], pixels: list[motile_plugin.data_model.tracks.SegMask], added: bool = True)
Bases:
TracksAction
Action for updating the segmentation associated with nodes
- nodes
- pixels
- added
- inverse()
Restore previous attributes
- _apply()
Set new attributes
- class motile_plugin.data_model.actions.UpdateNodeAttrs(tracks: motile_plugin.data_model.tracks.Tracks, nodes: list[motile_plugin.data_model.tracks.Node], attrs: motile_plugin.data_model.tracks.Attrs)
Bases:
TracksAction
Action for updating the segmentation associated with nodes
- nodes
- prev_attrs
- new_attrs
- inverse()
Restore previous attributes
- _apply()
Set new attributes
- class motile_plugin.data_model.actions.AddEdges(tracks: motile_plugin.data_model.tracks.Tracks, edges: list[motile_plugin.data_model.tracks.Edge])
Bases:
TracksAction
Action for adding new edges
- edges
- inverse()
Delete edges
- _apply()
Steps: - add each edge to the graph. Assumes all edges are valid (they should be checked at this point already)
- class motile_plugin.data_model.actions.DeleteEdges(tracks: motile_plugin.data_model.tracks.Tracks, edges: list[motile_plugin.data_model.tracks.Edge])
Bases:
TracksAction
Action for deleting edges
- edges
- inverse()
Restore edges and their attributes
- _apply()
Steps: - Remove the edges from the graph
- class motile_plugin.data_model.actions.UpdateTrackID(tracks: motile_plugin.data_model.solution_tracks.SolutionTracks, start_node: motile_plugin.data_model.tracks.Node, track_id: int)
Bases:
TracksAction
- start_node
- old_track_id
- new_track_id
- inverse() TracksAction
Restore the previous track_id
- _apply()
Assign a new track id to the track starting with start_node. Will also update the self.tracks.segmentation array and seg_id on the self.tracks.graph if a segmentation exists.