navigate.model.microscope.Microscope
- class navigate.model.microscope.Microscope(name: str, configuration: Dict[str, Any], devices_dict: dict, is_synthetic: bool = False, is_virtual: bool = False)
Bases:
object
Microscope Class - Used to control the microscope.
- __init__(name: str, configuration: Dict[str, Any], devices_dict: dict, is_synthetic: bool = False, is_virtual: bool = False) → None
Initialize the microscope.
- Parameters:
name (str) – Name of the microscope.
configuration (Dict[str, Any]) – Configuration dictionary.
devices_dict (dict) – Dictionary of devices.
is_synthetic (bool, optional) – Is synthetic, by default False
is_virtual (bool, optional) – Is virtual, by default False
Methods
__init__
(name, configuration, devices_dict)Initialize the microscope.
assemble_device_config_lists
(device_name, ...)Assemble device config lists.
Calculate all the waveforms.
Calculate the exposure and sweep times for all channels.
End the acquisition.
Get the available channels for imaging.
Get the exposure and sweep times for all channels.
Get stage position.
load_and_start_devices
(device_name, is_list, ...)Load and start devices.
move_remote_focus
([offset])Move remote focus.
move_stage
(pos_dict[, wait_until_done, ...])Move stage to a position.
move_stage_offset
([former_microscope])Move the stage to the offset position.
Prepare the acquisition.
prepare_next_channel
([update_daq_task_flag])Prepare the next channel.
Log the camera settings.
run_command
(command, *args)Run command.
set_camera_exposure_time
(channel)Set the camera exposure time.
Set the camera ROI.
Set the camera sensor mode.
Stop stage.
Close hardware explicitly.
Turn off current laser.
Turn on the current laser.
update_data_buffer
(data_buffer, number_of_frames)Update the data buffer for the camera.
update_stage_limits
([limits_flag])Update stage limits.
Attributes
Name of the microscope.
Output event queue.
Configuration dictionary.
Buffer for image data.
Dictionary of stages.
List of stages.
Ask stage for position.
Camera object.
Shutter device.
Dictionary of lasers.
Dictionary of galvanometers.
Remote focus device.
Dictionary of filter_wheels
Dictionary of data acquisition devices.
Dictionary of microscope info.
Current channel.
Current laser index.
List of all channels.
List of available channels.
Number of images.
Central focus position.
Is a synthetic microscope.
Dictionary of laser configurations.
Dictionary of returned stage positions.
Dictionary of commands
Dictionary of plugin devices
- assemble_device_config_lists(device_name: str, device_name_dict: dict) → tuple
Assemble device config lists.
- Parameters:
device_name (str) – Device name.
device_name_dict (dict) – Device name dictionary.
- Returns:
device_config_list (list) – Device configuration list.
device_name_list (list) – Device name list.
is_list (bool) – Is list.
- calculate_all_waveform() → dict
Calculate all the waveforms.
- Returns:
waveform – Dictionary of all the waveforms.
- Return type:
dict
- calculate_exposure_sweep_times() → tuple
Calculate the exposure and sweep times for all channels.
The calculate_exposure_sweep_times function calculates and returns exposure times and sweep times for all channels in a microscope configuration. It takes the camera’s readout time as an input parameter and considers various parameters such as camera exposure time, delay percentages, and smoothing to compute these times. The function iterates through the channels, performs calculations, and returns the results as dictionaries containing exposure times and sweep times for each channel.
- Returns:
exposure_times (dict) – Dictionary of exposure times.
sweep_times (dict) – Dictionary of sweep times.
- end_acquisition() → None
End the acquisition.
This function stops the acquisition, which includes stopping the data acquisition system, closing the camera image series, closing the shutter, turning off the lasers, and moving the stage to the central focus position if it was moved during the acquisition. It also stops the stage if it is moving.
- get_available_channels() → None
Get the available channels for imaging.
This function gets the available channels for imaging by identifying which channels are selected for imaging in the configuration file.
- get_exposure_sweep_times() → tuple
Get the exposure and sweep times for all channels.
- Returns:
exposure_times (dict) – Dictionary of exposure times.
sweep_times (dict) – Dictionary of sweep times.
- get_stage_position() → dict
Get stage position.
- Returns:
stage_position – Dictionary of stage positions.
- Return type:
dict
- load_and_start_devices(device_name: str, is_list: bool, device_name_list: list, device_ref_name: str, device_connection: Any, name: str, i: int, plugin_devices: dict) → None
Load and start devices.
Function uses importlib to import the device startup functions and then starts the devices. If it is a list, it will start the device at the index i. If it is a plugin, it will load the plugin device.
- Parameters:
device_name (str) – The name of the device.
is_list (bool) – Whether the device is a list of devices.
device_name_list (list) – The list of device names.
device_ref_name (str) – The reference name of the device.
device_connection (Any) – The communication instance of the device.
name (str) – The name of the microscope.
i (int) – Index.
plugin_devices (dict) – Plugin Devices
- move_remote_focus(offset: Optional[float] = None) → None
Move remote focus.
- Parameters:
offset (Optional[float], optional) – Offset, by default None
- move_stage(pos_dict: dict, wait_until_done: bool = False, update_focus: bool = True) → bool
Move stage to a position.
- Parameters:
pos_dict (dict) – Dictionary of stage positions.
wait_until_done (bool, optional) – Wait until stage is done moving, by default False
update_focus (bool, optional) – Update the central focus
- Returns:
success – True if stage is successfully moved, False otherwise.
- Return type:
bool
- move_stage_offset(former_microscope: Optional[str] = None) → None
Move the stage to the offset position.
- Parameters:
former_microscope (Optional[str], optional) – Name of the former microscope.
- prepare_acquisition() → dict
Prepare the acquisition.
This function prepares the acquisition by identifying which channels are selected for imaging, setting the camera region of interest (ROI), setting the camera sensor mode, setting the camera binning, initializing the image series, calculating all the waveforms required for the acquisition process, and opens the shutter.
- Returns:
waveform – Dictionary of all the waveforms.
- Return type:
dict
- prepare_next_channel(update_daq_task_flag: bool = True) → None
Prepare the next channel.
This function, prepare_next_channel, is responsible for configuring various hardware components for the next imaging channel in an experimental setup. It sequentially selects the next available channel, sets the filter wheel, camera exposure time, laser power, and other parameters based on the selected channel’s configuration. Additionally, it stops data acquisition, prepares the data acquisition system for the new channel, and adjusts the focus position as necessary, ensuring the hardware is ready for imaging the selected channel.
- Parameters:
update_daq_task_flag (bool) – whether to override waveforms in the DAQ (create new tasks)
- report_camera_settings() → None
Log the camera settings.
This function logs the camera settings for the current acquisition. It logs the camera parameters specified in the configuration file for the current microscope.
- run_command(command: str, *args) → None
Run command.
- Parameters:
command (str) – Command.
*args (list) – Variable input arguments.
- set_camera_exposure_time(channel: dict) → None
Set the camera exposure time.
This function prepares the camera for imaging by setting the camera exposure time based on the selected channel’s configuration. It also adjusts the camera line interval if the sensor mode is set to the Light-Sheet mode.
- Parameters:
channel (dict) – Dictionary of channel parameters.
- set_camera_roi() → None
Set the camera ROI.
This function sets the camera region of interest (ROI) based on the camera parameters specified in the configuration file. It sets the image width, image height, and the center of the image. The camera ROI is used to define the area of the image sensor that will be used to capture images during the acquisition process.
- set_camera_sensor_mode() → None
Set the camera sensor mode.
This function sets the camera sensor mode based on the camera parameters specified in the configuration file. It sets the sensor mode and the readout direction for the camera if it is in the light-sheet imaging mode.
- stop_stage() → None
Stop stage.
- terminate() → None
Close hardware explicitly.
Closes all devices other than plugin devices and deformable mirrors.
- turn_off_lasers() → None
Turn off current laser.
- turn_on_laser() → None
Turn on the current laser.
- update_data_buffer(data_buffer: List[ndarray], number_of_frames: int) → None
Update the data buffer for the camera.
- Parameters:
data_buffer (List[np.ndarray]) – Data buffer for the camera.
number_of_frames (int) – Number of frames to be acquired.
- update_stage_limits(limits_flag: bool = True) → None
Update stage limits.
- Parameters:
limits_flag (bool, optional) – Limits flag, by default True
- ask_stage_for_position
Ask stage for position.
- Type:
bool
- available_channels
List of available channels.
- Type:
list
- camera
Camera object.
- Type:
obj
- central_focus
Central focus position.
- Type:
float
- channels
List of all channels.
- Type:
list
- commands
Dictionary of commands
- Type:
dict
- configuration
Configuration dictionary.
- Type:
dict
- current_channel
Current channel.
- Type:
int
- current_laser_index
Current laser index.
- Type:
int
- daq
Dictionary of data acquisition devices.
- Type:
dict
- data_buffer
Buffer for image data.
- Type:
- filter_wheel
Dictionary of filter_wheels
- Type:
dict
- galvo
Dictionary of galvanometers.
- Type:
dict
- info
Dictionary of microscope info.
- Type:
dict
- is_synthetic
Is a synthetic microscope.
- Type:
Bool
- laser_wavelength
Dictionary of laser configurations.
- Type:
dict
- lasers
Dictionary of lasers.
- Type:
dict
- microscope_name
Name of the microscope.
- Type:
str
- number_of_frames
Number of images.
- Type:
int
- output_event_queue
Output event queue.
- Type:
Queue
- plugin_devices
Dictionary of plugin devices
- Type:
dict
- remote_focus_device
Remote focus device.
- Type:
Any
- ret_pos_dict
Dictionary of returned stage positions.
- Type:
dict
- shutter
Shutter device.
- Type:
Any
- stages
Dictionary of stages.
- Type:
dict
- stages_list
List of stages.
- Type:
list