psyphy 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- psyphy-0.0.2/.gitignore +33 -0
- psyphy-0.0.2/LICENSE.md +21 -0
- psyphy-0.0.2/PKG-INFO +139 -0
- psyphy-0.0.2/README.md +89 -0
- psyphy-0.0.2/pyproject.toml +120 -0
- psyphy-0.0.2/src/psyphy/__init__.py +126 -0
- psyphy-0.0.2/src/psyphy/data/__init__.py +15 -0
- psyphy-0.0.2/src/psyphy/data/dataset.py +303 -0
- psyphy-0.0.2/src/psyphy/data/io.py +92 -0
- psyphy-0.0.2/src/psyphy/inference/__init__.py +39 -0
- psyphy-0.0.2/src/psyphy/inference/base.py +47 -0
- psyphy-0.0.2/src/psyphy/inference/langevin.py +89 -0
- psyphy-0.0.2/src/psyphy/inference/laplace.py +56 -0
- psyphy-0.0.2/src/psyphy/inference/map_optimizer.py +245 -0
- psyphy-0.0.2/src/psyphy/model/__init__.py +46 -0
- psyphy-0.0.2/src/psyphy/model/base.py +77 -0
- psyphy-0.0.2/src/psyphy/model/covariance_field.py +518 -0
- psyphy-0.0.2/src/psyphy/model/likelihood.py +701 -0
- psyphy-0.0.2/src/psyphy/model/noise.py +44 -0
- psyphy-0.0.2/src/psyphy/model/prior.py +215 -0
- psyphy-0.0.2/src/psyphy/model/wppm.py +531 -0
- psyphy-0.0.2/src/psyphy/posterior/__init__.py +34 -0
- psyphy-0.0.2/src/psyphy/posterior/parameter_posterior.py +87 -0
- psyphy-0.0.2/src/psyphy/posterior/posterior.py +75 -0
- psyphy-0.0.2/src/psyphy/posterior/predictive_posterior.py +287 -0
- psyphy-0.0.2/src/psyphy/trial_placement/__init__.py +38 -0
- psyphy-0.0.2/src/psyphy/trial_placement/grid.py +56 -0
- psyphy-0.0.2/src/psyphy/trial_placement/sobol.py +65 -0
- psyphy-0.0.2/src/psyphy/utils/__init__.py +19 -0
- psyphy-0.0.2/src/psyphy/utils/math.py +104 -0
- psyphy-0.0.2/tests/conftest.py +47 -0
- psyphy-0.0.2/tests/test_3stimulus_decision_rule.py +557 -0
- psyphy-0.0.2/tests/test_basis_input_domain.py +60 -0
- psyphy-0.0.2/tests/test_covariance_field.py +288 -0
- psyphy-0.0.2/tests/test_covariance_field_single_entry_point.py +404 -0
- psyphy-0.0.2/tests/test_covariance_positive_definite.py +40 -0
- psyphy-0.0.2/tests/test_embedding_dim.py +207 -0
- psyphy-0.0.2/tests/test_imports.py +18 -0
- psyphy-0.0.2/tests/test_input_dim_validation.py +38 -0
- psyphy-0.0.2/tests/test_mc_likelihood.py +908 -0
- psyphy-0.0.2/tests/test_model_api.py +242 -0
- psyphy-0.0.2/tests/test_noise_models.py +115 -0
- psyphy-0.0.2/tests/test_posteriors.py +236 -0
- psyphy-0.0.2/tests/test_rectangular_U.py +245 -0
- psyphy-0.0.2/tests/test_wishart_covariance.py +345 -0
- psyphy-0.0.2/tests/test_wppm_model_kwargs_guard.py +34 -0
psyphy-0.0.2/.gitignore
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
.pytest_cache/
|
|
4
|
+
.mypy_cache/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
*.egg-info/
|
|
8
|
+
.venv/
|
|
9
|
+
|
|
10
|
+
*.sh
|
|
11
|
+
|
|
12
|
+
# MkDocs build output and caches
|
|
13
|
+
site/
|
|
14
|
+
.cache/
|
|
15
|
+
.mkdocs-cache/
|
|
16
|
+
|
|
17
|
+
# Ignore apple macOS system files
|
|
18
|
+
.DS_Store
|
|
19
|
+
# Ignore Jupyter Notebook checkpoints
|
|
20
|
+
.ipynb_checkpoints
|
|
21
|
+
|
|
22
|
+
# Ignore VSCode settings
|
|
23
|
+
.vscode/
|
|
24
|
+
|
|
25
|
+
# common Python tooling artifacts
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
coverage.xml
|
|
29
|
+
htmlcov/
|
|
30
|
+
.env
|
|
31
|
+
env/
|
|
32
|
+
venv/
|
|
33
|
+
.python-version
|
psyphy-0.0.2/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Psyphy authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
psyphy-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: psyphy
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Adaptive Trial Placement for Psychophysical Experiments
|
|
5
|
+
Project-URL: Homepage, https://flatironinstitute.github.io/psyphy
|
|
6
|
+
Project-URL: Repository, https://github.com/flatironinstitute/psyphy
|
|
7
|
+
Project-URL: Issues, https://github.com/flatironinstitute/psyphy/issues
|
|
8
|
+
Author: Hanna Dettki, Alex Williams
|
|
9
|
+
Maintainer: Hanna Dettki
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Psyphy authors
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE.md
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Requires-Python: >=3.10
|
|
36
|
+
Requires-Dist: jax>=0.4.28
|
|
37
|
+
Requires-Dist: numpy>=1.22
|
|
38
|
+
Requires-Dist: optax>=0.2.4
|
|
39
|
+
Requires-Dist: scipy>=1.7
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: pre-commit>=3.0; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: ruff>=0.9; extra == 'dev'
|
|
45
|
+
Provides-Extra: docs
|
|
46
|
+
Requires-Dist: jupyterlab>=4.0; extra == 'docs'
|
|
47
|
+
Requires-Dist: matplotlib>=3.5; extra == 'docs'
|
|
48
|
+
Requires-Dist: seaborn>=0.13; extra == 'docs'
|
|
49
|
+
Description-Content-Type: text/markdown
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
<div align="center">
|
|
54
|
+
<picture>
|
|
55
|
+
<source srcset="docs/images/psyphy_logo_draft.png" media="(prefers-color-scheme: light)"/>
|
|
56
|
+
<source srcset="docs/images/psyphy_logo_draft.png" media="(prefers-color-scheme: dark)"/>
|
|
57
|
+
<!-- <img align="center" src="docs/assets/logo/logo_text_black.svg" alt="Inferno" width="400" style="padding-right: 10px; padding left: 10px;"/> -->
|
|
58
|
+
</picture>
|
|
59
|
+
<h3>Psychophysical Modeling and Adaptive Trial Placement</h3>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
<h4 align="center">
|
|
64
|
+
<a href="https://flatironinstitute.github.io/psyphy/#install/">Installation</a> |
|
|
65
|
+
<a href="https://flatironinstitute.github.io/psyphy/reference/">Documentation</a> |
|
|
66
|
+
<a href="https://flatironinstitute.github.io/psyphy/examples/">Examples</a> |
|
|
67
|
+
<a href="https://flatironinstitute.github.io/psyphy/CONTRIBUTING/">Contributing</a>
|
|
68
|
+
</h4>
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Install (editable)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git clone https://flatironinstitute.github.io/psyphy.git
|
|
75
|
+
cd psyphy
|
|
76
|
+
pip install -e .
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## [Quickstart](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/)
|
|
81
|
+
- Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/) for a light-weight tutorial that demonstrates how to instantiate, evaluate and fit a model quickly. You should be able to run the underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/quick_start.py) on your CPU.
|
|
82
|
+
- Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/full_wppm_fit_example/) for a more comprehensive example visualizing a spatially varying covariance field, also explaining the underlying math. The underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/full_wppm_fit_example.py) for this tutorial requires a GPU.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## This package provides:
|
|
86
|
+
|
|
87
|
+
- Wishart Process Psychophysical Model (WPPM)
|
|
88
|
+
- fit to subject's data
|
|
89
|
+
- predict psychphysical thresholds
|
|
90
|
+
- optional trial placement strategy leveraging model's posterior (e.g., information gain, place next batch of trials such that model's uncertainty is maximally reduced)
|
|
91
|
+
- Priors and noise models
|
|
92
|
+
- supports cold and warm starts where warm means initialzing with parameters from previous subjects fitted parameters
|
|
93
|
+
- Noise Model:
|
|
94
|
+
- default: Gaussian
|
|
95
|
+
- supports Student's T
|
|
96
|
+
- Task likelihoods
|
|
97
|
+
- currently supports OddityTask, TwoAFC
|
|
98
|
+
- Inference engines (MAP, Langevin, Laplace)
|
|
99
|
+
- Posterior wrappers and diagnostics
|
|
100
|
+
- Trial placement strategies (grid, information gain)
|
|
101
|
+
- supports online and batchwise trial placement
|
|
102
|
+
- Experiment session orchestration
|
|
103
|
+
- reading session data and exporting next batch of trial placments
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## Background
|
|
108
|
+
|
|
109
|
+
This package implements methods described in:
|
|
110
|
+
- [Hong et al. (2025). *Comprehensive characterization of human color discrimination thresholds*.](https://www.biorxiv.org/content/10.1101/2025.07.16.665219v1)
|
|
111
|
+
|
|
112
|
+
While the paper above used AEPsych (a Gaussian Process–based trial placer),
|
|
113
|
+
`psyphy` integrates trial placement directly with the WPPM posterior (e.g. via InfoGain/EAVC),
|
|
114
|
+
making the adaptive trial placement model-aware.
|
|
115
|
+
|
|
116
|
+
## Docs
|
|
117
|
+
|
|
118
|
+
Build and preview the documentation locally:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# from repo root
|
|
122
|
+
source .venv/bin/activate
|
|
123
|
+
pip install mkdocs mkdocs-material 'mkdocstrings[python]'
|
|
124
|
+
mkdocs serve
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Build the static site:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
mkdocs build
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Deploy to GitHub Pages (manual):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
mkdocs gh-deploy --clean
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
For contributors, see CONTRIBUTING.md for full doc guidelines and NumPy-style docstrings.
|
psyphy-0.0.2/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<picture>
|
|
5
|
+
<source srcset="docs/images/psyphy_logo_draft.png" media="(prefers-color-scheme: light)"/>
|
|
6
|
+
<source srcset="docs/images/psyphy_logo_draft.png" media="(prefers-color-scheme: dark)"/>
|
|
7
|
+
<!-- <img align="center" src="docs/assets/logo/logo_text_black.svg" alt="Inferno" width="400" style="padding-right: 10px; padding left: 10px;"/> -->
|
|
8
|
+
</picture>
|
|
9
|
+
<h3>Psychophysical Modeling and Adaptive Trial Placement</h3>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<h4 align="center">
|
|
14
|
+
<a href="https://flatironinstitute.github.io/psyphy/#install/">Installation</a> |
|
|
15
|
+
<a href="https://flatironinstitute.github.io/psyphy/reference/">Documentation</a> |
|
|
16
|
+
<a href="https://flatironinstitute.github.io/psyphy/examples/">Examples</a> |
|
|
17
|
+
<a href="https://flatironinstitute.github.io/psyphy/CONTRIBUTING/">Contributing</a>
|
|
18
|
+
</h4>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Install (editable)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://flatironinstitute.github.io/psyphy.git
|
|
25
|
+
cd psyphy
|
|
26
|
+
pip install -e .
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## [Quickstart](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/)
|
|
31
|
+
- Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/) for a light-weight tutorial that demonstrates how to instantiate, evaluate and fit a model quickly. You should be able to run the underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/quick_start.py) on your CPU.
|
|
32
|
+
- Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/full_wppm_fit_example/) for a more comprehensive example visualizing a spatially varying covariance field, also explaining the underlying math. The underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/full_wppm_fit_example.py) for this tutorial requires a GPU.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## This package provides:
|
|
36
|
+
|
|
37
|
+
- Wishart Process Psychophysical Model (WPPM)
|
|
38
|
+
- fit to subject's data
|
|
39
|
+
- predict psychphysical thresholds
|
|
40
|
+
- optional trial placement strategy leveraging model's posterior (e.g., information gain, place next batch of trials such that model's uncertainty is maximally reduced)
|
|
41
|
+
- Priors and noise models
|
|
42
|
+
- supports cold and warm starts where warm means initialzing with parameters from previous subjects fitted parameters
|
|
43
|
+
- Noise Model:
|
|
44
|
+
- default: Gaussian
|
|
45
|
+
- supports Student's T
|
|
46
|
+
- Task likelihoods
|
|
47
|
+
- currently supports OddityTask, TwoAFC
|
|
48
|
+
- Inference engines (MAP, Langevin, Laplace)
|
|
49
|
+
- Posterior wrappers and diagnostics
|
|
50
|
+
- Trial placement strategies (grid, information gain)
|
|
51
|
+
- supports online and batchwise trial placement
|
|
52
|
+
- Experiment session orchestration
|
|
53
|
+
- reading session data and exporting next batch of trial placments
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Background
|
|
58
|
+
|
|
59
|
+
This package implements methods described in:
|
|
60
|
+
- [Hong et al. (2025). *Comprehensive characterization of human color discrimination thresholds*.](https://www.biorxiv.org/content/10.1101/2025.07.16.665219v1)
|
|
61
|
+
|
|
62
|
+
While the paper above used AEPsych (a Gaussian Process–based trial placer),
|
|
63
|
+
`psyphy` integrates trial placement directly with the WPPM posterior (e.g. via InfoGain/EAVC),
|
|
64
|
+
making the adaptive trial placement model-aware.
|
|
65
|
+
|
|
66
|
+
## Docs
|
|
67
|
+
|
|
68
|
+
Build and preview the documentation locally:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# from repo root
|
|
72
|
+
source .venv/bin/activate
|
|
73
|
+
pip install mkdocs mkdocs-material 'mkdocstrings[python]'
|
|
74
|
+
mkdocs serve
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Build the static site:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
mkdocs build
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Deploy to GitHub Pages (manual):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
mkdocs gh-deploy --clean
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For contributors, see CONTRIBUTING.md for full doc guidelines and NumPy-style docstrings.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.18.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "psyphy"
|
|
7
|
+
version = "0.0.2"
|
|
8
|
+
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "Hanna Dettki" },
|
|
11
|
+
{ name = "Alex Williams" }
|
|
12
|
+
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
maintainers = [
|
|
16
|
+
{ name = "Hanna Dettki" }
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
description = "Adaptive Trial Placement for Psychophysical Experiments"
|
|
20
|
+
readme = "README.md"
|
|
21
|
+
license = {file = "LICENSE.md"}
|
|
22
|
+
requires-python = ">=3.10"
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"jax>=0.4.28",
|
|
30
|
+
"optax>=0.2.4",
|
|
31
|
+
"numpy>=1.22",
|
|
32
|
+
"scipy>=1.7",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = [
|
|
37
|
+
"pytest>=8.0",
|
|
38
|
+
"ruff>=0.9",
|
|
39
|
+
"mypy>=1.0",
|
|
40
|
+
"pre-commit>=3.0",
|
|
41
|
+
]
|
|
42
|
+
docs = [
|
|
43
|
+
"matplotlib>=3.5",
|
|
44
|
+
"seaborn>=0.13",
|
|
45
|
+
"jupyterlab>=4.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://flatironinstitute.github.io/psyphy"
|
|
50
|
+
Repository = "https://github.com/flatironinstitute/psyphy"
|
|
51
|
+
Issues = "https://github.com/flatironinstitute/psyphy/issues"
|
|
52
|
+
|
|
53
|
+
[tool.hatch.build.targets.wheel]
|
|
54
|
+
packages = ["src/psyphy"]
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.sdist]
|
|
57
|
+
include = ["src/psyphy", "README.md", "LICENSE.md", "tests"]
|
|
58
|
+
|
|
59
|
+
# Ruff configuration
|
|
60
|
+
[tool.ruff]
|
|
61
|
+
line-length = 88
|
|
62
|
+
target-version = "py39"
|
|
63
|
+
src = ["src", "tests"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint]
|
|
66
|
+
select = [
|
|
67
|
+
"E", # pycodestyle errors
|
|
68
|
+
"W", # pycodestyle warnings
|
|
69
|
+
"F", # pyflakes
|
|
70
|
+
"I", # isort (import sorting)
|
|
71
|
+
"B", # flake8-bugbear
|
|
72
|
+
"C4", # flake8-comprehensions
|
|
73
|
+
"UP", # pyupgrade
|
|
74
|
+
"SIM", # flake8-simplify
|
|
75
|
+
"NPY", # NumPy-specific rules
|
|
76
|
+
]
|
|
77
|
+
ignore = [
|
|
78
|
+
"E501", # Line too long (handled by formatter)
|
|
79
|
+
"ARG", # Unused arguments (prototyping phase)
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
[tool.ruff.lint.per-file-ignores]
|
|
83
|
+
"tests/**/*.py" = ["ARG", "S101"] # Allow unused args and asserts in tests
|
|
84
|
+
"__init__.py" = ["F401"] # Allow unused imports in __init__.py
|
|
85
|
+
"docs/**/*.py" = ["ARG", "T201"] # Allow print statements in examples
|
|
86
|
+
|
|
87
|
+
[tool.ruff.format]
|
|
88
|
+
quote-style = "double"
|
|
89
|
+
indent-style = "space"
|
|
90
|
+
docstring-code-format = true
|
|
91
|
+
|
|
92
|
+
# mypy configuration
|
|
93
|
+
[tool.mypy]
|
|
94
|
+
python_version = "3.10"
|
|
95
|
+
warn_return_any = false # Disabled for JAX compatibility
|
|
96
|
+
warn_unused_configs = true
|
|
97
|
+
disallow_untyped_defs = false
|
|
98
|
+
ignore_missing_imports = true
|
|
99
|
+
files = ["src/psyphy", "tests"]
|
|
100
|
+
exclude = [
|
|
101
|
+
"^build/",
|
|
102
|
+
"^dist/",
|
|
103
|
+
"^\\.venv/",
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
# Ignore third-party packages that have compatibility issues
|
|
107
|
+
[[tool.mypy.overrides]]
|
|
108
|
+
module = [
|
|
109
|
+
"jax.*",
|
|
110
|
+
"jaxlib.*",
|
|
111
|
+
"optax.*",
|
|
112
|
+
]
|
|
113
|
+
ignore_errors = true
|
|
114
|
+
|
|
115
|
+
# pytest configuration
|
|
116
|
+
[tool.pytest.ini_options]
|
|
117
|
+
testpaths = ["tests"]
|
|
118
|
+
python_files = ["test_*.py"]
|
|
119
|
+
python_classes = ["Test*"]
|
|
120
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""
|
|
2
|
+
psyphy
|
|
3
|
+
======
|
|
4
|
+
|
|
5
|
+
Psychophysical modeling and adaptive trial placement.
|
|
6
|
+
|
|
7
|
+
This package implements the Wishart Process Psychophysical Model (WPPM)
|
|
8
|
+
with modular components for priors, task likelihoods, and noise models,
|
|
9
|
+
which can be fitted to incoming subject data and used to adaptively
|
|
10
|
+
select new trials to present to the subject next.
|
|
11
|
+
This is useful for efficiently estimating psychophysical parameters
|
|
12
|
+
(e.g. threshold contours) with minimal trials.
|
|
13
|
+
|
|
14
|
+
----------------------------------------------------------------------
|
|
15
|
+
Workflow
|
|
16
|
+
----------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
Core design
|
|
19
|
+
-----------
|
|
20
|
+
1. WPPM (model/wppm.py):
|
|
21
|
+
- Structural definition of the psychophysical model.
|
|
22
|
+
- Maintains parameterization of local covariance fields.
|
|
23
|
+
- Computes discriminability between stimuli.
|
|
24
|
+
- Delegates trial likelihoods and predictions to the task.
|
|
25
|
+
|
|
26
|
+
2. Prior (model/prior.py):
|
|
27
|
+
- Defines the distribution over model parameters.
|
|
28
|
+
- WPPM: structured prior over basis weights and
|
|
29
|
+
decay_rate-controlled covariance fields.
|
|
30
|
+
|
|
31
|
+
3. TaskLikelihood (model/likelihood.py):
|
|
32
|
+
- Encodes the psychophysical decision rule.
|
|
33
|
+
- WPPM: loglik and predict implemented via Monte Carlo
|
|
34
|
+
observer simulations, using the noise model explicitly.
|
|
35
|
+
|
|
36
|
+
4. NoiseModel (model/noise.py):
|
|
37
|
+
- Defines the distribution of internal representation noise.
|
|
38
|
+
- WPPM: GaussianNoise or StudentTNoise option.
|
|
39
|
+
|
|
40
|
+
Unified import style
|
|
41
|
+
--------------------
|
|
42
|
+
Top-level (core models + session):
|
|
43
|
+
from psyphy import WPPM, Prior, OddityTask, GaussianNoise, MAPOptimizer
|
|
44
|
+
from psyphy import ExperimentSession, ResponseData, TrialBatch
|
|
45
|
+
|
|
46
|
+
Subpackages:
|
|
47
|
+
from psyphy.model import WPPM, Prior, OddityTask, GaussianNoise, StudentTNoise
|
|
48
|
+
from psyphy.inference import MAPOptimizer, LangevinSampler, LaplaceApproximation
|
|
49
|
+
from psyphy.acquisition import expected_improvement, upper_confidence_bound, mutual_information
|
|
50
|
+
from psyphy.acquisition import optimize_acqf, optimize_acqf_discrete, optimize_acqf_random
|
|
51
|
+
from psyphy.trial_placement import GridPlacement, SobolPlacement
|
|
52
|
+
from psyphy.utils import grid_candidates, sobol_candidates, custom_candidates, chebyshev_basis
|
|
53
|
+
|
|
54
|
+
Data flow
|
|
55
|
+
---------
|
|
56
|
+
- A ResponseData object (psyphy.data) contains trial stimuli and responses.
|
|
57
|
+
- WPPM.init_params(prior) samples parameter initialization.
|
|
58
|
+
- Inference engines optimize the log posterior:
|
|
59
|
+
log_posterior = task.loglik(params, data, model=WPPM, noise=NoiseModel)
|
|
60
|
+
+ prior.log_prob(params)
|
|
61
|
+
- Posterior predictions (p(correct), threshold ellipses) are always obtained
|
|
62
|
+
through WPPM delegating to TaskLikelihood.
|
|
63
|
+
|
|
64
|
+
Extensibility
|
|
65
|
+
-------------
|
|
66
|
+
- To add a new task: subclass TaskLikelihood, implement predict/loglik.
|
|
67
|
+
- To add a new noise model: subclass NoiseModel, implement logpdf/sample.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
----------------------------------------------------------------------
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
# Data
|
|
75
|
+
# Re-export subpackages for unified import style (e.g., psyphy.model, psyphy.inference)
|
|
76
|
+
# from . import acquisition as acquisition
|
|
77
|
+
from . import data as data
|
|
78
|
+
from . import inference as inference
|
|
79
|
+
from . import model as model
|
|
80
|
+
from . import posterior as posterior
|
|
81
|
+
|
|
82
|
+
# from . import session as session
|
|
83
|
+
from . import trial_placement as trial_placement
|
|
84
|
+
from . import utils as utils
|
|
85
|
+
from .data.dataset import ResponseData, TrialBatch
|
|
86
|
+
from .inference.langevin import LangevinSampler
|
|
87
|
+
from .inference.laplace import LaplaceApproximation
|
|
88
|
+
|
|
89
|
+
# Inference
|
|
90
|
+
from .inference.map_optimizer import MAPOptimizer
|
|
91
|
+
from .model.likelihood import OddityTask, OddityTaskConfig
|
|
92
|
+
from .model.noise import GaussianNoise, StudentTNoise
|
|
93
|
+
from .model.prior import Prior
|
|
94
|
+
from .model.wppm import WPPM
|
|
95
|
+
|
|
96
|
+
# Posterior
|
|
97
|
+
from .posterior.parameter_posterior import ParameterPosterior
|
|
98
|
+
from .posterior.posterior import MAPPosterior
|
|
99
|
+
from .posterior.predictive_posterior import PredictivePosterior, WPPMPredictivePosterior
|
|
100
|
+
|
|
101
|
+
# Experiment orchestration
|
|
102
|
+
# from .session.experiment_session import ExperimentSession
|
|
103
|
+
|
|
104
|
+
__all__ = [
|
|
105
|
+
# Core model
|
|
106
|
+
"WPPM", # needs task for likelihood and noise model
|
|
107
|
+
"Prior",
|
|
108
|
+
"OddityTask",
|
|
109
|
+
"OddityTaskConfig",
|
|
110
|
+
"GaussianNoise", # default noise model
|
|
111
|
+
"StudentTNoise",
|
|
112
|
+
# Inference
|
|
113
|
+
"MAPOptimizer",
|
|
114
|
+
"LangevinSampler",
|
|
115
|
+
"LaplaceApproximation",
|
|
116
|
+
# Data handling
|
|
117
|
+
"ResponseData",
|
|
118
|
+
"TrialBatch",
|
|
119
|
+
# Subpackages
|
|
120
|
+
"model",
|
|
121
|
+
"inference",
|
|
122
|
+
"posterior",
|
|
123
|
+
"trial_placement",
|
|
124
|
+
"utils",
|
|
125
|
+
"data",
|
|
126
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
psyphy.data
|
|
3
|
+
==========
|
|
4
|
+
|
|
5
|
+
submodule for handling psychophysical experiment data.
|
|
6
|
+
|
|
7
|
+
Includes:
|
|
8
|
+
- dataset: ResponseData, TrialBatch, loaders
|
|
9
|
+
- transforms: color/model space conversions
|
|
10
|
+
- io: save/load datasets
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .dataset import ResponseData, TrialBatch, TrialData
|
|
14
|
+
|
|
15
|
+
__all__ = ["ResponseData", "TrialBatch", "TrialData"]
|