Skip to main content

Simulator for the Cortical Labs cl API

Project description

CL SDK

This package provides an implementation of the CL API to assist with local development of applications that can run on a Cortical Labs CL1 system.

Please refer to docs.corticallabs.com for the latest documentation.

Prerequisites

This SDK requires Python 3.12 or later.

Installation

Use of a venv is recommended:

$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip3 install cl-sdk

Cortical Labs Developer Guide

This SDK is capable of running most of the Jupyter notebooks in our developer guide. Install cl-sdk as above, then:

$ git clone https://github.com/Cortical-Labs/cl-api-doc.git

From here you can open and run the *.ipynb notebooks directly in Visual Studio Code, or by installing and running Jupyter Lab:

$ pip3 install jupyterlab
$ jupyter lab cl-api-doc

Development

For working on the simulator itself:

$ pip3 install -e .

Running Tests

$ pip3 install -e '.[test]'
$ pytest

Building Documentation

$ pip3 install -e '.[test]'
$ python3 -m docs.make

Serve the built docs to view in a browser:

$ python3 -m http.server -d docs/html

User Options

Several user options can be set by defining environment variables in a .env file of your project directory.

Simulation from a recording

Spikes and samples are simulated by replaying recordings as set by the CL_SDK_REPLAY_PATH environment variable in the .env file. If this is omitted, a temporary recording with randomly generated samples and spikes will be used that is based on a Poisson distribution and the following optional environment variables:

  • CL_SDK_SAMPLE_MEAN: Mean samples value (default 170). This value will be in microvolts when multiplied by the constant "uV_per_sample_unit" in the recording attributes;
  • CL_SDK_SPIKE_PERCENTILE: Percentile threshold for sample values, above which will correspond to a spike (default 99.995);
  • CL_SDK_DURATION_SEC: Duration of the temporary recording (default 60); and
  • CL_SDK_RANDOM_SEED: Random seed (defaults to Unix time).

The starting position of the replay recording will be randomised every time cl.open() is called. This can be overriden by setting CL_SDK_REPLAY_START_OFFSET, where a value of 0 indicates the first frame of the recording.

Speed of simulation

The simulator can operate in two timing modes:

  • Based on wall clock time (default), or
  • Accelerated time.

Accelerated time mode can be enabled by setting CL_SDK_ACCELERATED_TIME=1 environment variable in the .env file. When enabled, passage of time will be decouple from the system wall clock time, enabling accelerated testing of applications.

WebSocket server

An included webSocket server can be used to stream simulated data. By default, the server is disabled. It can be enabled by setting CL_SDK_WEBSOCKET=1 environment variable in the .env file. The port used by the server can be set using the CL_SDK_WEBSOCKET_PORT environment variable (default 1025). The server will be hosted on localhost by default, but this can be changed by setting the CL_SDK_WEBSOCKET_HOST environment variable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cl_sdk-0.29.0.tar.gz (418.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cl_sdk-0.29.0-py3-none-any.whl (444.5 kB view details)

Uploaded Python 3

File details

Details for the file cl_sdk-0.29.0.tar.gz.

File metadata

  • Download URL: cl_sdk-0.29.0.tar.gz
  • Upload date:
  • Size: 418.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cl_sdk-0.29.0.tar.gz
Algorithm Hash digest
SHA256 1acbe6bb0e84c69c816a31bb78743994e8fb876e206a4b495a4114c9fc9268e3
MD5 bdffb5ad713a6dbe75258b86d84ecb74
BLAKE2b-256 1c71df572cbcc59baa7847af795201d88558a95503075963f65715294d40f83d

See more details on using hashes here.

File details

Details for the file cl_sdk-0.29.0-py3-none-any.whl.

File metadata

  • Download URL: cl_sdk-0.29.0-py3-none-any.whl
  • Upload date:
  • Size: 444.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for cl_sdk-0.29.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f4be953d611d7297b8d3464db32f95d85d5b52a566fbbf25df675e7d1df700d
MD5 21293cbfe8ebbf2cfd2a53e1a2f279d6
BLAKE2b-256 ba8e94e686e9e7d921edda614c5878bfeb7921e9e5efba7a8e778510ebedecb9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page