find_cells

This module finds cells in an image using two classes and the following helper functions:

microscope_automation.samples.find_cells.segment(image, img_dir)[source]

FOR TESTING PURPOSES ONLY

Input:

image:

img_dir:

Output:

none

microscope_automation.samples.find_cells.segment_dir(directory, multi=True)[source]
microscope_automation.samples.find_cells.display_and_save(image, name, location='/home/mattb/git/microscopeautomation/data/test_data_matthew/segmentationtest/', display=False)[source]

class CellFinder

class microscope_automation.samples.find_cells.CellFinder(image, prefs, parent_colony_object)[source]
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

twofold_distance_map()[source]

Compute the entire distance map for a segmented colony

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

class CalibrationViewer

class microscope_automation.samples.find_cells.CalibrationViewer[source]

This class is intended to be a bookkeeper for image viewing threads. Scipy’s imshow doesn’t play nice with