Skip to main content

Module preprocessing

Module preprocessing 

Source
Expand description

Sensor signal normalisation and denormalisation.

The raw sensor values captured by wearable devices span very different physical scales (e.g. heart rate ≈ 60–180 bpm vs. LF power ≈ 0–10 000). Before feeding data into the ViT encoder every channel is z-score normalised using population-level statistics.

§Normalisation formula

z[t, c] = (x[t, c] - mean[c]) / std[c]

§Denormalisation (used in caption generation)

x[t, c] = z[t, c] * std[c] + mean[c]

After denormalisation certain channels are clamped to be non-negative (e.g. steps, sleep_coefficient).

Structs§

ChannelStats
Per-channel normalisation statistics resolved from NORM_PARAMS.

Functions§

apply_mask
Apply a missingness mask, replacing imputed values with NaN.
average_downsample_ct
Average-pool a (C, T) array down to (C, target_t) time-steps.
channel_name
Return the human-readable name for a channel index.
channel_stats
Compute (mean, max, min, std) for every channel in a (T, C) array.
denormalize
Reverse a previous call to normalize.
denormalized
Denormalise without mutating: returns a new owned array.
f32_slice_to_normalised
Convert a flat Vec<f32> (row-major, shape [T, C]) into an ndarray after normalising.
normalize
Z-score normalise a (T, C) raw sensor array in-place.
normalized
Z-score normalise a raw sensor array and return a new array.