microscope_automation.samples package¶
Submodules¶
microscope_automation.samples.correct_background module¶
Correct background of microscope images. For information see: http://imagejdocu.tudor.lu/doku.php?id=howto:working:how_to_correct_background_illumination_in_brightfield_microscopy https://clouard.users.greyc.fr/Pantheon/experiments/illumination-correction/index-en.html https://en.wikipedia.org/wiki/Flat-field_correction
Created on 18 Jan 2017
@author: winfriedw
-
microscope_automation.samples.correct_background.
fixed_pattern_correction
(image, black_reference)[source]¶ Correct for fixed pattern with black reference image.
Cameras have faulty pixels that show up as a fixed pattern. To correct the image we use a reference image acquired under the same conditions as the image but with light blocked to reach the camera. We subtract the reference image from the image
- Input:
image: one channel image to be corrected
black_reference: correction image acquired with identical exposure settings but camera blocked
- Output:
corrected_image: image after correction
-
microscope_automation.samples.correct_background.
illumination_correction
(image, black_reference, illumination_reference)[source]¶ Correct for uneven illumination.
- Input:
image: one channel image to be corrected
black_reference: correction image acquired with identical exposure settings but camera blocked
illumination_reference: correction image acquired without sample (brightfield) or dye solution (fluorescence)
- Output:
corrected_image: image after correction
microscope_automation.samples.draw_plate module¶
Draw 96 Well plate. Colorcode wells based on content. Get information from yml file.
Created on Jun 28, 2016
@author: winfriedw
-
microscope_automation.samples.draw_plate.
draw_column_labels
(n_row=8, n_col=12, pitch=9)[source]¶ Draw plate wells based on content
- Input:
n_col: number of columns, labeled from 1 to n_col
pitch: distance between individual wells in mm
- Output:
none
-
microscope_automation.samples.draw_plate.
draw_label
(x=0, y=0, text='Hallo World!', align='center')[source]¶
-
microscope_automation.samples.draw_plate.
draw_legend
(ax, n_row, n_col, pitch, prefs)[source]¶ Draw legend
- Input:
n_row: number of rows, labeled alphabetically
n_col: number of columns
pitch: distance between individual wells in mm
prefs: preferences
- Output:
none
-
microscope_automation.samples.draw_plate.
draw_plate
(n_col=12, n_row=8, pitch=9, diameter=6.94, prefs=None)[source]¶ Draw plate and label wells based on content
- Input:
n_col: number of columns, labeled from 1 to n_col
n_row: number of rows, labeled alphabetically
pitch: distance between individual wells in mm
diameter: diameter of Well in mm
- Output:
none
-
microscope_automation.samples.draw_plate.
draw_row_labels
(n_row=8, pitch=9)[source]¶ Draw plate wells based on content
- Input:
n_row: number of rows, labeled alphabetically
pitch: distance between individual wells in mm
- Output:
none
-
microscope_automation.samples.draw_plate.
draw_well
(pos, diameter, color)[source]¶ Draws Well
- Input:
pos: [x,y] position of Well center in mm
diameter: diameter of Well in mm
- Output:
none
-
microscope_automation.samples.draw_plate.
draw_wells
(ax, n_col=12, n_row=8, pitch=9, diameter=6.94, prefs=None)[source]¶ Draw plate wells based on content
- Input:
n_col: number of columns, labeled from 1 to n_col
n_row: number of rows, labeled alphabetically
pitch: distance between individual wells in mm
diameter: diameter of Well in mm
- Output:
none
microscope_automation.samples.find_cells module¶
-
class
microscope_automation.samples.find_cells.
CalibrationViewer
[source]¶ Bases:
object
This class is intended to be a bookkeeper for image viewing threads. Scipy’s imshow doesn’t play nice with
-
class
microscope_automation.samples.find_cells.
CellFinder
(image, prefs, parent_colony_object)[source]¶ Bases:
object
-
adjust_image
()[source]¶ Adjust contrast, gamma, etc. Will have additional parameters for adjustment preferences.
- Input:
none
- Output:
seg: 2D numpy array of image data
-
choose_imaging_location
()[source]¶ Choose a location (or locations) to image. General outline:
if looking for smooth locations, use twofold distance map algorithm
if looking for rough locations (TBD)
convert image locations to stage coordinates
- Input:
none
- Output:
none
-
export_cells
()[source]¶ Convert the cell list into Cell objects. Add operation metadata to original image
-
filter_objects
()[source]¶ Filter objects in image to identify best colonies.
- Input:
none
- Output:
seg: 2D numpy array of image data
-
final_edge_detection
()[source]¶ Find improved edges.
- Input:
none
- Output:
seg: 2D numpy array of image data
-
find_cells
()[source]¶ Find cells in a given image. General outline:
segment colony
choose location to image
return cell information
- Input:
none
- Output:
cell_dict: dictionary of the form {‘name’: cell_object}
-
get_original_data
()[source]¶ Retrieve data from original image. Currently ImageAICS type. Will need to be converted to float and normalized between 0 and 1
- Input:
image: ImageAICS image
- Output:
seg: 2D numpy array of image data
-
improve_initial_edges
()[source]¶ Improve initial edge detection with dilation, hole filling, etc.
- Input:
none
- Output:
seg: 2D numpy array of image data
-
initial_edge_detection
()[source]¶ Initial edge detection.
- Input:
none
- Output:
seg: 2D numpy array of image data
-
static
is_outlier
(points, thresh=3.5)[source]¶ Returns a boolean array with True if points are outliers and False otherwise.
- Input:
points: An num_observations by num_dimensions array of observations
thresh: The modified z-score to use as a threshold. Observations with a modified z-score (based on the median absolute deviation) greater than this value will be classified as outliers.
- Output:
mask: A num_observations-length boolean array.
- References:
Boris Iglewicz and David Hoaglin (1993), “Volume 16: How to Detect and Handle Outliers”, The ASQC Basic References in Quality Control: Statistical Techniques, Edward F. Mykytka, Ph.D., Editor.
-
segment_image
()[source]¶ Segment a given image. General outline:
get original data
adjust image for edge detection
initial edge detection
dilation and hole filling
filtering
final edge detection
- Input:
none
- Output:
seg: segmented image
-
validate
(form_title, form_comment, pref_data, default=False)[source]¶ Function to calibrate steps of the cell finding process
- Input:
form_title: title of form to be displayed
form_comment: comment for form to be displayed
pref_data: (list) contains form fields, preference names, preference values, and (in that order)
default: checked or unchecked as default for continuing. (Default = False)
- Output:
boolean for whether to continue recursion
-
-
microscope_automation.samples.find_cells.
display_and_save
(image, name, location='/home/mattb/git/microscopeautomation/data/test_data_matthew/segmentationtest/', display=False)[source]¶
microscope_automation.samples.find_well_center module¶
Find center of well based on ImageAICS of well segment. We will generate an ImageAICS of the whole well and convolve it with the ImageAICS of the segment. All dimensions in pixels Created on Jun 18, 2016
@author: winfriedw
-
microscope_automation.samples.find_well_center.
create_edge_image
(diameter, length, r, phi, add_noise=False)[source]¶ Create ImageAICS for well edge used for alignment and test purposes.
- Input:
diameter: Well diameter in pixels
length: size of image in pixels
r: distance of image from circle center in pixels.
phi: direction of image
addNoise: add noise for test purposes. Default is False.
- Output:
im: well edge image to be used for alignment
-
microscope_automation.samples.find_well_center.
create_well_image
(diameter)[source]¶ Create mask for whole well. Using the whole well for alignment will improve accuracy on the cost of speed. We recommend to use create_edge_image if possible
- Input:
diameter: well diameter in pixels
- Return:
well_image: numpy array for well with well set to 1 and background set to 0
-
microscope_automation.samples.find_well_center.
find_well_center
(image, well_diameter, percentage, phi)[source]¶ Find center of well based on edge ImageAICS.
- Input:
image: image with well edge
well_diameter: diameter of well in pixels
percentage: percentage of whole well used for convolution. Large numbers increase accuracy, smaller speed. well_diameter*percentage/100 has to be larger than size of ImageAICS
phi: direction of image from center
- Return:
x_center, y_center: expected center of well
-
microscope_automation.samples.find_well_center.
find_well_center_fine
(image, direction, test=False)[source]¶ Find edge of well in image in selected direction.
- Input:
image: image with well edge
direction: direction to search for edge. String of form ‘-x’, ‘x’, ‘-y’, or ‘y’
test: returns 1 if True since test images may not have data (Default: False)
- Return:
edge_pos: coordinate of well edge in selected direction in pixels with origin in center of image
-
microscope_automation.samples.find_well_center.
show_debug_image
(image)[source]¶ Show ImageAICS when in debug mode.
- Input:
image: ImageAICS object to display if debug mode is turned on
- Return:
none
-
microscope_automation.samples.find_well_center.
show_debug_summary
(image, well_image, correlation, t_image, corr_x, corr_y)[source]¶ Show all images to calculate new center.
- Input:
image: microscope image of well center
well_image: synthetic image of well used for alignment
correlation: image of crosscorrelation
t_image: image after thresholding used for crosscorrelation
corr_x, corr_y: correlation peak
- Output:
none
microscope_automation.samples.interactive_location_picker_pyqtgraph module¶
-
class
microscope_automation.samples.interactive_location_picker_pyqtgraph.
ImageLocationPicker
(image=None, location_list=[], app=None, spot_size=10, spot_brush='r', spot_symbol='+', spot_pen='r')[source]¶ Bases:
object
-
flip_coordinates
(location_list)[source]¶ ZEN has the image origin in the upper left corner, QTgraph in the lower left corner. This methods transforms coordinates between the two systems.
- Input:
location_list: List of tuples (or single tuple) in the form of (x,y) coordinates to be transformed
- Output:
flipped_location_list: list with (x, y) tuples after transformation
-
-
class
microscope_automation.samples.interactive_location_picker_pyqtgraph.
KeyPressWindow
(*args, **kwargs)[source]¶ Bases:
pyqtgraph.graphicsWindows.GraphicsWindow
Creating a class to define a custom key press signal for selecting modes.
-
sigKeyPress
¶
-
-
microscope_automation.samples.interactive_location_picker_pyqtgraph.
test_ImageLocationPicker
(prefs, image_save_path, app, verbose=False)[source]¶ Test location picker on ZEN blue hardware with slide.
- Input:
prefs: path to experiment preferences image_save_path: path to directory to save test images app: object of class QtGui.QApplication
- Output:
None
microscope_automation.samples.positions_list module¶
Class to create position lists for tiling and multi-position imaging. Created on Aug 14, 2017
@author: winfriedw
-
class
microscope_automation.samples.positions_list.
CreateTilePositions
(tile_type='none', tile_number=(2, 2), tile_size=(1, 1), degrees=0)[source]¶ Bases:
object
Create position lists for tiling and multi-position imaging.
-
create_ellipse
(nx, ny)[source]¶ Return positions for ellipse with step size of one.
- Input:
nx, ny: number of tiles in x and y
- Output:
ellipse_list: list for rectangle positions, centered around zero and with step size of one
-
create_rectangle
(nx, ny)[source]¶ Return positions for rectangle with step size of one.
- Input:
nx, ny: number of tiles in x and y
- Output:
rect_list: list for rectangle positions, centered around zero and with step size of one
-
get_field_rotation
()[source]¶ Set size of tiles in x and y.
- Input:
none
- Output:
degrees: Angle the tile field is rotated counterclockwise in degrees
-
get_pos_list
(center=(0, 0, 0))[source]¶ Return list with positions.
- Input:
center: Center position for tiles as tuple (x, y, z)
- Output:
pos_list: list with tuples (x,y) for tile centers.
-
get_tile_number
()[source]¶ Return number of tiles in x and y.
- Input:
none
- Output:
tile_number: tuple with number of tiles in x and y direction
-
get_tile_size
()[source]¶ Retrieve size of tiles in x and y.
- Input:
none
- Output:
tile_size: tuple with size of tiles in x and y direction
-
get_tile_type
()[source]¶ Return type of tiling.
- Input:
none
- Output:
- tile_type: string to describe type of tiling. Allowed values:
‘none’: do not tile
‘rectangle’: tiles are arranged to form a rectangle
‘ellipse’: tiles are arranged to form an ellipse
-
rotate_pos_list
(pos_list, degrees)[source]¶ Rotate all coordinates in pos_list counterclockwise by angle degree around center = (0, 0, 0).
- Input:
pos_list: list with (x, y, z) coordinates
degrees: amount of counterclock rotation around origin in degree
- Output:
rot_list: list with (x, y, z) coordinates after rotation.
-
set_field_rotation
(degrees=0)[source]¶ Set size of tiles in x and y.
- Input:
degrees: Angle the tile field is rotated counterclockwise in degrees
- Output:
none
-
set_tile_number
(tile_number=(2, 2))[source]¶ Set number of tiles in x and y.
- Input:
tile_number: tuple with number of tiles in x and y direction
- Output:
none
-
set_tile_size
(tile_size=(1, 1))[source]¶ Set size of tiles in x and y.
- Input:
tile_size: tuple with size of tiles in x and y direction
- Output:
none
-
microscope_automation.samples.samples module¶
Classes to describe and manipulate samples Created on Jul 11, 2016
@author: winfriedw
-
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
Class for the background object associated with each plate. It will be used to do background correction.
-
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
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
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
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
-
-
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
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
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]¶ Bases:
object
-
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
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
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
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
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
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
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
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
Class to describe and manipulate samples within a Well. Input:
- Output:
None
-
class
microscope_automation.samples.samples.
Slide
(name='Slide', 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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
Class to describe and navigate slide.
-
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]¶ Bases:
microscope_automation.samples.samples.ImagingSystem
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
-
-
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)
-
microscope_automation.samples.samples.
create_plate_holder_manually
(m, prefs)[source]¶ Create plate holder manually instead of using setup_samples.
-
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.segmentation_filters module¶
-
microscope_automation.samples.segmentation_filters.
apply_filter
(filter_name, input_image, filter_values)[source]¶
-
microscope_automation.samples.segmentation_filters.
filter_by_distance
(input_image, filter_values)[source]¶ Function to filter segmented objects by their distance from the center of the image
- Input:
input_image: The image (numpy array) to the filter to be applied on
filter_values: (list) [max distance from the center, number of objects requested]
- Output:
filtered_image: Image (numpy array) after applying the filter mask
-
microscope_automation.samples.segmentation_filters.
filter_by_size
(input_image, filter_values)[source]¶ Function to filter segmented objects by their area.
- Input:
input_image: The image (numpy array) to the filter to be applied on
filter_values: (list) [minimum area, maximum area (optional)]
- Output:
filtered_image: Image (numpy array) after applying the filter mask
microscope_automation.samples.setup_samples module¶
Function to setup hardware and samples based on reference files Created on Aug 1, 2016 Split into it’s own module: 05/21/2020
@author: winfriedw
-
microscope_automation.samples.setup_samples.
add_barcode
(name, well_object, layout)[source]¶ Add barcode to well.
- Input:
name: string with name for barcode
well_object: instance of Well class from module samples
layout: preferences for plate layout
- Output:
none
-
microscope_automation.samples.setup_samples.
add_colonies
(well_object, colonies, hardware_settings)[source]¶ Add colonies from Celigo scan to well.
- Input:
well_object: instance of well_object from module samples
colonies: pandas frame with colony information. This information was extracted with CellProfiler from plate-scanner images.
hardware_settings: preferences with description of microscope components, here coordinate transformation between colonies and well
- Output:
colony_list: list with all colony objects
-
microscope_automation.samples.setup_samples.
filter_colonies
(prefs, colonies, well_dict)[source]¶ Select colonies to image based on settings in preferences file.
- Input:
prefs: preferences with selection criteria
colonies: table with colony data
well_dict: list with wells that should be considered. Well names in format ‘A1’.
- Output:
slected_colonies: subset of colonies to be imaged
-
microscope_automation.samples.setup_samples.
get_colony_data
(prefs, colony_file)[source]¶ Get data and positions of colonies.
- Input:
prefs: preferences with information about colony file
colony_file: path to .csv file with colony data.
- Output:
colonies: pandas frame with content of .csv file
-
microscope_automation.samples.setup_samples.
setup_plate
(prefs, colony_file=None, microscope_object=None, barcode=None)[source]¶ Create object of class plateholder from module sample that holds information about all colonies scanned with plate reader.
- Input:
prefs: preferences file for experiment
colony_file: path to .csv file with colony data.
microscope_object: object create by setup_microscope describing hardware components
barcode: string barcode for plate. If not provided can be read from colony file or will be requested by pop-up window.
- Output:
plate_holder_object: object that contains all wells with sample information.
microscope_automation.samples.tile_images module¶
-
microscope_automation.samples.tile_images.
tile_images
(images, method='stack', output_image=True, image_output_path=None)[source]¶ Restitch tiled images based off of location
- Input:
images: (list, ImageAICS) images to tile
method: (string) tiling method to use, currently only method is “stack”
output_image: (bool) flag to output image
image_output_path: (string) specified image output path
- Output:
img: tiled image of type ImageAICS
microscope_automation.samples.well_overview_segmentation module¶
-
class
microscope_automation.samples.well_overview_segmentation.
WellSegmentation
(image_data, colony_filters_dict=None, mode='A', canny_sigma=0.01, canny_low_threshold=0.025, remove_small_holes_area_threshold=1000)[source]¶ Bases:
object
-
get_mode_c_points
(dist_mask, threshold_min, threshold_max)[source]¶ Function to find a point at the center, edge & ridge in a colony
- Input:
dist_mask: The image with two fold distance map applied
threshold_min: The minimum percentage threshold for the distance from the edge
threshold_max: The maximum percentage threshold for the distance from the edge
- Output:
smooth_point_corrected: the location of the point
-
property
point_locations
¶
-
microscope_automation.samples.well_segmentation_refined module¶
-
class
microscope_automation.samples.well_segmentation_refined.
WellSegmentation
(image_data, colony_filters_dict=None, mode='A', canny_sigma=0.01, canny_low_threshold=0.025, remove_small_holes_area_threshold=1000)[source]¶ Bases:
object
-
create_circular_mask
(center=None, radius=None)[source]¶ To create a circular mask over an image, masking out edges of a well
- Input:
center: user-defined center of circular mask
radius: radius of circular mask
- Output:
mask: a mask with masked-out area being 0, and in-mask area being 1
-
downscale_filter_dictionary
(colony_filters_dict)[source]¶ To downscale filters from original image to processing image scale
- Input:
colony_filters_dict: dictionary of filters with colony_filters_dict[‘distFromCenter’][0] as distance from center and colony_filters_dict[‘distFromCenter’][1] as number of positions
- Output:
colony_filters_dict_corrected: corrected colony filteres dictionary with downscaling factor
-
filter_small_objects
(bw_img, area)[source]¶ To filter small objects from image
- Input:
bw_img: A binary image with objects
area: Objects smaller than this area will be filtered out
- Output:
int_img: binary image with objects smaller than specified area be filtered out
-
find_edge_position
(colony_mask)[source]¶ Function to find edge position from a colony mask
- Parameters
colony_mask – a [0, 1] image showing the segmentation of 1 colony
- Returns
edge_position: a tuple (y, x) of the selected edge position in the downsampled well overview image
-
find_edge_ridge_pair
(colony_mask, center_pos, dist_well=30.0)[source]¶ A method to find a pair of edge and ridge point in a colony that is far away from each other and the center position :param colony_mask: a binary colony mask :param center_pos: a tuple (y, x) of the center position :param dist_well: a float > 1 to indicate the size of the well that should be masked out :return:
-
find_positions
(mode='A')[source]¶ To find a position in a colony that passes the size filter, and is positioned 40% from the edge of colony, maximum in distance map that indicates preferred smoothness in region, and is close to the center of the well for good imaging practice.
- Input:
none
- Output:
none
-
find_ridge_position
(colony_mask, edge_position)[source]¶ Function to find ridge position, optimized by selecting a position in a colony furthest away from the edge position :param colony_mask: a [0, 1] image showing the segmentation of 1 colony :param edge_position: a tuple (y, x) of the selected edge position in the downsampled well overview image :return:
-
property
point_locations
¶
-
preprocessing_image
()[source]¶ To pre-process input image with correction for uneven illumination and rescaling intensity to enhance contrast
- Input:
none
- Output:
img_rescale_2: rescaled image ready for segmentation
-
process_colonies
(binary_colony_mask)[source]¶ To partition binary colony mask into separate, distinct, labelled colonies using distance map to find markers of colonies and separate connected colonies with watershed segmentation.
- Input:
binary_colony_mask: A binary image of colonies(1) and background (0)
- Output:
none
-
segment_and_find_positions
()[source]¶ Function segments out the colonies, applies filters, and finds the smooth points based on the mode
- Input:
none
- Output:
none
-
segment_colonies
(rescaled_image)[source]¶ To segment colonies from grayscale image using edge detection method to approximate location of colony edges and watershed segmentation to fill in the colonies
- Input:
rescaled_image: The rescaled image from preprocessing with enhanced contrast
- Output:
binary_colony_mask: binary image of mask of colonies(1) and background(0)
-
Module contents¶
Samples package for Microscope Automation.