pulse2percept.percepts.metrics
Phosphene measurements. Imported on demand by
measure(), not by
pulse2percept.percepts.
Functions
|
Measure the phosphenes in a brightness percept |
Classes
|
Phosphene measurements for a single frame of a brightness percept |
|
Phosphene measurements for every frame of a brightness percept |
- class pulse2percept.percepts.metrics.FrameMetrics(integrated_brightness: float, max_brightness: float, area: float, centroid: tuple[float, float], diameter: float, major_axis: float, minor_axis: float, elongation: float, n_components: int, touches_edge: bool)[source]
Phosphene measurements for a single frame of a brightness percept
Produced by
measure_percept(), usually throughmeasure().Only positive brightness is measured: the frame is clipped at zero first. The support is the set of pixels at or above
thresholdtimes the frame’s own positive maximum (half maximum by default). Geometry is measured on that support as a binary set of pixels, unweighted by the brightness within it, and describes the support in full even when it falls into several components. For a sufficiently sampled circular support,major_axis,minor_axisanddiameterconverge to a common value.A frame without positive brightness has no phosphene: brightness, area and component count are zero, and position and shape are
NaN.Added in version 0.11.0.
- integrated_brightness
Positive brightness integrated over the visual field (brightness units x dva^2): the pixel sum scaled by pixel area. Approximates a spatial integral, so it is insensitive to sampling resolution up to discretization.
- Type:
- diameter
Diameter (dva) of the circle of equal area,
2 * sqrt(area / pi). Atthreshold=0.5this approximates the FWHM of a sufficiently sampled circular Gaussian; agreement is limited by grid resolution.- Type:
- major_axis, minor_axis
Axis lengths (dva) of the ellipse with the same second moments as the support,
4 * sqrt(eigenvalue). Exact for a continuous uniformly filled ellipse; sampled supports approach those values as resolution increases.- Type:
- n_components
Number of connected components in the support, using full 2D connectivity so diagonal neighbors count as connected. Descriptive only: the other measurements still describe the combined support.
- Type:
- class pulse2percept.percepts.metrics.PerceptMetrics(frames: tuple[FrameMetrics, ...], threshold: float)[source]
Phosphene measurements for every frame of a brightness percept
Produced by
measure_percept(), usually throughmeasure(). Frames are measured independently; frame timing stays intime.Every
FrameMetricsmeasurement is also available as an array over frames:metrics.diameteris the diameter of each frame,metrics.peak.diameterthat of the brightest.Added in version 0.11.0.
- frames
One measurement per frame, in the order the frames are stored.
- Type:
- property peak_frame
Index of the frame with the largest
integrated_brightnessTies go to the earliest frame, as with
np.argmax.
- property peak
FrameMetricsof the frame atpeak_frame
- property integrated_brightness
Integrated positive brightness of each frame, (T,)
- property max_brightness
Largest positive brightness of each frame, (T,)
- property area
Support area (dva^2) of each frame, (T,)
- property diameter
Equivalent-circle diameter (dva) of each frame, (T,)
- property centroid
Support
(x, y)center (dva) of each frame, (T, 2)
- property major_axis
Equivalent-ellipse major axis (dva) of each frame, (T,)
- property minor_axis
Equivalent-ellipse minor axis (dva) of each frame, (T,)
- property elongation
Axis ratio of each frame, (T,)
- property n_components
Number of connected support components in each frame, (T,)
- property touches_edge
Whether each frame’s support reaches the field border, (T,)
- pulse2percept.percepts.metrics.measure_percept(percept, threshold=0.5)[source]
Measure the phosphenes in a brightness percept
Measures each frame independently. See
FrameMetricsfor the definitions and units.Added in version 0.11.0.
- Parameters:
percept (
Percept) – A (Y, X, T) brightness percept built on aGrid2D. The grid is required because positions and sizes are reported in degrees of visual angle; without one a percept carries pixel indices instead.threshold (float, optional) – Fraction of a frame’s own positive maximum at or above which a pixel belongs to the support. Must lie in (0, 1]. A Gaussian of standard deviation
sigmahas support diameter2 * sigma * sqrt(-2 * log(threshold)), so the default of 0.5 gives approximately its FWHM.
- Returns:
metrics
- Return type:
- Raises:
ValueError – For an RGB percept, a percept without visual-field coordinates, a threshold outside (0, 1], or non-finite data.
Notes
These measurements describe the modeled percept image, not behavioral performance such as acuity or discriminability.