Skip to content

Group per-channel header fields into coherent signal metadata #744

Backlog

Description

@tompollard

Problem

Record stores per-channel header fields in parallel lists: sig_name, file_name, fmt, units, samps_per_frame, adc_gain, baseline, and others. Their entries must remain aligned with each other, the signal array columns, and n_sig as records are selected, edited, and written.

Decisions to make

  • Should logical signal metadata and signal-file layout/encoding metadata be separate objects? Which fields belong to each?
  • How should the model represent several signals sharing a file, and variable-layout multi-segment records?
  • Should counts and name lists be derived from channel entries? How would legacy in-place edits such as record.sig_name[0] = "ECG" remain compatible?
  • Should omitted header defaults, such as one sample per frame, be normalized to explicit values when read? When should type checks and cross-field validation happen?

Related: #371 (record metadata), #441 (signal metadata on MultiRecord), #672 (readable attributes), and the design review on #417.

Activity

  1. tompollard commented on Nov 30, 2026

    @tompollard
    MemberAuthor

    One concrete case to include when deciding whether counts should be derived: after read_record("sample-data/100", stop=4), assigning record.n_sig = 5 makes record.metadata.n_signals report 5, but record.write(...) writes a two-channel header. Conversely, slicing record.p_signal down to one column leaves both counts at 2, and record.write(...) fails with a NumPy broadcasting error. I reproduced both cases while reviewing #802.

    I removed the proposed writable n_signals alias from #802 so the new name does not inherit this ambiguity. A future count API should decide which value is authoritative when several signal arrays are loaded, and make Record.metadata and writing behave consistently with that decision. This fits the count and cross-field validation questions already tracked here.

  2. tompollard commented on Nov 30, 2026

    @tompollard
    MemberAuthor

    One remaining writer case for this issue: Record.wrsamp() still raises NumPy's non-broadcastable output operand error after a loaded two-channel p_signal is sliced to one column without updating the per-channel fields. I reproduced it with read_record("sample-data/100", stop=4). PR #803 improves validation and diagnostics for write_record() and Record.write(); the legacy writer's validation path still needs a separate compatibility review.

  3. tompollard commented on Nov 30, 2026

    @tompollard
    MemberAuthor

    We have settled the count contract for this part of the work. n_sig is the mutable, declared channel count for the current record view. In #805, n_signals is an alias for that same stored value, and each access to Record.metadata takes a fresh snapshot of it. The count is not inferred from a loaded array: a record may be header-only or hold more than one signal form.

    Edits can leave the declaration, arrays, and per-channel lists temporarily inconsistent. #803 and #804 make the single-segment writers reject those inconsistencies before writing. #805 adds a check that a MultiRecord master count agrees with its fixed-layout segments or variable-layout header. The larger question of grouping per-channel fields into a coherent metadata model remains open here.

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