Skip to content

Declare microvolts as the unit of the velocity systems' output - #13

Merged
cboulay merged 1 commit into
devfrom
feat/microvolts-unit
Oct 7, 2026
Merged

cboulay merged 1 commit into
devfrom
feat/microvolts-unit

Conversation

@cboulay

@cboulay cboulay commented Oct 7, 2026

Copy link
Copy Markdown
Member

Summary

The velocity systems produce signals in microvolts — the DNSS spike templates (wf_orig) are µV and the LFP noise scale is chosen to sit under them — but no message said so. Downstream consumers such as an LSL outlet, which writes attrs into the stream description, therefore published no unit.

  • dnss/wfs.py: WF_UNIT = "microvolts" alongside wf_orig.
  • system/_signal_unit.py (new, private): a transformer that sets attrs["unit"], preserving other attrs.
  • Velocity2Spike and Velocity2LFP end with that stage, so each declares the unit standalone.
  • VelocityEncoder adds no stage: both Add inputs carry the unit and LineNoise preserves attrs. Docstrings now give µV for the output, drift_scale and line_noise_amp.

The unit is a constant, not a setting: the amplitudes are fixed in µV, so a configurable unit could only disagree with the data.

Tests

  • tests/unit/test_signal_unit.py: stamping, preserving other attrs, replacing a different unit.
  • tests/integration/test_velocity_encoder_unit.py: Clock → Spiral → Diff → VelocityEncoder (line noise on); every output message has unit == "microvolts".

Full suite: 164 passed; ruff clean.

Note: on macOS 27 the locked scipy 1.15.3 fails to load (dyld __thread_bss error), so I ran the suite with uv run --with scipy==1.18.1. The lock is unchanged here; bumping it is a separate change.

Velocity2Spike and Velocity2LFP now stamp attrs["unit"] = "microvolts"
on every output message. The amplitude is set by the DNSS spike templates
(microvolts) and the LFP scale is chosen to match, but nothing declared it,
so consumers such as an LSL outlet could not report a unit.

VelocityEncoder inherits the unit through Add and LineNoise without an
extra stage. The stamping stage is private to the system package.
@cboulay
cboulay merged commit 9aee035 into dev Oct 7, 2026
14 checks passed
@cboulay
cboulay deleted the feat/microvolts-unit branch October 7, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant