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
Classes:
Name | Description |
---|---|
ResponseData |
Container for psychophysical trial data. |
TrialBatch |
Container for a proposed batch of trials |
ResponseData
¶
Container for psychophysical trial data.
Attributes:
Name | Type | Description |
---|---|---|
refs |
List[Any]
|
List of reference stimuli. |
probes |
List[Any]
|
List of probe stimuli. |
responses |
List[int]
|
List of subject responses (e.g., 0/1 or categorical). |
Methods:
Name | Description |
---|---|
add_batch |
Append responses for a batch of trials. |
add_trial |
append a single trial. |
to_numpy |
Return refs, probes, responses as numpy arrays. |
Source code in src/psyphy/data/dataset.py
add_batch
¶
add_batch(
responses: List[int], trial_batch: TrialBatch
) -> None
Append responses for a batch of trials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
responses
|
List[int]
|
Responses corresponding to each (ref, probe) 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 |
---|---|---|---|
ref
|
Any
|
Reference stimulus (numpy array, list, etc.) |
required |
probe
|
Any
|
Probe stimulus |
required |
resp
|
int
|
Subject response (binary or categorical) |
required |
Source code in src/psyphy/data/dataset.py
TrialBatch
¶
Container for a proposed batch of trials
Attributes:
Name | Type | Description |
---|---|---|
stimuli |
List[Tuple[Any, Any]]
|
Each trial is a (reference, probe) tuple. |
Methods:
Name | Description |
---|---|
from_stimuli |
Construct a TrialBatch from a list of stimuli (ref, probe) pairs. |
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 |
Container for psychophysical trial data. |
TrialBatch |
Container for a proposed batch of trials |
ResponseData
¶
Container for psychophysical trial data.
Attributes:
Name | Type | Description |
---|---|---|
refs |
List[Any]
|
List of reference stimuli. |
probes |
List[Any]
|
List of probe stimuli. |
responses |
List[int]
|
List of subject responses (e.g., 0/1 or categorical). |
Methods:
Name | Description |
---|---|
add_batch |
Append responses for a batch of trials. |
add_trial |
append a single trial. |
to_numpy |
Return refs, probes, responses as numpy arrays. |
Source code in src/psyphy/data/dataset.py
add_batch
¶
add_batch(
responses: List[int], trial_batch: TrialBatch
) -> None
Append responses for a batch of trials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
responses
|
List[int]
|
Responses corresponding to each (ref, probe) 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 |
---|---|---|---|
ref
|
Any
|
Reference stimulus (numpy array, list, etc.) |
required |
probe
|
Any
|
Probe stimulus |
required |
resp
|
int
|
Subject response (binary or categorical) |
required |
Source code in src/psyphy/data/dataset.py
TrialBatch
¶
Container for a proposed batch of trials
Attributes:
Name | Type | Description |
---|---|---|
stimuli |
List[Tuple[Any, Any]]
|
Each trial is a (reference, probe) tuple. |
Methods:
Name | Description |
---|---|
from_stimuli |
Construct a TrialBatch from a list of stimuli (ref, probe) pairs. |
Source code in src/psyphy/data/dataset.py
Transforms (e.g., from RGB to model space)¶
transforms
¶
transforms.py
color space transformations.
functions (MVP stubs): - to_model_space(rgb): map RGB stimulus values into model space - to_rgb(model_coords): map from model space back to RGB
Future extensions: - other color spaces
Functions:
Name | Description |
---|---|
model_to_stimuli |
Map from model space coordinates to RGB values. |
stimuli_to_model_space |
Map RGB stimulus values to model space coordinates. |
Attributes:
Name | Type | Description |
---|---|---|
ArrayLike |
|
model_to_stimuli
¶
model_to_stimuli(model_coords: ArrayLike) -> ndarray
Map from model space coordinates to RGB values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_coords
|
array - like
|
Model space coordinates. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
RGB values (MVP: identical to input). |
Source code in src/psyphy/data/transforms.py
stimuli_to_model_space
¶
stimuli_to_model_space(rgb: ArrayLike) -> ndarray
Map RGB stimulus values to model space coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rgb
|
array - like
|
RGB values, shape (3,) or similar. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Model-space coordinates (MVP: identical to input). |
Source code in src/psyphy/data/transforms.py
I/O¶
io
¶
io.py
I/O utilities for saving and loading psyphy data.
Supports: - CSV for human-readable trial logs - Pickle (.pkl) for Posterior and ResponseData checkpoints?
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. |
Attributes:
Name | Type | Description |
---|---|---|
PathLike |
|
load_posterior
¶
load_responses_csv
¶
load_responses_csv(path: PathLike) -> ResponseData
Load ResponseData from a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str or Path
|
|
required |
Returns:
Type | Description |
---|---|
ResponseData
|
|
Source code in src/psyphy/data/io.py
save_posterior
¶
save_responses_csv
¶
save_responses_csv(
data: ResponseData, path: PathLike
) -> None
Save ResponseData to a CSV file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ResponseData
|
|
required |
path
|
str or Path
|
|
required |