Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pure Python backend / cross-platform support #7

Open
a-hurst opened this issue Nov 16, 2021 · 1 comment
Open

Pure Python backend / cross-platform support #7

a-hurst opened this issue Nov 16, 2021 · 1 comment

Comments

@a-hurst
Copy link
Contributor

a-hurst commented Nov 16, 2021

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!

Screen Shot 2021-11-16 at 3 50 42 PM

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!

cfs.zip

@a-hurst
Copy link
Contributor Author

a-hurst commented Mar 19, 2023

Just as a quick update for anyone who stumbles on this, I finally made my pure-Python CFS parser into a proper package and put it up on GitHub here: https://github.com/a-hurst/pycfs-signal

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

No branches or pull requests

1 participant