electrode_board

The ‘electrode_board’ module provides support for working with board definition files.

class purpledrop.electrode_board.Board(board_def: Dict[str, Any])[source]

Represents the top-level object in an electrode board definition file

as_dict() dict[source]

Return a serializable dict representation of the board

static load_from_file(filepath)[source]

Create a Board from a board definition file

static load_from_string(data: AnyStr) purpledrop.electrode_board.Board[source]

Create a board from a JSON string in memory

class purpledrop.electrode_board.ControlPoint(grid_coord: Tuple[float, float], image_coord: Tuple[float, float])[source]

Represents a control point in an image

A control point is a pair of corresponding points – one in image coordinates and the other in grid coordinates – used to calibrate the position of the electrode grid relative to fiducials.

class purpledrop.electrode_board.Fiducial(corners: List[List[int]], label: str = '')[source]

Represents a fiducial location

class purpledrop.electrode_board.Layout(layout_def: Dict[str, Any])[source]

Represents the ‘layout’ property of a baord definition

A layout defines the placement and pin mapping for the electrodes on the board.

as_dict() dict[source]

Return a serializable dict version of the board definition

grid_location_to_pin(x: int, y: int, grid_number: int = 0)[source]

Return the pin number at given grid location, or None if no pin is defined there.

pin_polygon(pin: int) Optional[List[Tuple[int, int]]][source]

Get the polygon defining a pin in board coordinates

pin_to_grid_location(pin: int) Optional[Tuple[Tuple[int, int], int]][source]

Return the grid location of a given pin number

class purpledrop.electrode_board.Registration(data: dict)[source]

A registration is a collection of fiducials and control points which together define relationship between the electrode locations and fiducials

purpledrop.electrode_board.list_boards()[source]

Find all available board definitions.

Uses same search rules as load_board; see load_board().

Returns

A list of board names, which can be passed to load_board

purpledrop.electrode_board.load_board(name) Optional[purpledrop.electrode_board.Board][source]

Load a board definition by name or path

Attempt to load a board definition from the name, using the following priorities (the first to succeed is returned):

  1. Load as a full path

  2. Load from ~/.config/purpledrop/boards/{name}.json

  3. Load from package resources (purpledrop/boards in repo)

purpledrop.electrode_board.load_peripheral(pdata, templates=None)[source]

Load a peripheral from a dict

This loads a peripheral with support for templates, as used in the board definition file format

Parameters
  • pdata – A dict containing the peripheral definition

  • templates – A dict mapping types to template definitions