science_jubilee.tools.Camera#

Classes#

Well

A class representing a well of a labware.

Tool

Camera

A class representation of a Raspberry Pi camera.

Functions#

requires_active_tool(func)

Decorator to ensure that a tool cannot complete an action unless it is the

Module Contents#

class science_jubilee.tools.Camera.Well[source]#

A class representing a well of a labware.

Each Well is associated with a specific name, depth, total liquid volume, shape, diameter, x, y, and z dimension, y-dimension, as well as its coordinates and any applied offset

Returns:

A Well object with various information about the geometry of the well and its position in the labware

Return type:

Well

name: str#
depth: float#
totalLiquidVolume: float#
shape: str#
diameter: float = None#
xDimension: float = None#
yDimension: float = None#
x: float#
y: float#
z: float#
offset: Tuple[float] = None#
slot: int = None#
has_tip: bool = False#
clean_tip: bool = False#
labware_name: str = None#
property x#
Offsets the x-position of the each well with respect to the deck-slot coordinates
Returns:

The x-coordinate of the well

Return type:

float

property y#
Offsets the y-position of the each well with respect to the deck-slot coordinates
Returns:

The y-coordinate of the well

Return type:

float

property z#
Offsets the z-position of each well with respect to the deck-slot coordinates
Returns:

The z-coordinate of the well

Return type:

float

apply_offset(offset: Tuple[float])[source]#

Allows the user to offset the coordinates of the well with respect to the deck-slot coordinates

Parameters:

offset (Tuple[float]) – A tuple of floats with the new offset of the well

property top_#
Defines the top-most point of the well
Returns:

The z-coordinate of the top of the well

Return type:

float

property bottom_#
Defines the bottom-most point of the well
Returns:

The z-coordinate of the bottom of the well

Return type:

float

bottom(z: float, check=False)[source]#

Allows the user to dinamically indicate a new Z location relative to the bottom of the well.

Parameters:
  • z (float) – the distance in mm to offset the coordinates from the bottom of the well. Should be +

  • check (bool, optional) – the ‘z’ parameters can either be + or -. If negative, an assert error is raised to avoid collision with the labware. However, there might be instances of custom labware where the bottom of the well is purposely set as higher during the generation of its config .json file., defaults to False

Returns:

A Location which contains information about the new coordinates generated and the Well object

Return type:

Location

top(z: float)[source]#

Allows the user to dinamically indicate a new Z location relative to the top of the well.

Parameters:

z (float) – the distance in mm to offset the coordinates from the top of the well.Can be either + or -

Returns:

A Location which contains information about the new coordinates generated and the Well object.

Return type:

Location

__repr__()[source]#

Displayed representation of a Well object indicating its name and its coordinates

Returns:

A string representation of the name and coordinates of a well

Return type:

str

set_has_tip(value: bool)[source]#

Set the value of the has_tip attribute.

Parameters:

value (bool) – The new value for the has_tip attribute

set_clean_tip(value: bool)[source]#

Returns the value of the clean_tip attribute.

Parameters:

value (bool) – The new value for the clean_tip attribute

class science_jubilee.tools.Camera.Tool(index, name, **kwargs)[source]#
post_load()[source]#

Run any code after tool has been associated with the machine.

science_jubilee.tools.Camera.requires_active_tool(func)[source]#

Decorator to ensure that a tool cannot complete an action unless it is the current active tool.

class science_jubilee.tools.Camera.Camera(index, name)[source]#

Bases: science_jubilee.tools.Tool.Tool

A class representation of a Raspberry Pi camera.

Parameters:

Tool (class:Tool) – The base tool class

load_coefficients(path)[source]#

Loads camera matrix and distortion coefficients.

Parameters:

path (str) – Path to your camera calibration file

Returns:

A list containing your camera matrix (index 0) and distortion matrix (index 1)

Return type:

list

get_camera_indices()[source]#

Returns valid camera indices for use with OpenCV

Returns:

A list of valid camera indices

Return type:

list

get_frame(resolution=[1200, 1200], uvc=False)[source]#

Take a picture and return the image. Compensates for lens distortion using camera calibration file.

Parameters:
  • resolution (list, optional) – Camera resolution, defaults to [1200, 1200]

  • uvc (bool, optional) – True if the camera is a USB video class (UVC) camera for programmatically setting focus, defaults to False

Returns:

The captured frame

Return type:

ndarray

show_frame(frame, grid=False, save=False, save_path='fig.png')[source]#

Show a captured frame using matplotlib.

Parameters:
  • frame (ndarray) – The captured frame to show

  • grid (bool, optional) – Show grid lines, defaults to False

  • save (bool, optional) – Save to file, defaults to False

  • save_path (str, optional) – File path to save image, defaults to “fig.png”

get_show_frame()[source]#

Get and show a frame.

video_stream(camera_index=0)[source]#

Start a video stream from the camera.

Parameters:

camera_index (int, optional) – The camera index, defaults to 0

image_wells(resolution=[1200, 1200], uvc=False, wells: science_jubilee.labware.Labware.Well = None)[source]#

Move to a number of wells to take and show images.

Parameters:
  • resolution (list, optional) – Camera resolution, defaults to [1200, 1200]

  • uvc (bool, optional) – True if the camera is a USB video class (UVC) camera for programmatically setting focus, defaults to False

  • wells (Well, optional) – A list of wells to image, defaults to None

get_well_image(resolution=[1200, 1200], uvc=False, well: science_jubilee.labware.Labware.Well = None)[source]#

Move to a single well to take a picture and return the frame.

Parameters:
  • resolution (list, optional) – Camera resolution, defaults to [1200, 1200]

  • uvc (bool, optional) – True if the camera is a USB video class (UVC) camera for programmatically setting focus, defaults to False

  • well (Well, optional) – The well to image, defaults to None

Returns:

The captured frame

Return type:

ndarray

static _get_xyz(well: science_jubilee.labware.Labware.Well = None, location: Tuple[float] = None)[source]#

Get the (x,y,z) position of a well.

Parameters:
  • well (Well, optional) – The well to fetch position of, defaults to None

  • location (Tuple[float], optional) – Directly specify an (x,y,z) location, defaults to None

Raises:

ValueError – Must specify either a well or a location

Returns:

The well location

Return type:

Tuple[float, float, float]

static _get_top_bottom(well: science_jubilee.labware.Labware.Well = None)[source]#

Get the top and bottom heights of a well.

Parameters:

well (Well, optional) – The well to fetch position of, defaults to None

Returns:

The z-height of the top and bottom of the well

Return type:

Tuple[float, float]