motile_plugin.widgets

Subpackages

Classes

MotileWidget

A widget that controls the backend components of the motile napari plugin.

TreeWidget

pyqtgraph-based widget for lineage tree visualization and navigation

TracksViewer

Purposes of the TracksViewer:

Package Contents

class motile_plugin.widgets.MotileWidget(viewer: napari.Viewer)

Bases: qtpy.QtWidgets.QScrollArea

A widget that controls the backend components of the motile napari plugin. Recieves user input about solver parameters, runs motile, and passes results to the TrackingViewController.

solver_update
view_tracks
remove_layers
viewer: napari.Viewer
tracks_viewer
edit_run_widget
view_run_widget
run_list_widget
main_layout
main_widget
view_run(run: motile_plugin.backend.motile_run.MotileRun) None

Populates the run viewer and the napari layers with the output of the provided run.

Args:

run (MotileRun): The run to view

edit_run(run: motile_plugin.backend.motile_run.MotileRun | None)

Create or edit a new run in the run editor. Also removes solution layers from the napari viewer. Args:

run (MotileRun | None): Initialize the new run with the parameters and name

from this run. If not provided, uses the SolverParams default values.

_generate_tracks(run: motile_plugin.backend.motile_run.MotileRun) None

Called when we start solving a new run. Switches from run editor to run viewer and starts solving of the new run in a separate thread to avoid blocking

Args:

run (MotileRun): Start solving this motile run.

solve_with_motile(run: motile_plugin.backend.motile_run.MotileRun) motile_plugin.backend.motile_run.MotileRun

Runs the solver and relabels the segmentation to match the solution graph. Emits: self.solver_event when the solver provides an update (will be emitted from the thread, which is why it needs to be an event and not just a normal function callback)

Args:
run (MotileRun): A run with name, parameters, and input segmentation,

but not including the output graph or segmentation.

Returns:

MotileRun: The provided run with the output graph and segmentation included.

_on_solver_event(run: motile_plugin.backend.motile_run.MotileRun, event_data: dict) None

Parse the solver event and set the run status and gap accordingly. Also emits a solver_update event to tell the run viewer to update. Note: This will simply tell the run viewer to refresh its plot and status. If the run viewer is not viewing this run, it will refresh anyways, which is pointless but not harmful.

Args:

run (MotileRun): The run that the solver is working on event_data (dict): The solver event data from ilpy.EventData

_on_solve_complete(run: motile_plugin.backend.motile_run.MotileRun) None

Called when the solver thread returns. Updates the run status to done and tells the run viewer to update.

Args:

run (MotileRun): The completed run

_title_widget() qtpy.QtWidgets.QWidget

Create the title and intro paragraph widget, with links to docs

Returns:

QWidget: A widget introducing the motile plugin and linking to docs

class motile_plugin.widgets.TreeWidget(viewer: napari.Viewer)

Bases: qtpy.QtWidgets.QWidget

pyqtgraph-based widget for lineage tree visualization and navigation

track_df
lineage_df
graph = None
mode = 'all'
feature = 'tree'
view_direction = 'vertical'
tracks_viewer
selected_nodes
layout
tree_widget: TreePlot
mode_widget
feature_widget
navigation_widget
panel_layout
panel
keyPressEvent(event: qtpy.QtGui.QKeyEvent) None

Catch arrow key presses to navigate in the tree

Args:

event (QKeyEvent): The Qt Key event

keyReleaseEvent(ev)

Reset the mouse scrolling when releasing the X/Y key

_update_selected()

Called whenever the selection list is updated. Only re-computes the full graph information when the new selection is not in the lineage df (and in lineage mode)

_update_track_data() None

Called when the TracksViewer emits the tracks_updated signal, indicating that a new set of tracks should be viewed.

_set_mode(mode: str) None

Set the display mode to all or lineage view. Currently, linage view is always horizontal and all view is always vertical.

Args:

mode (str): The mode to set the view to. Options are “all” or “lineage”

_set_feature(feature: str) None

Set the feature mode to ‘tree’ or ‘area’. For this the view is always horizontal.

Args:

feature (str): The feature to plot. Options are “tree” or “area”

_update_lineage_df() None

Subset dataframe to include only nodes belonging to the current lineage

class motile_plugin.widgets.TracksViewer(viewer: napari.viewer)

Purposes of the TracksViewer: - Emit signals that all widgets should use to update selection or update

the currently displayed Tracks object

  • Storing the currently displayed tracks

  • Store shared rendering information like colormaps (or symbol maps)

  • Interacting with the napari.Viewer by adding and removing layers

tracks_updated
classmethod get_instance(viewer=None)
viewer
selected_nodes
tracking_layers
tracks = None
colormap
symbolmap: dict[motile_plugin.core.NodeType, str]
mode = 'all'
remove_napari_layer(layer: napari.layers.Layer | None) None

Remove a layer from the napari viewer, if present

remove_napari_layers() None

Remove all tracking layers from the viewer

add_napari_layers() None

Add new tracking layers to the viewer

view_external_tracks(tracks: motile_plugin.core.Tracks, name: str) None

View tracks created externally. Assigns tracklet ids, adds a hypothesis dimension to the segmentation, and relabels the segmentation based on the assigned track ids. Then calls update_tracks.

Args:

tracks (Tracks): A tracks object to view, created externally from the plugin name (str): The name to display in napari layers

update_tracks(tracks: motile_plugin.core.Tracks, name: str) None

Stop viewing a previous set of tracks and replace it with a new one. Will create new segmentation and tracks layers and add them to the viewer.

Args:

tracks (motile_plugin.core.Tracks): The tracks to visualize in napari. name (str): The name of the tracks to display in the layer names

toggle_display_mode(event=None) None

Toggle the display mode between available options

set_display_mode(mode: str) None

Update the display mode and call to update colormaps for points, labels, and tracks

Args:

mode (str): “all” or “lineage”

filter_visible_nodes() list[int]

Construct a list of track_ids that should be displayed

update_selection() None

Sets the view and triggers visualization updates in other components

set_napari_view() None

Adjust the current_step of the viewer to jump to the last item of the selected_nodes list