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:

Callback parameters (manipulators, error)

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:

Callback parameter (Error message (on error))

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:

Callback parameters (error message (on error))

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:

Callback parameters (manipulator ID, position in (x, y, z, w) (or an empty array on error) in mm, error message)

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 position of.

Returns:

Callback parameters (manipulator ID, angles in (yaw, pitch, roll) (or an empty array on error) in degrees, error message)

Return type:

ephys_link.common.AngularOutputData

async goto_pos(manipulator_id: str, position: list[float], speed: int) 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 (int) – The speed to move at (in mm/s)

Returns:

Callback parameters (manipulator ID, position in (x, y, z, w) (or an empty array on error) in mm, error message)

Return type:

ephys_link.common.PositionalOutputData

async drive_to_depth(manipulator_id: str, depth: float, speed: int) 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 (int) – The speed to drive at (in mm/s)

Returns:

Callback parameters (manipulator ID, depth (or 0 on error) in mm, error message)

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:

Callback parameters (manipulator ID, inside, error message)

Return type:

ephys_link.common.StateOutputData

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

Calibrate manipulator

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

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

Returns:

Callback parameters (manipulator ID, error message)

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:

Callback parameters (manipulator ID, error message)

Return type:

str

set_can_write(manipulator_id: str, can_write: bool, hours: float, sio: AsyncServer) 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:

Callback parameters (manipulator ID, can_write, error message)

Return type:

ephys_link.common.StateOutputData