28 Oct 2026 · 1 min read
Before analysing a recording, check its timestamps
A small Python example for finding duplicate timestamps, recording gaps and non-finite measurements before analysis.
A plot can look plausible even when a recording contains duplicated timestamps, missing samples or non-finite values. A small check at the beginning of an analysis helps make those problems visible.
This example uses a deliberately imperfect, synthetic recording. It is a programming exercise, not experimental data or a validated electrophysiology quality-control system.
What we check
- Time moves forwards: consecutive timestamps should increase.
- Samples arrive at the expected interval: for an intended rate of 250 Hz, the interval is 0.004 seconds. The example flags a gap larger than 1.5 times that interval.
- Values are finite: missing or non-finite values need an explicit handling decision.
The 1.5 multiplier is a simple example threshold, not a universal rule. Real devices may have timestamp rounding, clock drift, multiple clocks or burst delivery. Use the timing specification and acquisition design for your recording.
Run the example
The companion script uses only the Python standard library. Download the example ZIP, extract recording_quality.py, save it in a new folder and run:
python recording_quality.pyIt creates synthetic_recording.csv and prints a report. The expected result is 1,000 rows, one non-increasing timestamp, one large gap and one non-finite measurement.
Rows: 1000
Non-increasing timestamp steps: 1
Gaps larger than 1.5 sample intervals: 1
Non-finite measurements: 1What should happen next?
Keep the raw data intact and investigate the flagged rows. A duplicate could come from a repeated export; a gap could reflect acquisition loss; a non-finite value could have appeared during processing. The report does not tell you which explanation is correct, and it does not repair the recording automatically.
Once you understand the problem, record the exclusion or correction rule alongside the data. Decide how it affects later operations such as epoching, filtering and alignment with other devices.
What this check does not establish
Uniform timestamps do not prove that a signal is biologically meaningful, free of artefacts, correctly calibrated or aligned with another system. Timing checks are one part of a larger quality review.
Read about my research workflows or discuss a scientific analysis project.