Skip to content

Regenerate RecordData declarations from written samples #920

Done

Description

@tompollard

Problem

RecordData.write() can retain init_value and checksum from the source header even when they do not describe the samples being written. This happens after frame smoothing or skew alignment without an explicit edit. In the comparison reported on PR #919, 54 of 364 unedited channels had an init_value different from their first written sample. For example, an aligned or smoothed write can begin with a different integer from the source file.

#919 refreshes these declarations when explicit calibration changes the integers or a target format recodes missing markers. It also fills omitted adc_res and adc_zero when derived declarations require those positional header fields. Ordinary RecordData writes can still retain stale declarations.

Proposed fix

Derive init_value and checksum from the encoded samples on every RecordData.write() and write_record(path, RecordData) call. Keep the mutable Record writer's behavior separate. The result should be the same whether the caller omits formats= or repeats the source format explicitly.

This will change some header bytes relative to 5.17.0: checksums may appear in an equivalent unsigned form, and some initial values will change to the first sample actually written. Document those changes in a changelog entry and the next release notes.

Checks

  • Cover uniform reads with several samples per frame, aligned skew, expanded layout, physical and digital values, masks, full and partial windows, and format overrides.
  • Compare output against the current writer and identify every changed header field; signal data bytes should remain unchanged.
  • Confirm records with omitted ADC fields still write, using n8_evoked_raw_95_F1_R9.
  • Check that recalculation does not add a full signal-array copy or materially slow large writes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions