ephys_link.platform_handler

Handle communications with platform specific API

Handles relaying WebSocket messages to the appropriate platform API functions and conducting error checks on the input and output values

Function names here are the same as the WebSocket events. They are called when the server receives an event from a client. In general, each function does the following:

  1. Receive extracted arguments from ephys_link.server

  2. Call and check the appropriate platform API function (overloaded by each platform)

  3. Log/handle successes and failures

  4. Return the callback parameters to ephys_link.server

Classes

PlatformHandler

An abstract class that defines the interface for a manipulator handler.

class PlatformHandler[source]

Bases: ABC

An abstract class that defines the interface for a manipulator handler.

reset() bool[source]

Reset handler.

Returns:

True if successful, False otherwise.

Return type:

bool

stop() bool[source]

Stop handler.

Returns:

True if successful, False otherwise.

Return type:

bool

get_manipulators() GetManipulatorsOutputData[source]

Get all registered manipulators.

Returns:

Result of connected manipulators, platform information, and error message (if any).

Return type:

ephys_link.common.GetManipulatorsOutputData

register_manipulator(manipulator_id: str) str[source]

Register a manipulator.

Parameters:

manipulator_id (str) – The ID of the manipulator to register.

Returns:

Error message on error, empty string otherwise.

Return type:

str

unregister_manipulator(manipulator_id: str) str[source]

Unregister a manipulator.

Parameters:

manipulator_id (str) – The ID of the manipulator to unregister.

Returns:

Error message on error, empty string otherwise.

Return type:

str

get_pos(manipulator_id: str) PositionalOutputData[source]

Get the current position of a manipulator.

Parameters:

manipulator_id (str) – The ID of the manipulator to get the position of.

Returns:

Positional information for the manipulator and error message (if any).

Return type:

ephys_link.common.PositionalOutputData

get_angles(manipulator_id: str) AngularOutputData[source]

Get the current position of a manipulator.

Parameters:

manipulator_id (str) – The ID of the manipulator to get the angles of.

Returns:

Angular information for the manipulator and error message (if any).

Return type:

ephys_link.common.AngularOutputData

get_shank_count(manipulator_id: str) ShankCountOutputData[source]

Get the number of shanks on the probe

Parameters:

manipulator_id (str) – The ID of the manipulator to get the number of shanks of.

Returns:

Number of shanks on the probe.

Return type:

ephys_link.common.ShankCountOutputData

async goto_pos(manipulator_id: str, position: list[float], speed: float) PositionalOutputData[source]

Move manipulator to position

Parameters:
  • manipulator_id (str) – The ID of the manipulator to move

  • position (list[float]) – The position to move to in (x, y, z, w) in mm

  • speed (float) – The speed to move at (in mm/s)

Returns:

Resulting position of the manipulator and error message (if any).

Return type:

ephys_link.common.PositionalOutputData

async drive_to_depth(manipulator_id: str, depth: float, speed: float) DriveToDepthOutputData[source]

Drive manipulator to depth

Parameters:
  • manipulator_id (str) – The ID of the manipulator to drive

  • depth (float) – The depth to drive to in mm

  • speed (float) – The speed to drive at (in mm/s)

Returns:

Resulting depth of the manipulator and error message (if any).

Return type:

ephys_link.common.DriveToDepthOutputData

set_inside_brain(manipulator_id: str, inside: bool) StateOutputData[source]

Set manipulator inside brain state (restricts motion)

Parameters:
  • manipulator_id (str) – The ID of the manipulator to set the state of

  • inside (bool) – True if inside brain, False if outside

Returns:

New inside brain state of the manipulator and error message (if any).

Return type:

ephys_link.common.StateOutputData

async calibrate(manipulator_id: str, sio: socketio.AsyncServer) str[source]

Calibrate manipulator

Parameters:
  • manipulator_id (str) – ID of manipulator to calibrate

  • sio (socketio.AsyncServer) – SocketIO object (to call sleep)

Returns:

Error message on error, empty string otherwise.

Return type:

str

bypass_calibration(manipulator_id: str) str[source]

Bypass calibration of manipulator

Parameters:

manipulator_id (str) – ID of manipulator to bypass calibration

Returns:

Error message on error, empty string otherwise.

Return type:

str

set_can_write(manipulator_id: str, can_write: bool, hours: float, sio: socketio.AsyncServer) com.StateOutputData[source]

Set manipulator can_write state (enables/disabled moving manipulator)

Parameters:
  • manipulator_id (str) – The ID of the manipulator to set the state of

  • can_write (bool) – True if allowed to move, False if outside

  • hours (float) – The number of hours to allow writing (0 = forever)

  • sio (socketio.AsyncServer) – SocketIO object from server to emit reset event

Returns:

New can_write state of the manipulator and error message (if any).

Return type:

ephys_link.common.StateOutputData