You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defread_header(record_name: str) ->RecordInfo:
""" Reads a header file, and returns a RecordInfo object containing the metadata fields """# ...Bunch of header parsing logicreturninfodefopen_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)
returnrecorddefread_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)
returnrecord.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.
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?
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New record class addressing #376, #371.
Workflow:
RecordInfoobject.Recordobject, and attach theRecordInfoobject. (Composition vs inheritance, so no more mixins.)Recordobject should contain aSignalHandlerobject or something similar. This class/object will be responsible for reading/writing the signal data from/to the files. TheRecordobject will contain methods which call the underlyingSignalHanderobject.