Data¶
Package¶
data
¶
psyphy.data¶
submodule for handling psychophysical experiment data.
Includes: - dataset: ResponseData, TrialBatch, loaders - transforms: color/model space conversions - io: save/load datasets - published: loaders for published third-party datasets (downloaded on request)
Classes:
| Name | Description |
|---|---|
ResponseData |
Python-friendly incremental trial log. |
TrialBatch |
Container for a proposed batch of trials. |
TrialData |
Batched trial data for compute. |
ResponseData
¶
Python-friendly incremental trial log.
This container is convenient for adaptive trial placement and I/O (e.g., CSV), but it is not a compute-efficient representation for JAX.
Use :class:TrialData for model fitting and likelihood evaluation.
Methods:
| Name | Description |
|---|---|
add_batch |
Append responses for a batch of trials. |
add_trial |
append a single trial. |
copy |
Create a deep copy of this dataset. |
from_arrays |
Construct ResponseData from arrays. |
from_trial_data |
Build a ResponseData log from a :class: |
merge |
Merge another dataset into this one (in-place). |
tail |
Return last n trials as a new ResponseData. |
to_numpy |
Return stimuli and responses as NumPy arrays. |
to_trial_data |
Convert this log into the canonical JAX batch (:class: |
Attributes:
| Name | Type | Description |
|---|---|---|
contexts |
list[ndarray]
|
|
responses |
list[ndarray]
|
|
stim_shape |
tuple | None
|
|
stimuli |
list[ndarray]
|
|
trials |
list[tuple[Any, ...]]
|
Return list of (stim1, stim2, ... , response) tuples. |
Source code in src/psyphy/data/dataset.py
trials
¶
add_batch
¶
add_batch(responses: list[Any], trial_batch: TrialBatch, contexts: list[Any] | None = None) -> None
Append responses for a batch of trials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
responses
|
List[Any]
|
Responses corresponding to each stimulus group in the trial batch. |
required |
trial_batch
|
TrialBatch
|
The batch of proposed trials. |
required |
Source code in src/psyphy/data/dataset.py
add_trial
¶
append a single trial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
tuple(Any, ...)
|
Group of presented stimuli each represented in any format (numpy array, list, etc.) Input must contain appropriate number of stimuli of appropriate dimension. |
required |
resp
|
Any
|
Subject response |
required |
Source code in src/psyphy/data/dataset.py
copy
¶
copy() -> ResponseData
Create a deep copy of this dataset.
Returns:
| Type | Description |
|---|---|
ResponseData
|
New dataset with copied data |
Source code in src/psyphy/data/dataset.py
from_arrays
¶
from_arrays(X: ndarray | ndarray, y: ndarray | ndarray, c: ndarray | ndarray | None = None) -> ResponseData
Construct ResponseData from arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
(array, shape(n_trials, n_stimuli, input_dim) or (n_trials, input_dim))
|
Stimuli. If 3D, second axis is input stumili. For OddityTask, this is (ref, comparison) |
required |
y
|
(array, shape(n_trials, response_dim))
|
Responses |
required |
c
|
optional array, shape (n_trials, context_dim)
|
Context |
None
|
Returns:
| Type | Description |
|---|---|
ResponseData
|
Data container |
OddityTask Example
From paired stimuli¶
X = jnp.array([[[0, 0], [1, 0]], [[1, 1], [2, 1]]])
X is formed from refs = [[0, 0], [1, 1]], comparisons = [[1, 0], [2, 1]]¶
y = jnp.array([1, 0]) data = ResponseData.from_arrays(X, y)
Source code in src/psyphy/data/dataset.py
from_trial_data
¶
from_trial_data(data: TrialData) -> ResponseData
Build a ResponseData log from a :class:TrialData batch.
Source code in src/psyphy/data/dataset.py
merge
¶
merge(other: ResponseData) -> None
Merge another dataset into this one (in-place).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
ResponseData
|
Dataset to merge |
required |
Source code in src/psyphy/data/dataset.py
tail
¶
tail(n: int) -> ResponseData
Return last n trials as a new ResponseData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of trials to keep |
required |
Returns:
| Type | Description |
|---|---|
ResponseData
|
New dataset with last n trials |
Source code in src/psyphy/data/dataset.py
to_numpy
¶
to_numpy() -> tuple[ndarray, ndarray]
Return stimuli and responses as NumPy arrays. Will NOT include contexts by default. Output always fixed length of 2.
Source code in src/psyphy/data/dataset.py
to_trial_data
¶
to_trial_data() -> TrialData
Convert this log into the canonical JAX batch (:class:TrialData).
Source code in src/psyphy/data/dataset.py
TrialBatch
¶
Container for a proposed batch of trials. Does NOT include context or responses.
Attributes:
| Name | Type | Description |
|---|---|---|
stimuli |
List[Tuple[Any, ...]]
|
Each trial is a tuple of all presented stimuli (stim1, stim2, ...). For OddityTask this is (reference, comparison) |
Methods:
| Name | Description |
|---|---|
from_stimuli |
Construct a TrialBatch from a list of stimuli (stim1, stim2, ...) groups. |
Source code in src/psyphy/data/dataset.py
from_stimuli
¶
from_stimuli(groups: list[tuple[Any, ...]]) -> TrialBatch
Construct a TrialBatch from a list of stimuli (stim1, stim2, ...) groups.
TrialData
¶
TrialData(stimuli: ndarray, responses: ndarray, context: ndarray | None = None, stimulus_names: tuple[str, ...] = ())
Batched trial data for compute.
This is the canonical, compute-efficient representation of observed trials.
Shapes
stimuli : (N, K, d) responses : (N, R) context : optional (N, C)
Dimension key
N : number of trials (batch dimension) K : number of stimuli per trial (e.g. K=2 for a two-alternative task; K=2 for the oddity task, where the reference is presented twice but only the unique mean is stored — the duplication is encoded in the task likelihood, not here) d : dimensionality of each stimulus coordinate R : number of response channels (R=1 for binary; R=2 for e.g. (choice, RT)) C : number of context channels (observer-state covariates that condition the likelihood but are not part of the stimulus space, e.g. fatigue level)
Notes
- You can also think of this as a more generic ML-style dataset
Xwith shape (N, K, d) plusywith shape (N, R). - This is intended to be JAX-friendly (PyTree of arrays) so likelihood and inference code can be JIT-compiled without touching Python containers.
- Context is optional. No current inbuilt uses.
Methods:
| Name | Description |
|---|---|
stimulus |
Return stimuli[:, k, :] for the slot named |
Attributes:
| Name | Type | Description |
|---|---|---|
context |
ndarray | None
|
|
num_trials |
int
|
Number of trials (N). |
responses |
ndarray
|
|
stimuli |
ndarray
|
|
stimulus_names |
tuple[str, ...]
|
|
stimulus
¶
stimulus(name: str) -> ndarray
Return stimuli[:, k, :] for the slot named name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Must match one of the entries in |
required |
Returns:
| Type | Description |
|---|---|
(ndarray, shape(N, d))
|
Stimulus coordinates for all trials at the named slot. |
Source code in src/psyphy/data/dataset.py
Data Containers for Response Data and Proposed Next Trials¶
dataset
¶
dataset.py
Core data containers for psyphy.
defines: - ResponseData: container for psychophysical trial data - TrialBatch: container for a proposed batch of trials
Notes
- Data is stored in standard NumPy (mutable!) arrays or Python lists.
- Use numpy for I/O and analysis.
- Convert to jax.numpy (jnp) (immutable!) arrays only when passing into WPPM or inference engines that require JAX/Optax.
Classes:
| Name | Description |
|---|---|
ResponseData |
Python-friendly incremental trial log. |
TrialBatch |
Container for a proposed batch of trials. |
TrialData |
Batched trial data for compute. |
ResponseData
¶
Python-friendly incremental trial log.
This container is convenient for adaptive trial placement and I/O (e.g., CSV), but it is not a compute-efficient representation for JAX.
Use :class:TrialData for model fitting and likelihood evaluation.
Methods:
| Name | Description |
|---|---|
add_batch |
Append responses for a batch of trials. |
add_trial |
append a single trial. |
copy |
Create a deep copy of this dataset. |
from_arrays |
Construct ResponseData from arrays. |
from_trial_data |
Build a ResponseData log from a :class: |
merge |
Merge another dataset into this one (in-place). |
tail |
Return last n trials as a new ResponseData. |
to_numpy |
Return stimuli and responses as NumPy arrays. |
to_trial_data |
Convert this log into the canonical JAX batch (:class: |
Attributes:
| Name | Type | Description |
|---|---|---|
contexts |
list[ndarray]
|
|
responses |
list[ndarray]
|
|
stim_shape |
tuple | None
|
|
stimuli |
list[ndarray]
|
|
trials |
list[tuple[Any, ...]]
|
Return list of (stim1, stim2, ... , response) tuples. |
Source code in src/psyphy/data/dataset.py
trials
¶
add_batch
¶
add_batch(responses: list[Any], trial_batch: TrialBatch, contexts: list[Any] | None = None) -> None
Append responses for a batch of trials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
responses
|
List[Any]
|
Responses corresponding to each stimulus group in the trial batch. |
required |
trial_batch
|
TrialBatch
|
The batch of proposed trials. |
required |
Source code in src/psyphy/data/dataset.py
add_trial
¶
append a single trial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
tuple(Any, ...)
|
Group of presented stimuli each represented in any format (numpy array, list, etc.) Input must contain appropriate number of stimuli of appropriate dimension. |
required |
resp
|
Any
|
Subject response |
required |
Source code in src/psyphy/data/dataset.py
copy
¶
copy() -> ResponseData
Create a deep copy of this dataset.
Returns:
| Type | Description |
|---|---|
ResponseData
|
New dataset with copied data |
Source code in src/psyphy/data/dataset.py
from_arrays
¶
from_arrays(X: ndarray | ndarray, y: ndarray | ndarray, c: ndarray | ndarray | None = None) -> ResponseData
Construct ResponseData from arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
(array, shape(n_trials, n_stimuli, input_dim) or (n_trials, input_dim))
|
Stimuli. If 3D, second axis is input stumili. For OddityTask, this is (ref, comparison) |
required |
y
|
(array, shape(n_trials, response_dim))
|
Responses |
required |
c
|
optional array, shape (n_trials, context_dim)
|
Context |
None
|
Returns:
| Type | Description |
|---|---|
ResponseData
|
Data container |
OddityTask Example
From paired stimuli¶
X = jnp.array([[[0, 0], [1, 0]], [[1, 1], [2, 1]]])
X is formed from refs = [[0, 0], [1, 1]], comparisons = [[1, 0], [2, 1]]¶
y = jnp.array([1, 0]) data = ResponseData.from_arrays(X, y)
Source code in src/psyphy/data/dataset.py
from_trial_data
¶
from_trial_data(data: TrialData) -> ResponseData
Build a ResponseData log from a :class:TrialData batch.
Source code in src/psyphy/data/dataset.py
merge
¶
merge(other: ResponseData) -> None
Merge another dataset into this one (in-place).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
ResponseData
|
Dataset to merge |
required |
Source code in src/psyphy/data/dataset.py
tail
¶
tail(n: int) -> ResponseData
Return last n trials as a new ResponseData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of trials to keep |
required |
Returns:
| Type | Description |
|---|---|
ResponseData
|
New dataset with last n trials |
Source code in src/psyphy/data/dataset.py
to_numpy
¶
to_numpy() -> tuple[ndarray, ndarray]
Return stimuli and responses as NumPy arrays. Will NOT include contexts by default. Output always fixed length of 2.
Source code in src/psyphy/data/dataset.py
to_trial_data
¶
to_trial_data() -> TrialData
Convert this log into the canonical JAX batch (:class:TrialData).
Source code in src/psyphy/data/dataset.py
TrialBatch
¶
Container for a proposed batch of trials. Does NOT include context or responses.
Attributes:
| Name | Type | Description |
|---|---|---|
stimuli |
List[Tuple[Any, ...]]
|
Each trial is a tuple of all presented stimuli (stim1, stim2, ...). For OddityTask this is (reference, comparison) |
Methods:
| Name | Description |
|---|---|
from_stimuli |
Construct a TrialBatch from a list of stimuli (stim1, stim2, ...) groups. |
Source code in src/psyphy/data/dataset.py
from_stimuli
¶
from_stimuli(groups: list[tuple[Any, ...]]) -> TrialBatch
Construct a TrialBatch from a list of stimuli (stim1, stim2, ...) groups.
TrialData
¶
TrialData(stimuli: ndarray, responses: ndarray, context: ndarray | None = None, stimulus_names: tuple[str, ...] = ())
Batched trial data for compute.
This is the canonical, compute-efficient representation of observed trials.
Shapes
stimuli : (N, K, d) responses : (N, R) context : optional (N, C)
Dimension key
N : number of trials (batch dimension) K : number of stimuli per trial (e.g. K=2 for a two-alternative task; K=2 for the oddity task, where the reference is presented twice but only the unique mean is stored — the duplication is encoded in the task likelihood, not here) d : dimensionality of each stimulus coordinate R : number of response channels (R=1 for binary; R=2 for e.g. (choice, RT)) C : number of context channels (observer-state covariates that condition the likelihood but are not part of the stimulus space, e.g. fatigue level)
Notes
- You can also think of this as a more generic ML-style dataset
Xwith shape (N, K, d) plusywith shape (N, R). - This is intended to be JAX-friendly (PyTree of arrays) so likelihood and inference code can be JIT-compiled without touching Python containers.
- Context is optional. No current inbuilt uses.
Methods:
| Name | Description |
|---|---|
stimulus |
Return stimuli[:, k, :] for the slot named |
Attributes:
| Name | Type | Description |
|---|---|---|
context |
ndarray | None
|
|
num_trials |
int
|
Number of trials (N). |
responses |
ndarray
|
|
stimuli |
ndarray
|
|
stimulus_names |
tuple[str, ...]
|
|
stimulus
¶
stimulus(name: str) -> ndarray
Return stimuli[:, k, :] for the slot named name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Must match one of the entries in |
required |
Returns:
| Type | Description |
|---|---|
(ndarray, shape(N, d))
|
Stimulus coordinates for all trials at the named slot. |
Source code in src/psyphy/data/dataset.py
I/O¶
io
¶
io.py
I/O utilities for saving and loading psyphy data.
Supports: - CSV for human-readable trial logs
Notes
- Data is stored in NumPy arrays (via ResponseData.to_numpy()).
- Convert to jax.numpy when passing into models.
Functions:
| Name | Description |
|---|---|
load_posterior |
Load a Posterior object from pickle. |
load_responses_csv |
Load ResponseData from a CSV file. |
save_posterior |
Save a Posterior object to disk using pickle. |
save_responses_csv |
Save ResponseData to a CSV file. This is completely task agnostic. In the |
Attributes:
| Name | Type | Description |
|---|---|---|
PathLike |
|
load_posterior
¶
load_responses_csv
¶
Load ResponseData from a CSV file. Currently catering to OddityTask data format ONLY.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Must be of expected format for OddityTask. |
required |
Returns:
| Type | Description |
|---|---|
ResponseData
|
|
Source code in src/psyphy/data/io.py
save_posterior
¶
save_responses_csv
¶
save_responses_csv(data: TrialData | ResponseData, path: PathLike) -> None
Save ResponseData to a CSV file. This is completely task agnostic. In the current implementation, it will simply create as many stimulus columns as inputs in the data and will label them "stimulus 1", "stimulus 2", etc. The response column will be labeled "response"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ResponseData
|
|
required |
path
|
str or Path
|
|
required |
Source code in src/psyphy/data/io.py
Published Datasets¶
published
¶
psyphy.data.published¶
Loaders for published third-party psychophysical datasets.
These are datasets released alongside papers, used to validate psyphy against
results obtained independently. This is distinct from :mod:psyphy.data.dataset,
which provides the containers your own experiment data lives in.
psyphy ships no data. Each submodule exposes a fetch function that downloads
on request into a user cache directory (see hong2025.default_data_dir), and
loaders that return psyphy objects such as
:class:~psyphy.data.dataset.TrialData.
Available datasets
- :mod:
~psyphy.data.published.hong2025— human color discrimination, 8 observers, Wishart process fits. Hong et al. (2026), eLife 14:RP108943.
Examples:
hong2025
¶
hong2025.py
Loaders for the published human colour-discrimination dataset of Hong et al.
1 2 3 4 | |
Hong et al 2025 fitted a Wishart Process Psychophysical Model to eight observers and published both the trial-level data and the fitted Chebyshev weights.
Data availability
Hosted on OSF node k27js (https://osf.io/k27js). psyphy ships no data.
:func:fetch downloads on request into a user cache directory. At the time of
writing the OSF node carries no explicit license, so please always cite paper!
Typical use
from psyphy.data.published import hong2025 paths = hong2025.fetch(subject=1) # doctest: +SKIP data = hong2025.load_trials(paths["trials"]) # doctest: +SKIP W_org = hong2025.load_reference_W(paths["weights"]) # doctest: +SKIP
Coordinate convention
All stimulus coordinates are in the paper's 2-D "W space" and already lie in the Chebyshev domain [-1, 1]. No normalisation is applied or needed.
See also
docs/examples/wppm/hong2025_reproduction.md for the end-to-end walkthrough.
Functions:
| Name | Description |
|---|---|
build_paper_model |
Build a :class: |
default_data_dir |
Return the directory :func: |
fetch |
Download one observer's files from OSF node |
fetch_calibration_matrix |
Download the 2-D W space -> RGB transformation matrix from OSF. |
load_calibration_matrix |
Load a 3x3 transformation matrix CSV. |
load_reference_W |
Load published Chebyshev weights from |
load_sigma_table |
Load a published covariance table. |
load_trials |
Load |
w2d_to_rgb |
Convert 2-D W space coordinates to linear monitor RGB. |
Attributes:
| Name | Type | Description |
|---|---|---|
CALIBRATION_DATE |
|
|
PAPER_HYPERPARAMS |
Mapping[str, Any]
|
|
SUBJECT_INITIALS |
Mapping[int, str]
|
|
PAPER_HYPERPARAMS
¶
PAPER_HYPERPARAMS: Mapping[str, Any] = {'basis_degree': 4, 'input_dim': 2, 'extra_dims': 1, 'variance_scale': 0.0003, 'decay_rate': 0.4, 'diag_term': 0.0, 'mc_samples': 2000, 'bandwidth': 0.005, 'learning_rate': 0.0001, 'momentum': 0.2, 'total_steps': 1500, 'n_restarts': 1, 'target_pC': 0.667}
SUBJECT_INITIALS
¶
SUBJECT_INITIALS: Mapping[int, str] = {1: 'CH', 2: 'ME', 4: 'SG', 6: 'DK', 7: 'BH', 8: 'FM', 10: 'HG', 11: 'FW'}
build_paper_model
¶
Build a :class:~psyphy.model.wppm.WPPM configured as in the paper.
Every setting comes from :data:PAPER_HYPERPARAMS, itself a transcription
of ellipsoids/fit/fit_4d_human.py SECTION 4. Keeping it here rather than
in the example script gives the tutorial and the regression test a single
source of truth for the paper-to-psyphy mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mc_samples
|
int
|
Monte Carlo samples per trial in the oddity likelihood. Defaults to the paper's 2000, which is expensive; lower it for quick runs. |
None
|
bandwidth
|
float
|
Logistic smoothing bandwidth. Defaults to the paper's 5e-3. |
None
|
Returns:
| Type | Description |
|---|---|
WPPM
|
Ready to fit, or to wrap in a
:class: |
Notes
Imported lazily so that psyphy.data does not depend on psyphy.model
at import time.
Source code in src/psyphy/data/published/hong2025.py
default_data_dir
¶
default_data_dir() -> Path
Return the directory :func:fetch downloads into.
$PSYPHY_DATA_HOME if set, otherwise ~/.cache/psyphy/hong2025.
Deliberately outside the repository so downloaded data is never staged for
commit.
Source code in src/psyphy/data/published/hong2025.py
fetch
¶
fetch(subject: int = 1, data_dir: str | Path | None = None, *, noise_ellipses: bool = False, verbose: bool = True) -> dict[str, Path]
Download one observer's files from OSF node k27js.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
int
|
Observer number. See :data: |
1
|
data_dir
|
str or Path
|
Destination root. Defaults to :func: |
None
|
noise_ellipses
|
bool
|
Also fetch |
False
|
verbose
|
bool
|
Print progress. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Path]
|
Keys |
Notes
Requires network access; nothing else in this module does. Files already present at the expected size are skipped, so repeated calls are cheap.
Source code in src/psyphy/data/published/hong2025.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
fetch_calibration_matrix
¶
fetch_calibration_matrix(data_dir: str | Path | None = None, *, file_date: str = CALIBRATION_DATE, verbose: bool = True) -> Path
Download the 2-D W space -> RGB transformation matrix from OSF.
Separate from :func:fetch because this file is not per-subject and does
not live under the same OSF folder: it sits in
Calibration and transformation/Transformation matrices/, alongside the
monitor colorimetry matrices, and one copy serves every observer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_dir
|
str or Path
|
Destination root. Defaults to :func: |
None
|
file_date
|
str
|
Calibration date stamp embedded in the filename. |
:data:`CALIBRATION_DATE`
|
verbose
|
bool
|
Print progress. |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
Local path to |
See Also
load_calibration_matrix : read the downloaded file. w2d_to_rgb : apply it.
Source code in src/psyphy/data/published/hong2025.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
load_calibration_matrix
¶
Load a 3x3 transformation matrix CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to a |
required |
Returns:
| Type | Description |
|---|---|
(ndarray, shape(3, 3))
|
The matrix, oriented to be applied to column vectors from the left, exactly as stored. |
Notes
Header-less, comma-delimited, three rows. The OSF folder's own README
documents np.loadtxt as the intended reader.
Source code in src/psyphy/data/published/hong2025.py
load_reference_W
¶
Load published Chebyshev weights from Bestfit_W_sub{N}.csv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the best-fit weights CSV (the |
required |
column
|
str
|
Which fit to read. |
"W_org"
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Shape (5, 5, 2, 3) — exactly psyphy's |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the index column is malformed, the requested column is absent, index keys are duplicated, or the table is not dense. |
Notes
Enable jax_enable_x64 before calling if you intend to compare against
published covariances; in float32 the agreement floors around 1e-7.
Source code in src/psyphy/data/published/hong2025.py
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | |
load_sigma_table
¶
Load a published covariance table.
Handles both Thres_ellipses_sub{N}.csv (49 rows, the 7x7 reference grid,
66.7%-correct threshold covariances) and Noise_ellipses_sub{N}.csv
(10 609 rows, a 103x103 grid, model noise covariances). They share a layout:
one row per reference location, a first column holding the coordinate as
"x,y", then one column per fit holding a 2x2 matrix as
"[[a,b],[c,d]]".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to either ellipse CSV. |
required |
value_column
|
str
|
Which fit to read. Defaults to the file's main fit — whichever
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
coords |
(ndarray, shape(M, 2))
|
Reference locations in W space. |
Sigmas |
(ndarray, shape(M, 2, 2))
|
Covariance matrix at each location. |
Notes
Because every row carries its own coordinate, the row/column ordering
ambiguity that affects the published .pkl files — which store bare
(7, 7, 2, 2) arrays with no coordinates attached — does not arise here.
Source code in src/psyphy/data/published/hong2025.py
load_trials
¶
load_trials(path: str | Path, *, trial_types: Sequence[str] | None = FIT_TRIAL_TYPES, max_trials: int | None = None, seed: int = 0) -> TrialData
Load trial_data_pooled_by_type_sub{N}.csv into a :class:TrialData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the pooled trial CSV (the |
required |
trial_types
|
sequence of str
|
Keep only rows whose |
FIT_TRIAL_TYPES
|
max_trials
|
int
|
Take a reproducible random subsample of this many trials. Useful for
quick runs; |
None
|
seed
|
int
|
Seed for the subsample. |
0
|
Returns:
| Type | Description |
|---|---|
TrialData
|
|
Notes
The oddity task presents three stimuli (reference, reference, comparison)
but only two distinct means, so K=2. The duplication is encoded in the
task likelihood, not the data container i.e., the same convention psyphy uses
elsewhere, and the same one the paper uses (its data tuple is
(y, mref, mprobe)).
Source code in src/psyphy/data/published/hong2025.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | |
w2d_to_rgb
¶
Convert 2-D W space coordinates to linear monitor RGB.
The transform is affine, handled by augmenting each coordinate with a constant 1 so that the matrix's third column supplies the DC offset between W-space origin and monitor gray::
1 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
(ndarray, shape(2) or (N, 2))
|
Stimulus coordinates in the paper's 2-D W space. |
required |
M
|
(ndarray, shape(3, 3))
|
Matrix from :func: |
required |
Returns:
| Type | Description |
|---|---|
(ndarray, shape(3) or (N, 3))
|
Linear RGB in [0, 1], matching the input's dimensionality. |
Notes
These are linear, non-gamma-corrected RGB values, which is what the paper's own plotting code produces and passes to matplotlib. Applying an sRGB gamma would give more perceptually even colours but would no longer match the published figures.
The matrix is monitor-specific -- one Dell display, calibrated on the
date in :data:CALIBRATION_DATE. It reproduces this paper's figures; it
is not a general W-space-to-RGB conversion, and a different display needs
its own calibration.
Values outside the monitor gamut are clipped, so a returned colour on a channel boundary may not be the exact requested chromaticity. Over the paper's own [-0.7, 0.7] reference grid no clipping occurs.
Examples: