AmperieLabs

Sensor drift, event misalignment and motion artefact are different problems

A physiological trace rises slowly across a session. Peaks appear two seconds after the protocol markers. Several abrupt deflections coincide with movement.

Calling the whole file “noisy” loses the diagnosis.

The slow change may come from the measured physiology, electrode polarisation, temperature, hydration, amplifier warm-up or a changing sensor response. The two-second delay may be physiological latency, a fixed clock offset, an audio-output delay or an event logger writing from another computer. The abrupt deflections may be contact movement, cable motion, muscle activity, a genuine autonomic response to exertion, or several of those at once.

A high-pass filter can flatten the first problem, conceal the second and make the third look cleaner without identifying any of them.

Drift requires a reference

Technical note

NIST defines drift as a slow change in the response of a gauge.[a5-1] The word response matters. A downward trend in the recorded value does not by itself show that the instrument has drifted.

Consider a skin-temperature sensor that falls by 0.8 °C during a 40-minute recording. Four explanations fit the trace:

  • the skin cooled;
  • the sensor lifted slightly from the skin;
  • ambient temperature changed;
  • the sensor response changed while the true temperature remained stable.

Only the fourth is instrument drift.

Evidence for drift needs something expected to remain stable or to follow a known value:

  • a calibration reference measured before and after the session;
  • a check standard recorded repeatedly over days;
  • two sensors exposed to the same stable input;
  • a controlled bench signal fed into the acquisition chain;
  • a zero-input or shorted-input recording where appropriate;
  • repeated measurements under a declared thermal and electrical state.

For an electrode-based physiological channel, a long baseline shift can also arise from half-cell potentials, electrolyte redistribution, changing skin contact and actual tonic physiology. I would describe that first as baseline movement or low-frequency change. “Sensor drift” is a causal claim.

A useful drift table

Test Recorded input Reference Question answered
Shorted electronic input amplifier output electrical zero or known test source Does the electronics baseline move?
Stable resistor or simulator acquisition output known electrical input Does gain or offset change?
Temperature bath sensor reading calibrated thermometer Does response change at a stable temperature?
Repeated physiological placement physiological signal no fixed truth Is the full measurement process repeatable?
Two co-located sensors two sensor outputs agreement between devices Do they diverge under the same exposure?

The final two tests can reveal instability. They cannot cleanly assign it to the instrument, contact interface or subject.

A straight line is a weak drift model

Technical note

Fitting a linear trend and subtracting it is easy:

from scipy import signal

corrected = signal.detrend(recording, type="linear")

That operation assumes the trend is unwanted and approximately linear. It provides no evidence for either assumption.

In a stimulus experiment, a slow recovery may be the phenomenon under study. In an eight-hour wearable recording, posture, meals, temperature, medication and circadian change can all generate low-frequency structure. Detrending will still return an attractive centred trace.

I use detrending only after preserving the original signal and naming the reason for removal. The analysis record should state:

Observed pattern: monotonic baseline increase after minute 18
Evidence: also present during fixed electrical input test
Proposed cause: amplifier warm-up
Correction: calibration curve estimated from bench runs
Original retained: yes
Sensitivity analysis: results with and without correction

“Removed drift” is not enough.

Event misalignment is a clock problem

Technical note

A sensor and a protocol computer usually do not share time merely because both write timestamps.

One may record Unix time in milliseconds. Another may start at zero when firmware acquisition begins. The experiment script may log the command to play a sound while the sound card produces the stimulus later. Network time can correct wall clocks yet leave independent sample clocks running at slightly different rates.

There are two common timing errors.

Fixed offset

Every event is displaced by approximately the same amount:

sensor_time = protocol_time + 1.82 seconds

A start trigger, buffering delay or timezone conversion can create this.

Clock-rate difference

The displacement grows across the session:

sensor_time = 1.00008 * protocol_time + 1.82 seconds

A rate error of 100 parts per million accumulates 0.18 seconds across 30 minutes. A rate error of 50 parts per million accumulates 1.44 seconds across eight hours.

That is enough to move a short response out of its analysis window.

Use repeated shared events

Technical note

One marker at the start estimates an offset. It says nothing about clock-rate difference.

Use events observable in both streams:

  • a button press recorded by the protocol and an accelerometer;
  • a sharp breath marked in the script and visible in respiration;
  • an LED flash captured by a photodiode and video;
  • an electrical sync pulse recorded by both devices;
  • a deliberate device movement at the start and end;
  • an acoustic click recorded by a microphone beside the stimulus log.

Bennett, Gans and Jafari described data-driven synchronisation using common events observed by heterogeneous wearable and environmental sensors.[a5-2] The same principle works in a modest laboratory recording. Two or more anchors let the residual error show whether a simple offset is enough.

Fit the mapping on anchors and inspect every residual:

import numpy as np

protocol_t = np.array([0.0, 600.0, 1200.0, 1800.0])
sensor_t = np.array([1.82, 601.87, 1201.92, 1801.97])

slope, intercept = np.polyfit(protocol_t, sensor_t, deg=1)
predicted = slope * protocol_t + intercept
residuals = sensor_t - predicted

Store:

  • original sensor timestamp;
  • original protocol timestamp;
  • corrected common time;
  • estimated slope and intercept;
  • anchor type;
  • residual error;
  • software version that applied the correction.

Never overwrite the source event file.

Physiological latency cannot repair a clock

Technical note

Cross-correlation is often used to align streams by shifting one until correlation is highest. That can be reasonable for two sensors measuring the same physical event. It becomes dangerous when one stream is a stimulus marker and the other is a physiological response.

A skin response, heart-rate change or pupil response has a latency distribution. Aligning each response peak to the stimulus can erase the biological variation the study intended to measure.

Use technical anchors to estimate the clocks. Analyse physiological latency after the timebase has been corrected.

Motion artefact has several mechanisms

Technical note

“Motion” is context. The recorded disturbance still needs a mechanism.

For wearable biopotential or electrodermal data, movement can produce:

  • changing electrode pressure;
  • movement at the skin-electrode interface;
  • cable or lead motion;
  • triboelectric charge;
  • muscle activity entering the recording band;
  • reference-electrode disturbance;
  • transient loss and restoration of contact;
  • genuine physiological activation caused by exertion or startle.

Chen and colleagues used stationary wavelet decomposition and a Gaussian-mixture model to identify and remove motion artefacts from ambulatory skin-conductance data.[a5-3] The method is a concrete example of model-based correction. It does not make all movement-correlated signal disposable.

An accelerometer peak beside an electrodermal response establishes temporal association. It does not identify whether the electrodermal change came from contact disturbance, sympathetic activation or both.

Locality helps when several channels exist

Technical note

Suppose six nearby electrodes record the same palm.

A systemic autonomic event may appear with related timing across several channels, though amplitude and polarity can differ by site. A local contact disturbance may dominate one electrode. A reference-electrode movement can contaminate every derived channel at once.

Useful comparisons include:

  • number of affected channels;
  • onset synchrony;
  • waveform polarity;
  • recovery shape;
  • relation to impedance or contact-quality measures;
  • relation to accelerometer direction and magnitude;
  • recurrence at the same site;
  • dependence on cable or reference position.

Do not turn “present on all channels” into an automatic physiology label. A shared reference can create exactly that pattern.

Three failures, three diagnostic tests

Technical note

Observed pattern Evidence to collect Common wrong fix Better next test
Slow baseline movement reference input, temperature, contact quality, repeated standard linear detrend record a stable input through the same chain
Events increasingly late repeated shared anchors across session shift all markers by one constant fit offset and clock-rate mapping, inspect residuals
Sharp transient during movement IMU, contact quality, channel locality, raw waveform delete every movement interval compare affected channels and controlled repeated movements
All channels jump together reference channel, supply, grounding, shared hardware label as systemic response inspect common reference and acquisition rail
One channel decays after placement electrode site, impedance, gel/contact condition high-pass filter reseat or repeat placement under controlled conditions
Apparent response before stimulus audio/visual output timing, event-write timing widen response window record the delivered stimulus in the sensor timebase

The filter can make the diagnosis harder

Technical note

High-pass filtering

A high-pass filter suppresses low-frequency content. It cannot distinguish instrument drift from tonic physiology. Edge transients and phase behaviour also matter, especially around short records and event boundaries.

Median or Hampel filtering

These filters can suppress isolated spikes. A real sharp event may have the same local statistical signature. Keep a detection mask and review examples before replacing values.

IMU regression

Regressing accelerometer magnitude from a physiological channel assumes a stable relationship between movement and contamination. The same motion can produce different electrode effects after sweating, repositioning or pressure change. It may also remove genuine exertion-linked physiology.

Wavelet correction

Wavelet methods separate components by time-frequency structure. Their result depends on basis, level and classification rule. Show the removed component, not only the corrected trace.

Broad rejection windows

Deleting five seconds around every movement protects against some artefacts and preferentially removes behaviourally active periods. The retained dataset may describe stillness rather than daily physiology.

Build a controlled artefact session

Technical note

A short deliberate recording is more informative than tuning thresholds on uncontrolled data.

Example sequence:

  1. five minutes seated stillness;
  2. six marked wrist flexions;
  3. six marked finger contractions without arm movement;
  4. three controlled electrode-pressure changes, where safe and practical;
  5. a short walk;
  6. return to seated rest;
  7. repeat one movement block after the contact interface has equilibrated.

Record protocol markers, IMU, contact-quality channels and the physiological signal in the same clock where possible. Video can help during development, subject to consent and data governance.

The point is to obtain examples where the movement type is known. A classifier trained on labels inferred from the same unexplained waveform will reproduce the original guess.

Keep separate flags in the data model

Technical note

Do not compress every issue into one quality = bad column.

A usable segment table might contain:

participant_id
session_id
channel_id
start_time
end_time
missing_data_flag
saturation_flag
contact_change_flag
motion_context_flag
clock_correction_applied
clock_residual_ms
baseline_instability_flag
review_status
exclusion_reason

A motion-context flag can coexist with a retained physiological event. A timestamp-correction field records a transformation rather than pretending the source clock was always correct.

Technical figure in preparation

What I ask for before scoping

Technical note

Send:

  • one raw recording before filtering;
  • the event file;
  • the code or system that generated both timestamps;
  • nominal sampling rate and actual timestamp units;
  • device and firmware versions;
  • any IMU, contact or reference channels;
  • three intervals currently called drift or motion artefact;
  • the response window or downstream feature that is failing.

Include one interval where the team disagrees about the cause.

References

NIST/SEMATECH. Engineering Statistics Handbook, 2.4.5.3 Drift. NIST defines drift as a slow change in a gauge’s response.

Bennett TR, Gans N, Jafari R. Multi-Sensor Data-Driven Synchronization Using Wearable Sensors. Proceedings of the 2015 ACM International Symposium on Wearable Computers. 2015:113–116.

Chen W, Jaques N, Taylor S, Sano A, Fedor S, Picard RW. Wavelet-Based Motion Artifact Removal for Electrodermal Activity. 37th Annual International Conference of the IEEE Engineering in Medicine and Biology Society. 2015:6223–6226.

Need help with an existing dataset or method?

Services projects start with representative material and a bounded technical question.

View Signal Analysis