Reduces a recording along the time axis: one number per sensor, with the
sensor's grid coordinates attached. This is the counterpart of
pr_frame_metrics(), which reduces along the sensor axis instead.
Usage
pr_sensor_map(
trial,
statistic = c("mean", "max", "sd", "pti", "pct_zero"),
threshold = 0
)Arguments
- trial
A pr_trial object.
- statistic
Character. One of
"mean","max","sd","pti"or"pct_zero". See Details.- threshold
Numeric. Cells at or below this value count as unloaded. Default
0.
Value
A tibble::tibble with one row per sensor and columns sensor
(integer), row, col (integer grid indices) and value (numeric).
Details
The available statistics, for a sensor read at every frame:
"mean"— mean pressure, unloaded frames included in the denominator."max"— the maximum pressure picture (MPP): the peak this sensor ever saw.pr_sensor_map(trial, "max")$valueis the mappr_plot_heatmap()draws."sd"— standard deviation over frames (NAfor a single-frame trial), i.e. how much this sensor's load fluctuated."pti"— pressure-time integral, trapezoidal over the trial's own timestamps; identical topr_calc_pti()at the default threshold."pct_zero"— fraction of frames in which the sensor was at or belowthreshold.1means never loaded,0means always loaded; it is the per-sensor duty cycle, and1 - pct_zerois the fraction of the recording the sensor was in contact.
threshold treats cells at or below it as unloaded, exactly as in
pr_frame_metrics(): they are zeroed before mean, sd and pti are
taken, they cannot raise max, and they are what pct_zero counts. At
the default threshold = 0 on non-negative data no masking is needed and
none is done.
The sensor column is the pressure column index, taken positionally
from trial$layout$coords_mm, not the device channel number. For a
layout built by pr_layout_from_index_map() the two differ, and
pr_channel_order(trial$layout)[sensor] recovers the device channel.
Rows come back in that same column-major grid order, so $value can be
used as a feature vector directly.
See also
pr_frame_metrics() for the per-frame reduction,
pr_profile_matrix() to stack this across a dataset.
Other sensor aggregation functions:
pr_batch_frame_summary(),
pr_profile_matrix()
Examples
trial <- pr_example_trial("saddle_horse")
mpp <- pr_sensor_map(trial, "max")
mpp[which.max(mpp$value), ]
#> # A tibble: 1 × 4
#> sensor row col value
#> <int> <int> <int> <dbl>
#> 1 68 4 5 18.4
# The mean map is never above the peak map, sensor for sensor:
avg <- pr_sensor_map(trial, "mean")
all(avg$value <= mpp$value + 1e-9)
#> [1] TRUE
# Fraction of the recording each sensor spent in contact:
duty <- 1 - pr_sensor_map(trial, "pct_zero")$value
round(range(duty), 3)
#> [1] 0.462 1.000