cardioception.PAT.scoring.mad_outliers#

cardioception.PAT.scoring.mad_outliers(x, k=5.0, min_sd=1.0)[source]#

Flag values more than k robust standard deviations from the median.

The robust standard deviation is 1.4826 times the median absolute deviation (Leys et al., 2013), floored at min_sd. Without the floor a MAD of 0 (a fixed period, as in an exteroceptive run) would make any difference at all, float noise included, an outlier.

Parameters
xarray-like

Values, typically one participant’s heart periods in ms.

kfloat

Cut-off in robust standard deviations. Hodgetts et al. (2026) use 5.

min_sdfloat

Smallest robust standard deviation, in the units of x: 1 ms by default, so with identical periods only a trial more than k ms away is flagged. 0 turns the floor off.

Returns
masknp.ndarray of bool

True for outliers. NaN values are not flagged: they are missing, not outlying, and callers drop them separately.