navigate.controller.controller.Controller
- class navigate.controller.controller.Controller(root: tkinter.Tk, splash_screen: tkinter.Toplevel, configuration_path: str | os.PathLike[str], experiment_path: str | os.PathLike[str], waveform_constants_path: str | os.PathLike[str], rest_api_path: str | os.PathLike[str], waveform_templates_path: str | os.PathLike[str], gui_configuration_path: str | os.PathLike[str], multi_positions_path: str | os.PathLike[str], log_queue: mp.Queue | None, args: Any)
Bases:
objectNavigate Controller
- __init__(root: tkinter.Tk, splash_screen: tkinter.Toplevel, configuration_path: str | os.PathLike[str], experiment_path: str | os.PathLike[str], waveform_constants_path: str | os.PathLike[str], rest_api_path: str | os.PathLike[str], waveform_templates_path: str | os.PathLike[str], gui_configuration_path: str | os.PathLike[str], multi_positions_path: str | os.PathLike[str], log_queue: mp.Queue | None, args: Any) → None
Initialize the Navigate Controller.
- Parameters:
root (tkinter.Tk) – Tk root window.
splash_screen (tkinter.Toplevel) – Splash window shown before the main window is initialized.
configuration_path (str | os.PathLike[str]) – Path to the global configuration YAML file.
experiment_path (str | os.PathLike[str]) – Path to the experiment YAML file.
waveform_constants_path (str | os.PathLike[str]) – Path to the waveform constants YAML file.
rest_api_path (str | os.PathLike[str]) – Path to the REST API configuration YAML file.
waveform_templates_path (str | os.PathLike[str]) – Path to the waveform templates YAML file.
gui_configuration_path (str | os.PathLike[str]) – Path to the GUI configuration YAML file.
multi_positions_path (str | os.PathLike[str]) – Path to the multi-position YAML file.
log_queue (multiprocessing.Queue | None) – Queue used for cross-process logging.
args (Any) – Command-line arguments used for runtime options.
- Return type:
None
Methods
__init__(root, splash_screen, ...)Initialize the Navigate Controller.
add_acquisition_mode(name, acquisition_obj)Add and Acquisition Mode.
capture_image(command, mode, *args)Trigger the model to capture images.
change_microscope(microscope_name[, zoom])Change the microscope configuration.
destroy_virtual_microscope(microscope_name)Destroy virtual microscopes.
Enable window resize handling.
execute(command, *args)Handle controller commands from sub-controllers and UI callbacks.
Populate view and maximum intensity projection tabs.
Launch and wire up auxiliary microscope display windows.
move_stage(pos_dict)Trigger the model to move the stage.
populate_experiment_setting([file_name, ...])Load experiment file and populate model.experiment and configure view.
Prepare the acquisition data.
query_select_microscope(microscope_name)Query a specific microscope for its current stage positions.
register_event_listener(event_name, ...)Register an event listener.
register_event_listeners(events)Register multiple event listeners.
resize(event)Resize the GUI.
set_mode_of_sub(mode)Communicates imaging mode to sub-controllers.
Keep trying to stop the model until successful.
Stop the stage.
Bind Acquire Bar controls to the current stage control handlers.
Update the shared image buffer for the active camera geometry.
Update the View/Controller based on events from the Model.
Update experiment settings from GUI state.
update_frame_rate(frame_rate)Update the frame rate display in the GUI.
update_stage_controller_silent(ret_pos_dict)Send updates to the stage GUI
update_stage_limits(microscope_name)Update stage limits on the device side
Check if the model uses ASI hardware.
Attributes
Tk.tk GUI instance.
Flag to indicate if the GUI is ready for resizing.
Tk.tk GUI instance.
Path to the configuration yaml file.
Path to the experiment yaml file.
Path to the waveform constants yaml file.
Path to the REST API yaml file.
Path to the waveform templates yaml file.
Path to the GUI configuration yaml file.
Non-default command line input arguments for
Thread pool for the controller.
Queue for retrieving events ('event_name', value) from model
A shared memory manager
Configuration dictionary
Pipe for sending images from model to view.
Path to the default experiment yaml file.
Configuration Controller object.
View object in MVC architecture.
Event listeners for the controller.
Acquire Bar Sub-Controller.
Channels Tab Sub-Controller.
Multi-Position Tab Sub-Controller.
Camera View Tab Sub-Controller.
MIP Settings Tab Sub-Controller.
Camera Settings Tab Sub-Controller.
Stage Sub-Controller.
Waveform Display Sub-Controller.
Keystroke Sub-Controller.
Menu Sub-Controller.
acquisition modes from plugins
Plugin Sub-Controller
Number of x_pixels from microscope configuration file.
Number of y_pixels from microscope configuration file.
Pre-allocated shared memory array.
Additional microscopes.
Additional microscope configurations.
Flag for stopping acquisition.
current image id in the buffer
ID for the resize event.Only works on Windows OS.
- add_acquisition_mode(name: str, acquisition_obj: Callable[[str], Any]) → None
Add and Acquisition Mode.
- Parameters:
name (str) – Name of the acquisition mode.
acquisition_obj (Callable[[str], Any]) – Factory or class that produces an acquisition mode object.
- Return type:
None
- capture_image(command: str, mode: str, *args: Any) → None
Trigger the model to capture images.
- Parameters:
command (str) – Capture command passed to the model (for example
"acquire").mode (str) – Acquisition mode (for example
"continuous"or"single").*args (Any) – Command-specific positional arguments.
- Return type:
None
- change_microscope(microscope_name: str, zoom: str | None = None) → None
Change the microscope configuration.
- Parameters:
microscope_name (str) – Name of the microscope to switch to.
zoom (str | None, optional) – Zoom value to set for the microscope. If
None, keep current zoom.
- Return type:
None
- destroy_virtual_microscope(microscope_name: str, destroy_window: bool = True) → None
Destroy virtual microscopes.
- Parameters:
microscope_name (str) – The microscope name
destroy_window (bool) – The flag to dismiss window.
- Return type:
None
- enable_resize() → None
Enable window resize handling.
- Return type:
None
- execute(command: str, *args: Any) → Any
Handle controller commands from sub-controllers and UI callbacks.
The controller configuration is synchronized with model state and commands are dispatched to worker threads or executed locally based on command type.
- Parameters:
command (str) – Command name routed to controller/model operations.
*args (Any) – Command-specific positional arguments.
- Returns:
Command-dependent return value. Most commands return
None; some, such as"get_stage_position", return structured data.- Return type:
Any
- initialize_cam_view() → None
Populate view and maximum intensity projection tabs.
Communicates with the camera view controller and mip setting controller to set the minimum and maximum counts, as well as the default channel settings.
- Return type:
None
- launch_additional_microscopes() → None
Launch and wire up auxiliary microscope display windows.
- Return type:
None
- move_stage(pos_dict: dict[str, Any]) → None
Trigger the model to move the stage.
- Parameters:
pos_dict (dict[str, Any]) – Dictionary of axis positions
- Return type:
None
- populate_experiment_setting(file_name: str | os.PathLike[str] | None = None, in_initialize: bool = False) → None
Load experiment file and populate model.experiment and configure view.
Confirms that the experiment file exists. Sends the experiment file to the model and the controller. Populates the GUI with these settings.
- Parameters:
file_name (str | os.PathLike[str] | None, optional) – Path to a non-default experiment YAML file to load.
in_initialize (bool, optional) –
Truewhen called during controller initialization to skip reloading experiment YAML from disk.
- Return type:
None
- prepare_acquire_data() → bool
Prepare the acquisition data.
Updates model.experiment. Sets sub-controller’s mode to ‘live’ when ‘continuous is selected, or ‘stop’.
- Returns:
True if all settings are valid, False otherwise.
- Return type:
bool
- query_select_microscope(microscope_name: str) → None
Query a specific microscope for its current stage positions.
- Parameters:
microscope_name (str) – Microscope name to query from the model.
- Return type:
None
- register_event_listener(event_name: str, event_handler: Callable[[Any], None]) → None
Register an event listener.
- Parameters:
event_name (str) – Name of the event.
event_handler (Callable[[Any], None]) – The function to handle the event.
- Return type:
None
- register_event_listeners(events: dict[str, Callable[[Any], NoneType]]) → None
Register multiple event listeners.
- Parameters:
events (dict[str, Callable[[Any], None]]) – Dictionary of event names and handlers.
- Return type:
None
- resize(event: Event) → None
Resize the GUI.
- Parameters:
event (tkinter.Event) – Tk
<Configure>event emitted during window size changes.- Return type:
None
- set_mode_of_sub(mode: str) → None
Communicates imaging mode to sub-controllers.
- Parameters:
mode (str) – Imaging mode such as
"live"or"stop".- Return type:
None
- sloppy_stop() → None
Keep trying to stop the model until successful.
TODO: Delete this function!!!
This is set up to get around the conflict between self.threads_pool.createThread(‘model’, target) commands and the need to stop as abruptly as possible when the user hits stop. Here we leverage ObjectInSubprocess’ refusal to let us access the model from two threads to our advantage, and just try repeatedly until we get a command in front of the next command in the model threads_pool resource. We should instead pause the model thread pool and interject our stop command, or clear the queue in threads_pool.
- Return type:
None
- stop_stage() → None
Stop the stage.
Grab the stopped position from the stage and update the GUI control values accordingly.
- Return type:
None
- update_acquire_control() → None
Bind Acquire Bar controls to the current stage control handlers.
- Return type:
None
- update_buffer() → None
Update the shared image buffer for the active camera geometry.
- Return type:
None
- update_event() → None
Update the View/Controller based on events from the Model.
This method runs on the Tk thread and drains all pending model events.
- Return type:
None
- update_experiment_setting() → str
Update experiment settings from GUI state.
Collect settings from sub-controllers, validate values, and synchronize configuration data used by model commands.
- Returns:
Concatenated warning message if validation fails, otherwise an empty string.
- Return type:
str
- update_frame_rate(frame_rate: float) → None
Update the frame rate display in the GUI.
Updates the frame rate in the camera settings tab and the acquire bar controller. This method receives the accurate frame rate calculated from the model’s run_data_process method.
- Parameters:
frame_rate (float) – The frame rate in frames per second (Hz).
- Return type:
None
- update_stage_controller_silent(ret_pos_dict: dict[str, Any]) → None
Send updates to the stage GUI
- Parameters:
ret_pos_dict (dict[str, Any]) – Dictionary of axis positions
- Return type:
None
- update_stage_limits(microscope_name: str) → None
Update stage limits on the device side
- Parameters:
microscope_name (str) – Microscope name.
- Return type:
None
- use_asi_model() → bool
Check if the model uses ASI hardware.
- Returns:
True if the model uses ASI hardware, False if it uses NI hardware.
- Return type:
bool
- Raises:
ValueError – If the DAQ type is unknown.
- acquire_bar_controller
Acquire Bar Sub-Controller.
- Type:
- additional_microscopes
Additional microscopes.
- Type:
dict
- additional_microscopes_configs
Additional microscope configurations.
- Type:
dict
- args
Non-default command line input arguments for
- Type:
iterable
- camera_setting_controller
Camera Settings Tab Sub-Controller.
- Type:
- camera_view_controller
Camera View Tab Sub-Controller.
- Type:
- channels_tab_controller
Channels Tab Sub-Controller.
- Type:
- configuration
Configuration dictionary
- Type:
dict
- configuration_controller
Configuration Controller object.
- Type:
- configuration_path
Path to the configuration yaml file.
- Type:
string
- current_image_id
current image id in the buffer
- Type:
int
- data_buffer
Pre-allocated shared memory array.
- Type:
- default_experiment_file
Path to the default experiment yaml file.
- Type:
string
- event_listeners
Event listeners for the controller.
- Type:
dict
- event_queue
Queue for retrieving events (‘event_name’, value) from model
- Type:
mp.Queue
- experiment_path
Path to the experiment yaml file.
- Type:
string
- gui_configuration_path
Path to the GUI configuration yaml file.
- Type:
string
- img_height
Number of y_pixels from microscope configuration file.
- Type:
int
- img_width
Number of x_pixels from microscope configuration file.
- Type:
int
- keystroke_controller
Keystroke Sub-Controller.
- Type:
- manager
A shared memory manager
- Type:
Manager
- menu_controller
Menu Sub-Controller.
- Type:
- mip_setting_controller
MIP Settings Tab Sub-Controller.
- Type:
MIPSettingController
- multiposition_tab_controller
Multi-Position Tab Sub-Controller.
- Type:
- plugin_acquisition_modes
acquisition modes from plugins
- Type:
dict
- plugin_controller
Plugin Sub-Controller
- Type:
- resize_event_id
ID for the resize event.Only works on Windows OS.
- Type:
int
- resize_ready_flag
Flag to indicate if the GUI is ready for resizing.
- Type:
bool
- rest_api_path
Path to the REST API yaml file.
- Type:
string
- root
Tk.tk GUI instance.
- Type:
Tk top-level widget
- show_img_pipe
Pipe for sending images from model to view.
- Type:
mp.Pipe
- splash_screen
Tk.tk GUI instance.
- Type:
Tk top-level widget
- stage_controller
Stage Sub-Controller.
- Type:
- stop_acquisition_flag
Flag for stopping acquisition.
- Type:
bool
- threads_pool
Thread pool for the controller.
- Type:
Object
- view
View object in MVC architecture.
- Type:
View
- waveform_constants_path
Path to the waveform constants yaml file.
- Type:
string
- waveform_tab_controller
Waveform Display Sub-Controller.
- Type:
- waveform_templates_path
Path to the waveform templates yaml file.
- Type:
string