motile_tracker.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:
adding/removing nodes and edges to/from the segmentation and graph
Updating the segmentation and graph 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. Cannot mix adding |
|
Action for user updates to node attributes. Cannot update protected |
|
Action for adding new edges |
|
Action for deleting edges |
|
Module Contents
- class motile_tracker.data_model.actions.TracksAction(tracks: motile_tracker.data_model.tracks.Tracks)
- tracks
- abstract inverse() TracksAction
Get the inverse of this action. Calling this function does undo the action, since the change is applied in the action constructor.
- 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_tracker.data_model.actions.ActionGroup(tracks: motile_tracker.data_model.tracks.Tracks, actions: list[TracksAction])
Bases:
TracksAction
- actions
- inverse() ActionGroup
Get the inverse of this action. Calling this function does undo the action, since the change is applied in the action constructor.
- 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_tracker.data_model.actions.AddNodes(tracks: motile_tracker.data_model.tracks.Tracks, nodes: list[motile_tracker.data_model.tracks.Node], attributes: motile_tracker.data_model.tracks.Attrs, pixels: list[motile_tracker.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 node id. 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
- pixels = None
- attributes
- inverse()
Invert the action to delete nodes instead
- _apply()
Apply the action, and set segmentation if provided in self.pixels
- class motile_tracker.data_model.actions.DeleteNodes(tracks: motile_tracker.data_model.tracks.Tracks, nodes: list[motile_tracker.data_model.tracks.Node], pixels: list[motile_tracker.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_tracker.data_model.actions.UpdateNodeSegs(tracks: motile_tracker.data_model.tracks.Tracks, nodes: list[motile_tracker.data_model.tracks.Node], pixels: list[motile_tracker.data_model.tracks.SegMask], added: bool = True)
Bases:
TracksAction
Action for updating the segmentation associated with nodes. Cannot mix adding and removing pixels from segmentation: the added flag applies to all nodes
- nodes
- pixels
- added = True
- inverse()
Restore previous attributes
- _apply()
Set new attributes
- class motile_tracker.data_model.actions.UpdateNodeAttrs(tracks: motile_tracker.data_model.tracks.Tracks, nodes: list[motile_tracker.data_model.tracks.Node], attrs: motile_tracker.data_model.tracks.Attrs)
Bases:
TracksAction
Action for user updates to node attributes. Cannot update protected attributes (time, area, track id), as these are controlled by internal application logic.
- nodes
- prev_attrs
- new_attrs
- inverse()
Restore previous attributes
- _apply()
Set new attributes
- class motile_tracker.data_model.actions.AddEdges(tracks: motile_tracker.data_model.tracks.Tracks, edges: list[motile_tracker.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_tracker.data_model.actions.DeleteEdges(tracks: motile_tracker.data_model.tracks.Tracks, edges: list[motile_tracker.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_tracker.data_model.actions.UpdateTrackID(tracks: motile_tracker.data_model.solution_tracks.SolutionTracks, start_node: motile_tracker.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.