navigate.controller.controller.Controller
- class navigate.controller.controller.Controller(root, splash_screen, configuration_path, experiment_path, waveform_constants_path, rest_api_path, waveform_templates_path, gui_configuration_path, multi_positions_path, args)
Bases:
object
Navigate Controller
- __init__(root, splash_screen, configuration_path, experiment_path, waveform_constants_path, rest_api_path, waveform_templates_path, gui_configuration_path, multi_positions_path, args)
Initialize the Navigate Controller.
- Parameters:
root (Tk top-level widget.) – Tk.tk GUI instance.
splash_screen (Tk top-level widget.) – Tk.tk GUI instance.
configuration_path (string) – Path to the configuration yaml file. Provides global microscope configuration parameters.
experiment_path (string) – Path to the experiment yaml file. Provides experiment-specific microscope configuration.
waveform_constants_path (string) – Path to the waveform constants yaml file. Provides magnification and wavelength-specific parameters.
rest_api_path (string) – Path to the REST API yaml file. Provides REST API configuration parameters.
waveform_templates_path (string) – Path to the waveform templates yaml file. Provides waveform templates for each channel.
gui_configuration_path (string) – Path to the GUI configuration yaml file. Provides GUI configuration parameters.
*args – Command line input arguments for non-default file paths or using synthetic hardware modes.
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.
execute
(command, *args)Functions listens to the Sub_Gui_Controllers.
Populate view and maximum intensity projection tabs.
Launch additional microscopes.
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.
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.
Update the acquire control based on the current experiment parameters.
Update the buffer size according to the camera dimensions listed in the experimental parameters.
Update the View/Controller based on events from the Model.
Update model.experiment according to values in the GUI
update_stage_controller_silent
(ret_pos_dict)Send updates to the stage GUI
Attributes
Tk.tk GUI instance.
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
Model object in MVC architecture.
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, acquisition_obj)
Add and Acquisition Mode.
- Parameters:
name (string) – Name of the acquisition mode.
acquisition_obj (object) – Object of the acquisition mode.
- capture_image(command, mode, *args)
Trigger the model to capture images.
- Parameters:
command (string) – ‘acquire’ or ‘autofocus’
mode (string) – ‘continuous’, ‘z-stack’, ‘single’, or ‘projection’
args (function-specific passes.) –
- change_microscope(microscope_name, zoom=None)
Change the microscope configuration.
- Parameters:
microscope_name (string) – Name of the microscope to change to.
zoom (string) – Name of the zoom value to change to.
- destroy_virtual_microscope(microscope_name, destroy_window=True)
Destroy virtual microscopes.
- Parameters:
microscope_name (str) – The microscope name
destroy_window (bool) – The flag to dismiss window.
- execute(command, *args)
Functions listens to the Sub_Gui_Controllers.
The controller.experiment is passed as an argument to the model, which then overwrites the model.experiment. Workaround due to model being in a sub-process.
- Parameters:
command (string) – The string includes ‘stage’, ‘stop_stage’, ‘move_stage_and_update_info’,
args* (Iterable.) – Function-specific passes
- initialize_cam_view()
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.
- launch_additional_microscopes()
Launch additional microscopes.
- move_stage(pos_dict)
Trigger the model to move the stage.
- Parameters:
pos_dict (dict) – Dictionary of axis positions
- populate_experiment_setting(file_name=None, in_initialize=False)
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 (string) – file_name = path to the non-default experiment yaml file.
- prepare_acquire_data()
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
- register_event_listener(event_name, event_handler)
Register an event listener.
- Parameters:
event_name (string) – Name of the event.
event_handler (callable) – The function to handle the event.
- register_event_listeners(events)
Register multiple event listeners.
- Parameters:
events (dict) – Dictionary of event names and handlers.
- resize(event)
Resize the GUI.
- Parameters:
event (event) – event = <Configure x=0 y=0 width=1200 height=600>
- set_mode_of_sub(mode)
Communicates imaging mode to sub-controllers.
- Parameters:
mode (str) – The string = ‘live’, ‘stop’
- sloppy_stop()
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.
- stop_stage()
Stop the stage.
Grab the stopped position from the stage and update the GUI control values accordingly.
- update_acquire_control()
Update the acquire control based on the current experiment parameters.
- update_buffer()
Update the buffer size according to the camera dimensions listed in the experimental parameters.
- Returns:
self.img_width (int) – Number of x_pixels from microscope configuration file.
self.image_height (int) – Number of y_pixels from microscope configuration file.
self.data_buffer (SharedNDArray) – Pre-allocated shared memory array. Size dictated by x_pixels, y_pixels, an number_of_frames in configuration file.
- update_event()
Update the View/Controller based on events from the Model.
- update_experiment_setting()
Update model.experiment according to values in the GUI
Collect settings from sub-controllers will validate the value, if something is wrong, it will return False
- Returns:
Warning info if any
- Return type:
string
- update_stage_controller_silent(ret_pos_dict)
Send updates to the stage GUI
- Parameters:
ret_pos_dict (dict) – Dictionary of axis positions
- 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
- model
Model object in MVC architecture.
- Type:
- 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
- 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