Contents
samples¶
The samples module contains classes which define different objects that can be imaged, e.g. plates, slides, wells, and cells. These classes all have a microscope object attribute which defines the hardware_control method like class SpinningDisk3i(BaseMicroscope) or class SpinningDiskZeiss(BaseMicroscope).
class ImagingSystem(object)¶
This is the parent class of all other objects in the samples module.
-
class
microscope_automation.samples.samples.
ImagingSystem
(container=None, name='', image=True, x_zero=0, y_zero=0, z_zero=0, x_flip=1, y_flip=1, z_flip=1, x_correction=0, y_correction=0, z_correction=0, z_correction_x_slope=0, z_correction_y_slope=0, z_correction_z_slope=0, x_safe_position=None, y_safe_position=None, z_safe_position=None, reference_object=None, x_ref=None, y_ref=None, z_ref=None, microscope_object=None, stage_id=None, focus_id=None, auto_focus_id=None, objective_changer_id=None, safety_id=None, camera_ids=[])[source]¶ -
acquire_images
(experiment, camera_id, reference_object=None, file_path=None, pos_list=None, load=True, use_reference=True, use_auto_focus=False, meta_dict={}, verbose=True)[source]¶ Acquire image or set of images using settings defined in microscope software and optionally save.
Methods calls method of container instance until container has method implemented that actually performs action.
- Input:
experiment: string with experiment name as defined within microscope software
camera_id: string with unique camera ID
reference_object: object used to set parfocality and parcentricity, typically a well in plate
file_path: string for filename with path to save image in original format or tuple with string to directory and list with template for file name. Default=None: no saving
pos_list: coordinates if multiple images (e.g. tile) should be acquired. The coordinates are absolute stage positions in mum not corrected for objective offset.
load: Move focus in load position before move. Default: True
meta_dict: directory with additional meta data, e.g. {‘aics_well’:, ‘A1’}
use_autofocus: use autofocus (default = False)
use_reference: use reference object (default = True)
verbose: if True print debug information (Default = True)
- Output:
images: list with ImageAICS objects. Does not include the pixel data. Get pixel data with load_image.
-
add_attached_image
(key, image)[source]¶ Attach image to sample object.
- Input:
key: string with name of image (e.g. ‘backgroundGreen_10x’)
image: image object of class ImageAICS
- Output:
none
-
add_camera_id
(camera_id)[source]¶ Add ID to camera_ids without removing the existing IDs.
- Input:
camera_id: ID to add to the list of IDs
- Output:
none
-
add_meta
(meta_dict)[source]¶ Update dictionary with meta data.
- Input:
meta_dict: dictionary with meta data
- Output:
updated_meta_dict: dictionary with additional meta data
-
add_meta_data_file
(meta_data_file_object)[source]¶ Add object that handles saving of meta data to disk.
- Input:
meta_data_file_object: object of type meta_data_file
- Output:
none
-
add_samples
(sample_objects_dict)[source]¶ Adds samples to imaging system.
- Input:
sample_objects_dict: dictionary of form {‘name’: sample_object}
- Output:
none
-
add_to_image_dir
(list_name, sample_object=None, position=None)[source]¶ Add sample object to list with name list_name of objects to be imaged.
- Input:
list_name: string with name of list (e.g. ‘ColoniesPreScan’)
sample_object: object to be imaged. Can be list. List will always added at end
- position: position of object in list. Position will determine order of imaging.
Default: None = Append to end. Has no effect if object is list.
- Output:
none
-
background_correction
(uncorrected_image, settings)[source]¶ Correct background using background images attached to object or one of it’s superclasses.
- Input:
uncorrected_image: object of class ImageAICS
settings: object of class Preferences which holds image settings
- Output:
corrected: object of class ImageAICS after background correction.
-
calculate_slope_correction
(x, y, verbose=True)[source]¶ Calculate offset in z because of tilted sample.
- Input:
x, y: x and y positions in object coordinates in um the correction is to be calculated
verbose: if True print debug information (Default = True)
- Output:
z_slope_correction: offset in z in um
-
execute_experiment
(experiment, camera_id, reference_object=None, file_path=None, meta_dict={}, verbose=True)[source]¶ Acquire single image using settings defined in microscope software and optionally save.
Methods calls method of container instance until container has method implemented that actually performs action.
- Input:
experiment: string with experiment name as defined within microscope software
camera_id: string with unique camera ID
reference_object: object of type sample (ImagingSystem) used to correct for xyz offset between different objectives
file_path: filename with path to save image in original format. Default=None: no saving
meta_dict: directory with additional meta data, e.g. {‘aics_well’:, ‘A1’}
focus: use autofocus (default = False)
verbose: if True print debug information (Default = True)
- Output:
image: ImageAICS object. At this moment they do not include the pixel data. Get pixel data with load_image.
-
find_surface
(trials=3, verbose=True)[source]¶ Find cover slip using Definite Focus 2.
- Input:
trials: number of trials before initialization is aborted
verbose: if True, print debug messages (Default: True)
- Output:
z: position of focus drive after find surface
-
get_abs_pos_from_obj_pos
(x_object, y_object, z_object=None, verbose=True)[source]¶ Convert object coordinates into stage coordinates.
- Input:
x_object, y_object, z_object: Object coordinates in mum
verbose: if True print debug information (Default = True)
- Output:
x, y, z: coordinates in absolute stage coordinates in mum
-
get_abs_position
(stage_id=None, focus_id=None)[source]¶ Return current stage position. Positions are corrected for centricity and parfocality.
- Input:
stage_id: string id to identify stage information is collected from
focus_id: string id to identify focus drive information is collected from
- Output:
abs_pos: absolute (x, y, z) position of stage in mum
-
get_abs_zero
(verbose=True)[source]¶ Return center of object in stage coordinates.
- Input:
verbose: if True print debug information (Default = True)
- Output:
x_zero, y_zero, z_zero: center of object in mum in stage coordinates
-
get_attached_image
(key)[source]¶ Retrieve attached image.
- Input:
key: string with name of image (e.g. ‘backgroundGreen_10x’)
- Output:
image: image object of class ImageAICS
-
get_auto_focus_id
()[source]¶ Return id for auto-focus used with this sample.
- Input:
none
- Output:
auto_focus_id: id for auto-focus used with this sample
Searches through all containers until id is found
-
get_camera_ids
()[source]¶ Return ids for cameras used with this sample. Searches through all containers until id is found.
- Input:
none
- Output:
camera_ids: list with ids for cameras used with this sample
-
get_container
()[source]¶ Return container object that encloses object.
- Input:
none
- Output:
container: container object
-
get_container_pos_from_obj_pos
(x_object, y_object, z_object, verbose=True)[source]¶ Calculate container coordinates for given object coordinates.
- Input:
x_object, y_object, z_object: Object coordinates in mum
verbose: if True print debug information (Default = True)
- Output:
x_container, y_container, z_container: Container coordinates in mum for object coordinates
-
get_correction
()[source]¶ Get correction term if scaling for object coordinate system is slightly off relative to container coordinate system.
- Input:
none
- Output:
x_correction, y_correction, z_correction: Correction terms
-
get_flip
()[source]¶ Return if object coordinate system is flipped relative to container coordinate system.
- Input:
none
- Output:
x_flip, y_flip: 1 if system is not flipped, otherwise -1
-
get_focus_id
()[source]¶ Return id for focus used with this sample.
- Input:
none
- Output:
focus_id: id for focus used with this sample
Searches through all containers until id is found
-
get_from_image_dir
(list_name)[source]¶ Get list with name list_name of objects to be imaged.
- Input:
list_name: string with name of list (e.g. ‘ColoniesPreScan’)
- Output:
sample_objects: list of name list_name with objects to be imaged
-
get_image
()[source]¶ Return image property that defines if sample is included in imaging.
- Input:
none
- Output:
image: if True, include in imaging
-
get_images
(load=True, get_meta=False)[source]¶ Retrieve dictionary with images.
- Input:
load: if true, will load image data before returning dictionary
get_meta: if true, load meta data
- Output:
images: list of images.
-
get_immersion_delivery_system
()[source]¶ Return the object that describes immersion water delivery system
- Input:
none
- Output:
immersion_delivery_system: object of class ImmersionDelivery
-
get_meta
()[source]¶ Return dictionary with meta data.
- Input:
none
- Output:
meta_dict: dictionary with meta data
-
get_meta_data_file
()[source]¶ Return object that handles saving of meta data to disk.
- Input:
none
- Output:
meta_data_file_object: object of type meta_data_file. None if no meta data file exists
-
get_microscope
()[source]¶ Return object that describes connection to hardware.
- Input:
none
- Output:
microscope_object: object of class Microscope from module hardware
-
get_obj_pos_from_container_pos
(x_container, y_container, z_container, verbose=True)[source]¶ Calculate object coordinates from container coordinates.
- Input:
x_container, y_container, z_container: container coordinates in mum
verbose: if True print debug information (Default = True)
- Output:
x_object, y_object, z_object: object coordinates in mum for container coordinates
-
get_objective_changer_id
()[source]¶ Return id for objective changer used with this sample.
- Input:
none
- Output:
objective_changer_id: id for objective changer used with this sample
Searches through all containers until id is found
-
get_pos_from_abs_pos
(x=None, y=None, z=None, verbose=True)[source]¶ Return current position in object coordinates in mum. or transforms (x,y,z) from stage coordinates into object coordinates. This method is based on focus coordinates after drift correction.
- Input:
x, y, z: Absolute stage coordinates in mum. If not given or None retrieve current stage position and express in object coordinates.
verbose: if True print debug information (Default = True)
- Output:
x_pos, y_pos, z_pos: current or position passed in stage coordinate returned in object coordinates
-
get_reference_object
()[source]¶ Get reference object to correct for xyz offset between different objectives.
- Input:
none
- Output:
reference_object: any object of type sample
Searches through all containers until id is found
-
get_reference_position
()[source]¶ Return position used as reference to correct for xyz offset between different objectives.
Get position from reference object if available. If none is available use zero postion
- Input:
none
- Output:
x, y, z: position of reference structure in object coordinates
-
get_safe
()[source]¶ Get safe stage position to start any movement without danger . of collision in sample coordinates.
- Input:
None
- Output:
x, y, z: safe position in sample coordinates.
-
get_safety_id
()[source]¶ Return id for safety object. Safety object describes travel safe areas for stage and objectives.
- Input:
none
- Output:
saftey_id: id for safety object used with this sample
Searches through all containers until id is found
-
get_sample_type
()[source]¶ Return sample type.
- Input:
none
- Output:
sample_type: string with name of object type
-
get_stage_id
()[source]¶ Return id for stage used with this sample.
- Input:
none
- Output:
stage_id: id for stage used with this sample
Searches through all containers until id is found
-
get_tile_positions_list
(prefs, tile_object='NoTiling', verbose=True)[source]¶ Get positions for tiles in absolute coordinates. Subclasses have additional tile_objects (e.g. ColonySize, Well).
- Input:
prefs: Preferences object with preferences for tiling
- tile_object: tile object passed in by preferences. Possible options:
‘NoTiling’: do not tile
‘Fixed’: calculate tiling to image a rectangular area
‘Well’: cover a well with tiles using an elliptical area
‘ColonySize’: cover a colony with tiles using an ellipse
verbose: print debugging information
- Output:
tile_position_list: list with absolute positions for tiling
-
get_use_autofocus
()[source]¶ Return flag about autofocus usage
- Input:
none
- Output:
use_autofocus: boolean varaible indicating if autofocus should be used
-
get_well_object
()[source]¶ Get well object for subclass.
- Input:
none
- Output:
well_object: object for well
-
get_zero
()[source]¶ Return center of object in container coordinates.
- Input:
none
- Output:
x_zero, y_zero, z_zero: center of object in mum in container coordinates
-
live_mode_start
(camera_id, experiment)[source]¶ Start live mode in microscope software.
Methods calls method of container instance until container has method implemented that actually performs action.
- Input:
camera_id: string with unique camera ID
experiment: string with experiment name as defined within microscope software If None use actual experiment.
- Output:
none
-
live_mode_stop
(camera_id, experiment=None)[source]¶ Stop live mode in microscope software.
Methods calls method of container instance until container has method implemented that actually performs action.
- Input:
camera_id: string with unique camera ID
experiment: string with experiment name as defined within microscope software If None use actual experiment.
- Output:
none
-
load_image
(image, get_meta)[source]¶ Load image and meta data in object of type ImageAICS.
Methods calls method of container instance until container has method implemented that actually performs action.
- Input:
image: image object of class ImageAICS. Holds meta data at this moment, no image data.
get_meta: if true, retrieve meta data from file.
- Output:
image: image with data and meta data as ImageAICS class
-
microscope_is_ready
(experiment, reference_object=None, load=True, use_reference=True, use_auto_focus=True, make_ready=True, trials=3, verbose=True)[source]¶ Check if microscope is ready and setup up for data acquisition.
- Input:
experiment: string with name of experiment as defined in microscope software
reference_object: object used to set parfocality and parcentricity
load: move objective into load position before moving stage
use_reference: initialize reference position if not set
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:
ready: True if microscope is ready for use, False if not
-
move_delta_xyz
(x, y, z=0, load=True, verbose=True)[source]¶ Move in direction x,y,z in micrometers from current position.
- Input:
x, y, z: step size in micrometers
load: Move focus in load position before move. Default: True
verbose: if True print debug information (Default = True)
- Output:
x_stage, y_stage: x, y position on stage in mum
-
move_to_abs_position
(x=None, y=None, z=None, reference_object=None, load=True, verbose=True)[source]¶ Move stage to position x, y, z.
- Input:
x, y: Position stage should move to in stage coordinates in mum. If None, stage will not move
z: Focus position in mum. If not provided focus will not be changed, but autofocus might engage
reference_object: object of type sample (ImagingSystem) used to correct for xyz offset between different objectives
load: Move focus in load position before move. Default: True
verbose: if True print debug information (Default = True)
- Output:
x, y: New stage position
If use_autofocus is set, correct z value according to new autofocus position.
-
move_to_r_phi
(r, phi, load=True, verbose=True)[source]¶ moves to position r [mum], phi [degree] in radial coordinates. (0,0) is the center of unit (e.g. well). 0 degrees is in direction of x axis.
- Input:
r: radius in mum for radial coordinates (center = 0)
phi: angle in degree for radial coordinates (right = 0 degree)
load: Move focus in load position before move. Default: True
verbose: if True print debug information (Default = True)
- Output:
x_stage, y_stage: x, y position on stage in mum
-
move_to_safe
(load=True, verbose=True)[source]¶ Move to safe position for object.
- Input:
load: Move focus in load position before move. Default: True
verbose: if True print debug information (Default = True)
- Output:
x, y, z: new position in stage coordinates in mum
-
move_to_xyz
(x, y, z=None, reference_object=None, load=True, verbose=True)[source]¶ Move to position in object coordinates in mum.
If use_autofocus is set, correct z value according to new autofocus position.
- Input:
x, y, z; Position in object coordinates in mum. If z == None do not change z position
reference_object: object of type sample (ImagingSystem) used to correct for xyz offset between different objectives
load: Move focus in load position before move. Default: True
verbose: if True print debug information (Default = True)
- Output:
x_abs, y_abs, z_abs: new position in absolute stage coordinates in mum
-
move_to_zero
(load=True, verbose=True)[source]¶ Move to center of object.
- Input:
load: Move focus in load position before move. Default: True
verbose: if True print debug information (Default = True)
- Output:
x, y, z: new position in stage coordinates in mum
-
recall_focus
(auto_focus_id, pre_set_focus=True)[source]¶ Find difference between stored focus position and actual autofocus position. Recall focus will move the focus drive to it’s stored position.
- Input:
auto_focus_id: string of ID for autofocus to use
pre_set_focus: Move focus to previous auto-focus position. This makes definite focus more robust
- Output:
delta_z: difference between stored z position of focus drive and position after recall focus
-
set_container
(container=None)[source]¶ Object is part of container object (e.g. Plate is container for Well).
- Input:
container: object for container
- Output:
none
-
set_correction
(x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0, z_correction_z_slope=0, z_correction_offset=0)[source]¶ Set correction term if scaling for object coordinate system is slightly off relative to container coordinate system.
- Input:
x_correction, y_correction, z_correction: Correction terms
- Output:
none
-
set_flip
(x_flip=1, y_flip=1, z_flip=1)[source]¶ Set if object coordinate system is flipped relative to container coordinate system.
- Input:
x_flip, y_flip, z_flip: 1 if system is not flipped, otherwise -1
- Output:
none
-
set_hardware
(microscope_object=None, stage_id=None, focus_id=None, auto_focus_id=None, objective_changer_id=None, safety_id=None, camera_ids=[])[source]¶ Store object that describes connection to hardware.
- Input:
microscope_object: object of class Microscope from module hardware
stage_id: id string for stage.
focus_id: id string with name for focus drive
auto_focus_id: id string with name for auto-focus
objective_changer_id: id string with name for objective changer
safety_id: id string for safety area that prevents objective damage during stage movement
camera_ids: list with ids for cameras used with this sample
- Output:
none
-
set_image
(image=True)[source]¶ Define if sample should be included in imaging.
- Input:
image: if True, include in imaging
- Output:
none
-
set_interactive_positions
(tile_image_data, location_list=[], app=None)[source]¶ Opens up the interactive mode and lets user select colonies and return the list of coordinates selected
- Input:
tile_image_data: The pixel data of the image of the well - numpy array
location_list: The list of coordinates to be pre plotted on the image.
app: pyqt application object initialized in microscope_automation.py
- Output:
location_list: Returns the list of colonies selected by the user
-
set_reference_object
(reference_object)[source]¶ Set reference object to correct for xyz offset between different objectives. Avoid setting reference positions and connect reference object to same sample.
- Input:
reference_object: any object of type sample
- Output:
none
-
set_reference_position
(x, y, z)[source]¶ Set position used as reference to correct for xyz offset between different objectives. Avoid setting reference positions and connect reference object to the same sample.
- Input:
x, y, z: position of reference structure in object coordinates. Can be None
- Output:
none
-
set_safe
(x, y, z)[source]¶ Set safe stage position to start any movement without danger of collision in sample coordinates.
- Input:
x, y, z: safe position in sample coordinates.
- Output:
x_safe, y_safe, z_safe: safe position in sample coordinates.
-
set_use_autofocus
(flag)[source]¶ Set flag to enable the use of autofocus.
- Input:
flag: if true, use autofocus
- Output:
use_autofocus: status of use_autofocus
-
set_zero
(x=None, y=None, z=None, verbose=True)[source]¶ Set center position of object in container coordinates.
- Input:
x, y, z: position of object center in mum in coordinate system of enclosing container. If None, use current position
verbose: if True print debug information (Default = True)
- Output:
x_zero, y_zero, z_zero: new center position in container coordinates
-
store_focus
(focus_reference_obj=None, trials=3, verbose=True)[source]¶ Store actual focus position as offset from coverslip.
- Input:
focus_reference_obj: Sample object used as reference for autofocus
trials: number of trials before initialization is aborted
verbose: if True, print debug messages (Default: True)
- Output:
z: position of focus drive after store focus
-
tile_images
(images, settings)[source]¶ Create tile of all images associated with object.
- Input:
images: list with image objects of class ImageAICS
settings: object of class Preferences which holds image settings
- Output:
tile: ImageAICS object with tile
-
update_correction
(x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=1, z_correction_y_slope=1, z_correction_z_slope=1, z_correction_offset=1)[source]¶ Multiply existing correction terms if scaling for object coordinate system is slightly off relative to container coordinate system with additional correction term.
- Input:
x_correction, y_correction, z_correction z_correction_x_slope, z_correction_y_slope, z_correction_z_slope, z_correction_offset: Additional multiplicative correction terms
- Output:
x_correction, y_correction, z_correction: updated parameters
-
update_flip
(x_flip=1, y_flip=1, z_flip=1)[source]¶ Set if object coordinate system should be flippedcompared to current settings.
- Input:
x_flip, y_flip, z_flip: 1 if coordinate system flip should stay the same, otherwise -1
- Output:
x_flip, y_flip, z_flip: updated parameters
-
update_zero
(x=None, y=None, z=None, verbose=True)[source]¶ Update center position of object in container coordinates.
- Input:
x, y, z: position of object center in mum in coordinate system of inclosing container. If None, use current position
verbose: if True print debug information (Default = True)
- Output:
x_zero, y_zero, z_zero: new center position in container coordinates
-
class Background(ImagingSystem)¶
Class used for background correction of plates.
-
class
microscope_automation.samples.samples.
Background
(name='Background', center=[0, 0, 0], well_object=None, image=True, ellipse=[0, 0, 0], meta=None, x_flip=1, y_flip=- 1, z_flip=1, x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0)[source]¶ Class for the background object associated with each plate. It will be used to do background correction.
class PlateHolder(ImagingSystem)¶
Class which describes a plate holder. A plate holder is the container object which holds plates, slides, and other samples.
-
class
microscope_automation.samples.samples.
PlateHolder
(name='PlateHolder', microscope_object=None, stage_id=None, focus_id=None, auto_focus_id=None, objective_changer_id=None, safety_id=None, immersion_delivery=None, camera_ids=[], center=[0, 0, 0], x_flip=1, y_flip=1, z_flip=1, x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0, x_safe_position=55600, y_safe_position=31800, z_safe_position=0)[source]¶ Class to describe and navigate Stage.
A PlateHolder is the superclass for everything that can be imaged on a microscope (e.g. plates, wells, colonies, cells).
A Stage has it’s own coordinate system measured in mum and nows it’s position in stage coordinates.
A Stage can be moved to a position and acquire images. It will take track of the last image. To keep the image the user has to save it.
-
add_plates
(plate_object_dict)[source]¶ Adds Plate to Stage.
- Input:
plate_object_dict: dictionary of the form {“name”: plate_object}
- Output:
none
-
add_slides
(slide_object_dict)[source]¶ Adds Slide to PlateHolder.
- Input:
slide_object_dict:dictionary of the form {“name”: slide_object}
- Output:
none
-
execute_experiment
(experiment, camera_id, reference_object=None, file_path=None, meta_dict={'aics_barcode': '', 'aics_well': '', 'aics_xTile': '', 'aics_yTile': ''}, verbose=True)[source]¶ Acquire image using settings defined in microscope software and optionally save.
- Input:
experiment: string with experiment name as defined within microscope software
camera_id: string with unique camera ID
reference_object: object of type sample (ImagingSystem) used to correct for . xyz offset between different objectives
file_path: filename with path to save image in original format. Default=None: no saving
meta_dict: directory with additional meta data, e.g. {‘aics_well’:, ‘A1’}
verbose: if True print debug information (Default = True)
- Output:
image: image of class ImageAICS
Method adds camera_id to image.
-
find_surface
(reference_object=None, trials=3, verbose=True)[source]¶ Find cover slip using Definite Focus 2 and store position focus_drive object
- Input:
reference_object: Used for setting up of autofocus
trials: number of trials before initialization is aborted
verbose: if True, print debug messages (Default: True)
- Output:
positions_dict: dictionary {‘absolute’: z_abs, ‘focality_corrected’: z_cor} with focus position in mum
-
get_abs_stage_position
(stage_id=None, focus_drive_id=None)[source]¶ Get current position in stage coordinates and focus position in mum corrected for parcentricity.
- Input:
stage_id: id string for stage.
focus_id: id string with name for focus drive
- Output:
x, y, z: real focus position not corrected for drift.
-
get_camera_ids
()[source]¶ Return a list of camera objects associated with this sample
- Input:
none
- Output:
camera_ids: list of objects of class Camera
-
get_corrected_stage_position
(verbose=False)[source]¶ Get current position in stage coordinates and focus position in mum.
- Input:
none
- Output:
x, y, z: Stage position after centricity correction
-
get_immersion_delivery_system
()[source]¶ Return object that describes immersion water delivery system for this plate holder.
- Input:
none
- Output:
immersion_object: object of class ImmersionDelivery
-
get_microscope
()[source]¶ Return object that describes connection to hardware.
- Input:
none
- Output:
microscope_object: object of class Microscope from module hardware
-
get_plates
()[source]¶ Return dictionary of all plate_objects associated with plateholder.
- Input:
none
- Output:
plate_objects: dictionary with plate objects
-
get_slides
()[source]¶ Return Slide object attached to PlateHolder
- Input:
none
- Output:
slide_object: dictionary with slide objects
-
get_use_autofocus
()[source]¶ Return flag about autofocus usage
- Input:
none
- Output:
use_autofocus: boolean variable indicating if autofocus should be used
-
live_mode_start
(camera_id, experiment=None)[source]¶ Start live mode in microscope software.
- Input:
camera_id: string with unique camera ID
experiment: string with experiment name as defined within microscope software If None use actual experiment.
- Output:
none
-
live_mode_stop
(camera_id, experiment=None)[source]¶ Start live mode in microscopy software.
- Input:
camera_id: string with unique camera ID
experiment: string with experiment name as defined within microscope software If None use actual experiment.
- Output:
None
-
load_image
(image, get_meta)[source]¶ load image and meta data in object of type ImageAICS
- Input:
image: meta data as ImageAICS object. No image data loaded so far (if image data exists, it will be replaced)
get_meta: boolean of whether to obtain meta data for the image
- Output:
image: image and meta data (if requested) as ImageAICS object
-
recall_focus
(auto_focus_id, pre_set_focus=True)[source]¶ Find difference between stored focus position and actual autofocus position. Recall focus will move the focus drive to it’s stored position.
- Input:
auto_focus_id: string of ID for autofocus to use
pre_set_focus: Move focus to previous auto-focus position. This makes definite focus more robust
- Output:
delta_z: difference between stored z position of focus drive and position after recall focus
-
save_image
(file_path, camera_id, image)[source]¶ save original image acquired with given camera using microscope software
- Input:
file_path: string with filename with path for saved image in original format or tuple with path to directory and template for file name
camera_id: name of camera used for data acquisition
image: image of class ImageAICS
- Output:
image: image of class ImageAICS
-
set_plate_holder_pos_to_zero
(x=None, y=None, z=None)[source]¶ Set current stage position as zero position for PlateHolder.
- Input:
x, y, z: optional position in stage coordinates to set as zero position for PlateHolder. If omitted, actual stage position will be used.
- Output:
x, y, z: new PlateHolder zero position
-
set_stage_position
(x_stage, y_stage, z_stage=None, reference_object=None, load=True, verbose=True)[source]¶ Move stage to position in stage coordinates in mum.
- Input:
x_stage, y_stage, z_stage: stage position in mum
reference_object: object of type sample (ImagingSystem). Used to correct for xyz offset between different objectives
load: Move focus in load position before move. Default: True
verbose: if True print debug information (Default = True)
- Output:
x, y, z: actual stage position
If use_autofocus is set, correct z value according to new autofocus position.
-
set_use_autofocus
(flag)[source]¶ Set flag to enable the use of autofocus.
- Input:
flag: if true, use autofocus
- Output:
use_autofocus: status of use_autofocus
-
store_focus
(focus_reference_obj=None, trials=3, verbose=True)[source]¶ Store actual focus position as offset from coverslip.
- Input:
focus_reference_obj: Sample object used as reference for autofocus
trials: number of trials before initialization is aborted
verbose: if True, print debug messages (Default: True)
- Output:
positions_dict: dictionary {‘absolute’: z_abs, ‘focality_corrected’: z_cor} with focus position in mum
-
class ImmersionDelivery(ImagingSystem)¶
Class which interacts with class Pump(MicroscopeComponent).
-
class
microscope_automation.samples.samples.
ImmersionDelivery
(name='ImmersionDelivery', plate_holder_object=None, safety_id=None, pump_id=None, center=[0, 0, 0], x_flip=1, y_flip=1, z_flip=1, x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0, microscope_object=None)[source]¶ Class for pump and tubing to deliver immersion water to objective.
-
add_counter
(increment=1)[source]¶ Increment counter.
- Input:
- increment: integer to increment counter value.
default = 1
- Output:
count: counter setting after increment
-
count_and_get_water
(objective_magnification=None, pump_id=None, increment=1, verbose=True, automatic=False)[source]¶ Move objective to water outlet and add drop of water to objective.
- Input:
objective_magnification: add water to specific objective with given magnification as float number. Keep current objective if set to None.
pump_id: id of pump to trigger. None by default, which selects the pump_id already associated with this ImmersionDelivery object
increment: integer to increment counter value. Default = 1
verbose: if True print debug information (Default = True)
automatic: if True, trigger pump, else show dialog (Default = False)
- Output:
counter: counter value after increment
-
get_counter_stop_value
()[source]¶ Get value for counter to stop.
- Input:
none
- Output:
counter_stop_value: value for counter to stop
-
get_pump_id
()[source]¶ Return id for pump used with this ImmersionDelivery object.
- Input:
none
- Output:
pump_id: id for objective changer used with this sample
-
get_water
(objective_magnification=None, pump_id=None, verbose=True, automatic=False)[source]¶ Move objective to water outlet and add drop of water to objective.
- Input:
objective_magnification: add water to specific objective with given magnification as float number. Keep current objective if set to None.
pump_id: id of pump to trigger. None by default, which selects the pump_id already associated with this ImmersionDelivery object
verbose: if True print debug information (Default = True)
automatic: if True, trigger pump, else show dialog
- Output:
none
-
set_counter_stop_value
(counter_stop_value)[source]¶ Set value to stop counter and trigger pumping of immersion water.
- Input:
none
- Output:
counter_stop_value: current counter stop value
-
class Plate(ImagingSystem)¶
Class which describes a plate. A plate is the container object which holds wells.
-
class
microscope_automation.samples.samples.
Plate
(name='Plate', plate_holder_object=None, center=[0, 0, 0], x_flip=1, y_flip=1, z_flip=1, x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0)[source]¶ Class to describe and navigate Plate.
-
add_wells
(well_objects_dict)[source]¶ Adds well to plate.
- Input:
well_objects_dict: dictionary of form {‘name’: instance of Well class}
- Output:
none
-
get_well
(well_name)[source]¶ Return wellOjbect for well with name wellName.
- Input:
well_name: name of well in form ‘A1’
- Output:
well_object: object for one well with name wellName. None if no Well object with well_name exists
-
get_wells
()[source]¶ Return list with all instancess of class Well associated with plate.
- Input:
none
- Output:
wells: dict with well objects
-
get_wells_by_type
(sample_type)[source]¶ Return dictionary with all Well Objects associated with plate that contain samples of given type.
- Input:
sample_type: string or set with sample type(s) (e.g. {‘Sample’, ‘Colony’, ‘Barcode’})
- Output:
well_objects_of_type: dict with well objects
-
class Well(ImagingSystem)¶
Class which describes a well. A plate is the container object which holds barcodes and colonies.
-
class
microscope_automation.samples.samples.
Well
(name='Well', center=[0, 0, 0], diameter=1, plate_object=None, well_position_numeric=(0, 0), well_position_string=('A', '1'), x_flip=1, y_flip=1, z_flip=1, x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0)[source]¶ Class to describe and navigate single Well
-
add_barcode
(barcode_objects_dict)[source]¶ Adds barcode to well. Raises TypeError if non-barcode object is added.
- Input:
barcode_objects_dict: dictionary of form {‘name’: barcodeObject}
- Output:
none
-
add_colonies
(colony_objects_dict)[source]¶ Adds colonies to well. Raises TypeError if non-colony object is added.
- Input:
colony_objects_dict: dictionary of form {‘name’: colony_object}
- Output:
none
-
add_samples
(sample_objects_dict)[source]¶ Adds samples to well.
- Input:
sample_objects_dict: dictionary of form {‘name’: sample_object}
- Output:
none
-
calculate_well_correction
(update=True)[source]¶ Calculate correction factor for well coordinate system.
We find position within the well (e.g. colonies) based on their distance from the center in mum. For some experiments we use coordinates measured on other systems. Their might be a slight difference in calibration for different systems. We will use the well diameter to calculate a compensation factor for these differences.
- Input:
update: if True update correction factor and do not replace to keep earlier corrections in place
- Output:
none
-
find_colonies
(location_list)[source]¶ Find locations of colonies to be imaged in well and add them to well.
- Input:
location_list: list of the colony locations relative to the center of the well
- Output:
colony_list: List of Colony Objects
-
find_well_center_fine
(experiment, well_diameter, camera_id, settings, verbose=True, test=False)[source]¶ Find center of well with higher precision.
Method takes four images of well edges and calculates center. Will set origin of well coordinate system to this value.
- Input:
experiment: string with imaging conditions defined within microscope software
well_diameter: diameter of reference well in mum
camera_id: string with name of camera
settings: object of class Preferences which holds image settings
verbose: if True print debug information (Default = True)
test: if True will call find_well_center.find_well_center_fine in test mode. (Default = False)
- Output:
x_center, y_center, z_center: Center of well in absolute stage coordinates in mum. z after drift correction (as if no drift had occured)
-
get_assigned_diameter
()[source]¶ Get well diameter for well as measured by external means.
- Input:
none
- Output
assigned_diameter: predefined diameter in mum (e.g from plate specifications or other instrument)
-
get_colonies
()[source]¶ Get all colonies in well.
- Input:
none
- Output:
colonies: dict with colony objects
-
get_diameter
()[source]¶ Get well diameter for well. If measured diameter is available it will used, otherwise the set_diameter from specifications is used.
- Input:
none
- Output
diameter: diameter in mum
-
get_measured_diameter
()[source]¶ Get well diameter for well as measured in find_well_center_fine.
- Input:
none
- Output
measured_diameter: diameter in mum as measured in find_well_center_fine
-
get_samples
(sample_type={'Barcode', 'Colony', 'Sample'})[source]¶ Get all samples in well.
- Input:
sample_type: list with types of samples to retrieve. At this moment {‘Sample’, ‘Barcode’, ‘Colony’} are supported
- Output:
samples: dict with sample objects
-
get_tile_positions_list
(prefs, tile_object='Well', verbose=True)[source]¶ Get positions for tiles in absolute coordinates. Other classes have additional tile_objects (e.g. ColonySize).
- Input:
prefs: Preferences object with preferences for tiling
- tile_object: tile object passed in by preferences. Possible options:
‘NoTiling’: do not tile
‘Fixed’: calculate tiling to image a rectangular area
‘Well’: cover a well with tiles using an elliptical area
‘ColonySize’: cover a colony with tiles using an ellipse
verbose: print debugging information
- Output:
tile_position_list: list with absolute positions for tiling
-
get_well_object
()[source]¶ Get well object for subclass.
- Input:
none
- Output:
well_object: object for well
-
get_well_position_numeric
()[source]¶ Get row and column number.
- Input:
none
- Output:
well_position_numeric: (column, row) as integer tuple (e.g. (0,0) for well A1
-
get_well_position_string
()[source]¶ Get row and column as string.
- Input:
none
- Output:
well_position_string: (row, column) as string tuple (e.g. (‘A’,’1’) for well A1)
-
set_assigned_diameter
(assigned_diameter)[source]¶ Set diameter from specifications or measured externally for well.
- Input:
assigned_diameter: predefined diameter in mum (e.g from plate specifications or other instrument)
- Output:
none
-
set_diameter
(diameter)[source]¶ Set diameter for well. If measured diameter is available it will used, otherwise the set_diameter from specifications is used.
- Input:
diameter: diameter in mum
- Output:
none
-
set_interactive_positions
(tile_image_data, location_list=None, app=None)[source]¶ Opens up the interactive mode and lets user select colonies and return the list of coordinates selected
- Input:
tile_image_data: The pixel data of the image of the well - numpy array
location_list: The list of coordinates to be pre plotted on the image.
app: pyqt application object initialized in microscope_automation.py
- Output:
location_list: Returns the list of colonies selected by the user
-
set_measured_diameter
(measured_diameter)[source]¶ Set diameter measured during experiment for well.
- Input:
measured_diameter: diameter in mum as measured in find_well_center_fine
- Output:
none
-
class Barcode(ImagingSystem)¶
-
class
microscope_automation.samples.samples.
Barcode
(name='Barcode', well_object=None, center=[0, 0, 0], x_flip=1, y_flip=- 1, z_flip=1, x_correction=0, y_correction=0, z_correction=0, z_correction_x_slope=0, z_correction_y_slope=0)[source]¶ Class to image and read barcode.
-
read_barcode
(experiment, camera_id, file_path, verbose=True)[source]¶ Take image of barcode and return code.
- Input:
experiment: string with imaging conditions as defined within microscope sofware
camera_id: string with name of camera
file_path: filename with path to store images. If None, image is not saved
verbose: if True print debug information (Default = True)
- Output:
code: string encoded in barcode
-
read_barcode_data_acquisition
(experiment, camera_id, file_path, verbose=True)[source]¶ Take image of barcode.
- Input:
experiment: string with name for experiment used in microscope software
camera_id: unique ID for camera used to acquire image
file_path: filename with path to store images. If None, image is not saved
verbose: if True print debug information (Default = True)
- Output:
image: Image of barcode. Images will be used to decode barcode.
-
class Sample(ImagingSystem)¶
-
class
microscope_automation.samples.samples.
Sample
(name='Sample', well_object=None, center=[0, 0, 0], experiment=None, x_flip=1, y_flip=- 1, z_flip=1, x_correction=0, y_correction=0, z_correction=0, z_correction_x_slope=0, z_correction_y_slope=0)[source]¶ Class to describe and manipulate samples within a Well. Input:
- Output:
None
class Colony(ImagingSystem)¶
Class which describes a colony. A colony is the container object which holds cells.
-
class
microscope_automation.samples.samples.
Colony
(name='Colony', center=[0, 0, 0], well_object=None, image=True, ellipse=[0, 0, 0], meta=None, x_flip=1, y_flip=- 1, z_flip=1, x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0)[source]¶ Class to describe and manipulate colonies within a Well.
-
add_cells
(cell_objects_dict)[source]¶ Adds cells to colony.
This method will update cell line and clone information foe cells based on clone information (if available)
- Input:
cell_objects_dict: dictionary of form {‘name’: cellObject}
- Output:
none
-
execute_experiment
(experiment, camera_id, reference_object=None, file_path=None, meta_dict=None, verbose=True)[source]¶ Acquire single image using settings defined in microscope software and optionally save.
Methods calls method of container instance until container has method implemented that actually performs action.
- Input:
experiment: string with experiment name as defined within microscope software
camera_id: string with unique camera ID
reference_object: object of type sample (ImagingSystem) used to correct for xyz offset between different objectives
file_path: filename with path to save image in original format. Default=None: no saving
meta_dict: directory with additional meta data, e.g. {‘aics_well’:, ‘A1’}
focus: use autofocus (default = False)
verbose: if True print debug information (Default = True)
- Output:
image: ImageAICS object. At this moment they do not include the pixel data. Get pixel data with load_image.
-
find_cell_interactive_distance_map
(location)[source]¶ Find locations of cells to be imaged in colony and add them to colony.
- Input:
location: center of the cell in the form (x, y)
- Output:
cell_to_add: object of class Cell
-
find_cells_cell_profiler
()[source]¶ Find locations of cells to be imaged in colony and add them to colony.
- Input:
none
- Output:
none
-
find_cells_distance_map
(prefs, image)[source]¶ Find locations of cells to be imaged in colony and add them to colony.
- Input:
prefs: preferences read with module preferences with criteria for cells
image: ImageAICS object with colony
- Output:
none
-
get_cell_line
()[source]¶ Get name of cell line.
- Input:
none
- Output:
cell_line: string with name of cell line
-
get_cells
()[source]¶ Get all cells in colony.
- Input:
none
- Output:
cells: dictionary of form {‘name’: cellObject}
-
set_cell_line
(cell_line)[source]¶ Set name of cell line.
- Input:
cell_line: string with name of cell line
- Output:
none
-
set_interactive_positions
(image_data, location_list=None, app=None)[source]¶ Opens up the interactive mode and lets user select cells and return the list of coordinates selected
- Input:
image_data: The pixel data of the image of the colony - numpy array
location_list: Coordinates to be preplotted on the image
app: pyqt application object
- Output:
location_list: Returns the list of cells selected by the user
-
class Cell(ImagingSystem)¶
-
class
microscope_automation.samples.samples.
Cell
(name='Cell', center=[0, 0, 0], colony_object=None, x_flip=1, y_flip=1, z_flip=1, x_correction=1, y_correction=1, z_correction=1, z_correction_x_slope=0, z_correction_y_slope=0)[source]¶ Class to describe and manipulate cells within a colony.
-
execute_experiment
(experiment, camera_id, reference_object=None, file_path=None, meta_dict={}, verbose=True)[source]¶ Acquire single image using settings defined in microscope software and optionally save.
Methods calls method of container instance until container has method implemented that actually performs action.
- Input:
experiment: string with experiment name as defined within microscope software
camera_id: string with unique camera ID
reference_object: object of type sample (ImagingSystem) used to correct for xyz offset between different objectives
file_path: filename with path to save image in original format. Default=None: no saving
meta_dict: directory with additional meta data, e.g. {‘aics_well’:, ‘A1’}
verbose: if True print debug information (Default = True)
- Output:
image: ImageAICS object. At this moment they do not include the pixel data. Get pixel data with load_image.
-
get_cell_line
()[source]¶ Get name of cell line.
- Input:
none
- Output:
cell_line: string with name of cell line
-
set_cell_line
(cell_line)[source]¶ Set name of cell line.
- Input:
cell_line: string with name of cell line
- Output:
none
-
set_interactive_positions
(image_data, location_list=[])[source]¶ Opens up the interactive mode and lets user select objects and return the list of coordinates selected
Input: image_data: The pixel data of the image of the cell - numpy array
Output: location_list: Returns the list of objects selected by the user
-
Helper Methods¶
These helper functions are used when manually setting up samples objects is needed, such as while testing.
-
microscope_automation.samples.samples.
create_rect_tile
(n_col, n_row, x_pitch, y_pitch, z_pos=0)[source]¶ Create coordinates for rectangular tile scan.. The tiles will be centered around the current stage position.
- Input:
n_col, n_row: number of tiles in x and y
x_pitch, y_pitch: distance between tile centers in x and y
z_pos: offset in z in mum
- Output:
pos_list: list with tuples (x,y) for tile centers.
-
microscope_automation.samples.samples.
create_plate
(plate_format)[source]¶ Set up coordinates for different plate layouts for standard plates to be used with class Plate.
- Input:
plate_format: sting for format of plate (‘12’, ‘24’, ‘96’)
- Output:
- plate_layout: dictionary to describe plate with entries
name: name of plate
well_diameter: diameter of well in mum
well_names: (x,y) coordinates of well center in plate coordinates in mum. The center of well A1 = (0,0)