-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Hi again,
Since I put together my previous PR, I've done some additional work with the CFS format you might be interested in integrating! Specifically, I was running into some issues with pyCEDFS not parsing all the Data Section variables I wanted in my file (would only read the first 30 or so), so rather than get deep into ctypes debugging I adapted some old EDF-parser code I'd written to create a pure-Python CFS header parser. Once that was together, it was only a little extra work to get it reading Data Section variables and channel data without the DLL too. The end result runs nicely on macOS, and should be fully cross-platform for any systems that support Numpy!
Of course, given how strongly pyCEDFS is based on the ctypes/DLL interface, cleaning up my work for a PR would involve replacing a ton of the existing code which might have various unintended consequences. As such, I'm not sure whether you'd prefer this work be merged into pyCEDFS or exist as a separate project.
I've attached my WIP code so you can take a look. The main function is "read_cfs", which accepts a file path as an argument. It returns a dict with a header and a list of Frame objects (data sections), which contain the data section variables and channel data for each frame. The structure.py
file contains the names and byte widths of each field of each form of header in the file, which the read.py
file uses to grab the bytes associated with each field and convert them to their corresponding data types. The cfs.py
file contains some half-implemented container object types for CFS files and frames.
Let me know what you think!