Skip to main content

Adaptive experimetation for psychophysics

Project description

AEPsych

AEPsych is a framework and library for adaptive experimetation in psychophysics and related domains.

Installation

AEPsych only supports python 3.10+. We recommend installing AEPsych under a virtual environment like Anaconda. Once you've created a virtual environment for AEPsych and activated it, you can install AEPsych using pip:

pip install aepsych

If you're a developer or want to use the latest features, you can install from GitHub using:

git clone https://github.com/facebookresearch/aepsych.git
cd aepsych
pip install -e .[dev]

Usage

See the code examples here.

The canonical way of using AEPsych is to launch it in server mode (you can run aepsych_server --help to see additional arguments):

aepsych_server --port 5555 --ip 0.0.0.0 --db mydatabase.db

The server accepts messages over a unix socket, and all messages are formatted using JSON. All messages have the following format:

{
     "type":<TYPE>,
     "message":<MESSAGE>,
}

There are five message types: setup, resume, ask, tell and exit (see aepsych/server/message_handlers for the full set of messages).

Setup

The setup message prepares the server for making suggestions and accepting data. The setup message can be formatted as either INI or a python dict (similar to JSON) format, and an example for psychometric threshold estimation is given in configs/single_lse_example.ini. It looks like this:

{
    "type":"setup",
    "message":{"config_str":<PASTED CONFIG STRING>}
}

After receiving a setup message, the server responds with a strategy index that can be used to resume this setup (for example, for interleaving multiple experiments).

Resume

The resume message tells the server to resume a strategy from earlier in the same run. It looks like this:

{
    "type":"resume",
    "message":{"strat_id":"0"}
}

After receiving a resume message, the server responds with the strategy index resumed.

Ask

The ask message queries the server for the next trial configuration. It looks like this:

{
    "type":"ask",
    "message":""
}

After receiving an ask message, the server responds with a configuration in JSON format, for example {"frequency":100, "intensity":0.8}

Tell

The tell message updates the server with the outcome for a trial configuration. Note that the tell does not need to match with a previously ask'd trial. For example, if you are interleaving AEPsych runs with a classical staircase, you can still feed AEPsych with the staircase data. A message looks like this:

{
    "type":"tell",
    "message":{
        "config":{
                "frequency":100,
                "intensity":0.8
            },
        "outcome":"1",
    }
}

Exit

The exit message tells the server to close the socket connection, write strats into the database and terminate current session. The message is:

{
    "type":"exit",
}

The server closes the connection.

Data export and visualization

The data is logged to a SQLite database on disk (by default, databases/default.db). The database has one table containing all experiment sessions that were run. Then, for each experiment there is a table containing all messages sent and received by the server, capable of supporting a full replay of the experiment from the server's perspective. This table can be summarized into a data frame output (docs forthcoming) and used to visualize data (docs forthcoming).

Contributing

See the CONTRIBUTING file for how to help out.

License

AEPsych licensed CC-BY-NC 4.0, as found in the LICENSE file.

Citing

The AEPsych paper is currently under review. In the meanwhile, you can cite our preprint:

Owen, L., Browder, J., Letham, B., Stocek, G., Tymms, C., & Shvartsman, M. (2021). Adaptive Nonparametric Psychophysics. http://arxiv.org/abs/2104.09549

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

aepsych-0.4.3.tar.gz (147.8 kB view details)

Uploaded Source

Built Distribution

aepsych-0.4.3-py3-none-any.whl (217.2 kB view details)

Uploaded Python 3

File details

Details for the file aepsych-0.4.3.tar.gz.

File metadata

  • Download URL: aepsych-0.4.3.tar.gz
  • Upload date:
  • Size: 147.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aepsych-0.4.3.tar.gz
Algorithm Hash digest
SHA256 caac6a8cdbc40977443874daf3b226c180c589108651d4a3eb61a3dc3006fe54
MD5 c94f3cb66e7b470bd5224cf3841ea082
BLAKE2b-256 322e87644276026fe9fd3decd1e3c78b6d97e45b7edbec4fe54811b4cce48af9

See more details on using hashes here.

Provenance

File details

Details for the file aepsych-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: aepsych-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 217.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aepsych-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 903ebf164464f0a7d8a7d0a97dc7c8fb5d2428b9588017284df7bb7a2f31d63a
MD5 b7b5d9f0e57e3cfaf8dba67fd0d22764
BLAKE2b-256 37ff284f73fd8b43f1d05eb056657f422b82662bf3c227f9dbc1ab99bcc3be8d

See more details on using hashes here.

Provenance

Supported by

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