organoid_tracker.visualizer package

Submodules

Module contents

OrganoidTracker is centered around a Matplotlib window, and that window is controlled here.

Each screen in OrganoidTracker inherits from the Visualizer class, which just shows an empty Matplotlib plot. The subclasses show more interesting behaviour, like AbstractImageVisualizer which shows an image from your time-lapse movie, with the positions and links drawn on top.

If you want to create your own screeen, I would recommend that you create a subclass from ExitableImageVisualzer:

>>> from organoid_tracker.visualizer.exitable_image_visualizer import ExitableImageVisualizer
>>> class YourVisualizer(ExitableImageVisualizer):
>>>     def get_extra_menu_options(self) -> Dict[str, Any]:
>>>         return { "My menu//Some option": self._clicked_my_menu_option }
>>>
>>>     def _clicked_my_menu_option(self):
>>>         self.update_status("Clicked on my menu option!")
>>>
>>>     def _on_position_draw(self, position: Position, color: str, dz: int, dt: int) -> bool:
>>>         if dt == 0 and dz == 0:
>>>             self._ax.text(position.x, position.y, "Some text")  # Draws some text at the positions
>>>         return True  # Change this to False to no longer draw the original marker
class organoid_tracker.visualizer.Visualizer(window: Window)

Bases: object

A complete application for visualization of an experiment

attach()

Attaches all event handlers.

detach()

Detaches the event handlers.

draw_view()

Draws the view.

static get_closest_position(positions: Iterable[Position], x: Optional[int], y: Optional[int], z: Optional[int], time_point: Optional[TimePoint], max_distance: int = 100000)

Gets the position closest ot the given position. If z is missing, it is ignored. If x or y are missing, None is returned.

get_default_status() str

Gets the status normally used when moving between time points or between different visualizers. Use update_status to set a special status.

get_extra_menu_options() Dict[str, Any]
get_window() Window
reconstruct_image(time_point: TimePoint, z: int, rgb_canvas_2d: ndarray)

Draws all positions and shapes to the given canvas. The canvas must be a float array, and will be clipped from 0 to 1.

Only called if self._should_show_image_reconstruction returns True.

reconstruct_image_3d(time_point: TimePoint, rgb_canvas_3d: ndarray)

Draws all positions and shapes to the given canvas. The canvas must be a float array, and will be clipped from 0 to 1.

refresh_all()

Redraws the view after loading the images.

refresh_data()

Redraws the view.

run_async(runnable: Callable[[], Any], result_handler: Callable[[Any], None])

Creates a callable that runs the given runnable on a worker thread.

should_show_image_reconstruction() bool

If overridden, the reconstruct_image and reconstruct_image_3d can be called.

update_status(text: Union[str, bytes], redraw=True)

Updates the status of the window.

organoid_tracker.visualizer.activate(visualizer: Visualizer) None