Skip to content

[Draft]: Add new record - #388

Closed
cx1111 wants to merge 1 commit into
mainfrom
cx/newrecord
Closed

cx1111 wants to merge 1 commit into
mainfrom
cx/newrecord

Conversation

@cx1111

@cx1111 cx1111 commented Jun 7, 2022 •

Copy link
Copy Markdown
Collaborator

New record class addressing #376, #371.

def read_header(record_name: str) -> RecordInfo:
    """
    Reads a header file, and returns a RecordInfo object containing the
    metadata fields
    """
    # ...Bunch of header parsing logic
    return info

def open_record(record_name: str) -> Record:
    """
    Returns a Record object containing the info read from the header file.
    This can be used to read/write the signals belonging to the record.
    """
    info = read_header(record_name=record_name)
    record = Record(info=info)
    return record

def read_record_data(record_name: str, samp_from: int, samp_to: int):
    """
    The new rdsamp. No streaming. That would be too complicated.
    """
    record = open_record(record_name)  # Does NOT read the signals.
    signals = record.read(samp_from=samp_from, samp_to=samp_to)
    return record.info, signals

Workflow:

  • Read the .hea file to get a RecordInfo object.
  • Create a Record object, and attach the RecordInfo object. (Composition vs inheritance, so no more mixins.)
  • The Record object should contain a SignalHandler object or something similar. This class/object will be responsible for reading/writing the signal data from/to the files. The Record object will contain methods which call the underlying SignalHander object.

@cx1111

cx1111 commented Jun 10, 2022 •

Copy link
Copy Markdown
Collaborator Author

I considered having an individual SignalHandler or Signal class for each channel. But I think having one object represent all the channels makes more sense, especially regarding reading/writing multiplexed signal files, ie. a single dat file containing interleaved samples of multiple channels.

It would probably be more difficult to coordinate the logic across a collection of objects. For example, if two signals share the same file, which object(s) should contain the file handler?

@cx1111
cx1111 marked this pull request as draft June 24, 2022 19:44
@tompollard

Copy link
Copy Markdown
Member

Closing this 2022 draft because the API work has since taken a different shape. read_header returns a header description, while read_record and read_signals provide the current data-reading interfaces; SignalRead carries signal values and their metadata. We have not added the proposed lazy open_record/SignalHandler design, so this PR is no longer the implementation path. The remaining questions about structuring record metadata and multi-segment data are tracked in #371, #744, and #746. Thanks for laying out the original design.

@tompollard tompollard closed this Dec 1, 2026
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.

2 participants