Skip to content

Detect artifacts using Hjorth descriptors

What it does

Marks sample intervals whose windowed power, mobility or frequency spread differs from adaptive median baselines. Windows containing missing samples are also excluded.

When to use it

Use it on a preprocessed physiological signal when deviations in local power or waveform variation identify unsuitable segments. Margins depend on signal scaling and must match the intended analysis.

Canonical ID: ppg.hjorth_artifacts

Inputs

Name Meaning Type Unit Requirements
signal Nonempty real signal, optionally containing NaN. real vector a.u. minimum length: 1; NaN allowed; finite
sampling_frequency Sampling frequency in Hz. real scalar Hz greater than: 0; no NaN; finite
window_duration Duration of each full analysis window in seconds. real scalar s greater than: 0; no NaN; finite
step_duration Advance between window starts in seconds. real scalar s greater than: 0; no NaN; finite
margins Three rows of absolute lower and upper margins for activity, mobility, and complexity. real vector or matrix mixed minimum: 0; no NaN; finite

Parameters

Name Meaning Type Unit Default Requirements
min_segment_separation Merge uncovered gaps strictly shorter than this duration; zero merges overlap and contiguity only. real scalar s 0 minimum: 0
median_filter_order Median baseline length measured in analysis windows. integer scalar window 300 minimum: 1
negative Invert the threshold decision while always excluding NaN windows. boolean dimensionless no not specified

Outputs

Name Meaning Type Unit
artifact_mask Binary sample mask of the merged artifact intervals. real vector 1
artifact_starts Times of the first included samples, in seconds from signal start. real vector s
artifact_ends Times of the last included samples, in seconds from signal start. real vector s

How it works

The signal is centered globally and analyzed in complete windows. Each descriptor is compared with a truncated, NaN-omitting median baseline plus or minus its absolute margins. The lower activity threshold is floored to 0.0001 when nonpositive. Detected windows become sample intervals, and overlap or contiguity is always merged. A positive separation also joins uncovered gaps strictly shorter than that duration.

Interpretation and limitations

A zero mask value means no artifact was marked there; it does not certify signal quality, particularly in an unexamined tail or between spaced windows. The default separation is zero seconds. Interval endpoints identify included samples, and the first sample is at time zero. Negative mode inverts the threshold decision, but windows containing NaN remain excluded. Plotting, if offered by an implementation, does not alter detections.

References

Implementations and technical resources

Python source | MATLAB source

Normative JSON | Validation cases