hardware_control_zeiss¶
This module contains the class to control specific hardware for Zeiss Microscopes. This class is the link between the workflow and sample components of the Microscope Automation Software. It extends class BaseMicroscope(object)
The class uses an API to interact with connect_zen_blue. We strongly recommend to always access hardware functionality through the API exposed by hardware_control_zeiss.
The classes are built around a list of objects of class MicroscopeComponent(object). These objects are defined in module hardware_components. Most of these objects implement methods to control the hardware and store its state.
class SpinningDiskZeiss(BaseMicroscope)¶
Class to control a Carl Zeiss CellObserver microscope with a spinning disk head CSU-X1 from Yokogawa. The vendor software is ZEN blue. Most aspects of this microscope can be controlled through an extensive macro language based on IronPython. A subset of the functionality of this macro language can be exposed as dll.
The class SpinningDiskZeiss(BaseMicroscope) uses objects from hardware_components. that call the ZEN blue specific class ConnectMicroscope().
ZEN blue uses the concept of “experiments” for a collection of microscope settings and actions. The user defines these “experiments” through a graphical user interface. The information is saved on disk as xml file. These “experiments” are equivalent to “capture settings” within the 3i Slidebook software. To acquire an image or trigger other functions of the microscope we use in most cases “experiments”. The user defines these “experiments” within ZEN blue and provides the name of the “experiment” in a preferences file.
Most of the methods described below take this “experiment” name as input. The most important methods are:
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
add_control_software
(self, control_software_object)¶ Add object that connects this code to the vendor specific microscope control code to Microscope.
- Input:
controlSoftwareObject: single object connecting to vendor software
- Output:
none
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
add_microscope_object
(self, component_objects)¶ Add component to microscope.
- Input:
component_objects: object of a component class (e.g. Stage, Camera) or list of component classes
- Output:
none
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
change_objective
(self, experiment, objective_changer_object, trials=3)¶ Switch to objective used in experiment.
- Input:
experiment: string with name of experiment as defined in microscope software
objective_changer_object: object for objective changer objective is mounted to
trials: number of times system tries to recover
- Output:
objective_name: name of objective in new position
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
create_experiment_path
(self, experiment)¶ Creates complete path to experiment (Zen) or capture settings (Slidebook). Raises exception if experiment does not exist.
- Input:
experiment: string with name of experiment or capture settings (with or w/o extension .czexp or .exp.prefs)
- Output:
experiment_path: path to experiment or capture settings
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
execute_experiment
(self, experiment=None, file_path=None, z_start='C', interactive=False)¶ Trigger microscope to execute experiment defined within vendor software. Class ImageAICS is a container for meta and image data. To add image data use method load_image. Do not try to recover from exceptions on this level.
- Input:
experiment: string with name of experiment defined within Microscope software. If None use actual experiment.
file_path: string with path to save image do not save if None (default)
z_start: define where to start z-stack (‘F’= first slice, ‘C’ = center, ‘L’ = last slice). Default: ‘F’
interactive: if True, allow user to modify file name if file exists
- Output:
image: image of class ImageAICS to hold metadata. Does not contain image data at this moment.
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
get_information
(self, components_list=[])¶ Get positions for hardware components.
- Input:
components_list: list with names of components to retrieve positions Default: None = get positions for all components
- Output:
positions_dict: dictionary {component_id: positions}. Positions are dictionaries if multiple positions can be retrieved
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
get_objective_is_ready
(self, objective_position, reference_object_id=None)¶ Test if objective was initialized.
- Input:
objective_position: position of objective in objective changer
reference_object_id: ID of reference object (e.g. well) which objective was initialized for
- Output:
objective_is_ready: True, if offset for objective was set
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
initialize_hardware
(self, initialize_components_ordered_dict=None, reference_object_id=None, trials=3, verbose=True)¶ Initialize all hardware components.
- Input:
initialize_components_ordered_dict: directory with names of components to initialize and list of initialization steps. Default: None = initialize all components in order as assigned to microscope object
reference_object_id: Used for setting up of autofocus
trials: number of trials before initialization is aborted
verbose: if True print debug information (Default = True)
- Output:
none
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
live_mode
(self, camera_id, experiment=None, live=True)¶ Start/stop live mode of ZEN software.
- Input:
camera_id: string id for camera
experiment: name of ZEN experiment (default = None)
live: switch live mode on (True = default) or off (False)
- Output:
none
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
load_image
(self, image, get_meta=False)¶ Load image and return it as class ImageAICS. Methods adds image and meta data to image. Methods passes load image to microscope specific load method.
- Input:
communication_object: Object that connects to microscope specific software
image: image object of class ImageAICS. Holds meta data at this moment, no image data.
get_meta: if true, retrieve meta data from file. Default is False
- Output:
image: image with data and meta data as ImageAICS class
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
microscope_is_ready
(self, experiment, component_dict, focus_drive_id, objective_changer_id, safety_object_id, reference_object_id=None, load=True, make_ready=True, trials=3, verbose=True)¶ Check if microscope is ready and setup up for data acquisition.
- Input:
experiment: string with name of experiment as defined in microscope software
compenent_dict: dictionary with component_id as key and list actions
focus_drive_id: string id for focus drive
objective_changer_id: string id for objective changer parfocality and parcentricity has to be calibrated
safety_object_id: string id for safety area
reference_object_id: ID object used to set parfocality and parcentricity
load: move objective into load position before moving stage
make_ready: if True, make attempt to ready microscope, e.g. setup autofocus (Default: True)
trials: maximum number of attempt to initialize microscope. Will allow user to make adjustments on microscope. (Default: 3)
verbose: print debug messages (Default: True)
- Output:
is_ready: dictionary of all components that are ready
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
move_to_abs_pos
(self, stage_id=None, focus_drive_id=None, objective_changer_id=None, auto_focus_id=None, safety_id=None, safe_area='Compound', x_target=None, y_target=None, z_target=None, z_focus_preset=None, reference_object_id=None, load=True, trials=3, verbose=False)¶ Move stage and focus drive to position (x, y, z) in absolute system coordinates.
- Input:
stage_id, focus_drive_id: strings to identify stage and focus drive
objective_changer_id: string to identify objective changer
safety_id: string to identify safety object
safe_area: name of safe area withing safety object (default: ‘compound’ = combine all areas)
x_target, y_target: coordinates of stage after movement (none = do not move stage)
z_target: coordinate for focus position after movement (none = do not move focus, but engage auto-focus)
z_focus_preset: z position for focus before focus recall to make autofocus more reliable (Default: None, do not use feature)
reference_object_id: ID of object of type sample (ImagingSystem). Used to correct for xyz offset between different objectives
load: Move focus in load position before move. Default: True
trials: number of trials to retrieve z position before procedure is aborted
- Ouput:
x_final, y_final, z_final: coordinates after move
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
remove_images
(self)¶ Remove all images from display in microscope software
- Input:
communication_object: Object that connects to microscope specific software
- Output:
none
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
run_macro
(self, macro_name=None, macro_param=None)¶ Function to run a given Macro in the Zen Software
- Input:
macro_name: Name of the Macro
- Output:
none
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
save_image
(self, file_path, image, interactive=False)¶ Save last Microscope ImageAICS taken from within Microscope software. Methods adds file_path to meta data.
- Input:
file_path: filename with path to save ImageAICS
image: image of class ImageAICS
interactive: if True, allow update of filename if it already exists
- Output:
image: image of class ImageAICS
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
set_microscope
(self, settings_dict={})¶ Set status flags for microscope.
- Input:
- settings_dict: dictionary {component_id: {settings}}
- supported flags:
autofocus_id: {use_auto_focus: True/False}
- Output:
new_settings_dict: return all current settings
-
microscope_automation.hardware.hardware_control_zeiss.SpinningDiskZeiss.
stop_microscope
(self)¶ Stop Microscope immediately in emergency situation