Skip to main content

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

You can also run the server in read-only mode, which creates a temporary copy of the database to prevent modifications to the original:

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

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

Release files for aepsych 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aepsych 0.8.0
File Size Uploaded
aepsych-0.8.0.tar.gz 224.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aepsych 0.8.0
File Interpreter ABI Platform
aepsych-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 544.6 kB

Release files / aepsych-0.8.0.tar.gz

Download URL aepsych-0.8.0.tar.gz
Size 224.1 kB
Tags Source
SHA-256 checksum
How to use checksums
99e4f72c39a9799e6ad3fa5d722b6d0a3b9d5627b394cc2f66daaa146495ad84
BLAKE2b-256 checksum
How to use checksums
d13a25411b5dfe42ea8bd7aa631de75c797f004d65191569ccae3cddd3866683
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 11, 2025.

Transparency log

Release files / aepsych-0.8.0-py3-none-any.whl

Download URL aepsych-0.8.0-py3-none-any.whl
Size 320.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2204c74bc89af0da8d5ca626dc2435a68070194f0b8f82e4d00a127f25c472b1
BLAKE2b-256 checksum
How to use checksums
7fde18c6a70fb7ef31e2202c53f4d63abf452ab170f63bf8a307317a1444f530
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 11, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.5

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page