uwmadison-chm / bioread

Utilities to work with files from BIOPAC's AcqKnowlege software
MIT License
65 stars 23 forks source link

Unreadable matlab files #39

Open dominikbach opened 2 years ago

dominikbach commented 2 years ago

For some acq files, acq2mat and MatlabWriter.py produce unreadable matlab files.

For data acquired with the same settings, the error occurs for a small subset of files, with no clear pattern why. For a given file, the error is reproducible on different computers, Matlab versions, and system versions (all under Windows), and for the two conversion methods. We tried to open and save the acq files again in Acqknowledge but the error still occurs.

The error is: Error using load Cannot read file ...

Using matfile.m, it is the variable headerswhich cannot be read from file and produces the error with load.

njvack commented 2 years ago

Very weird! Any chance we can see one of the affected files?

dgfitch commented 4 months ago

We hit this error on some MR2 subjects over in Stacey's land.

I can't figure out a pattern and don't have time to do a version regression to find out what changed, but here's a sample file.

sample.zip

What I know: acq2mat ran on this with bioread v1.0.4 (the default on BI servers) generates a file Matlab can read. Same process with bioread 3.0.1 writes a .mat file that Matlab does not load.

Dominik is correct above, if I do m = matfile("sample_3.0.1.mat") I can confirm that m.headers is the bit that dies; the data from the channels loads fine. So, that's a possible workaround for folks who stumble on this; it wouldn't be too hard to write a matfile wrapper that fills in fake headers instead of trying to read whatever's broken.

The headers do look different if I diff a hex dump, but I don't know what's actually wrong.

Thanks for writing this dang library, Nate, it is endlessly useful. Maybe someday I'll have time to contribute back some fixes... :heart:

njvack commented 4 months ago

Interesting! The sample file is gonna be helpful here. I wonder if it would replicate with octave...

njvack commented 4 months ago

oh no I am trying to brew install octave over a cell link

njvack commented 4 months ago

One last question -- to confirm, using --data-only does not fix this, right? It's something in the headers structure itself, not the markers?

I think we're writing more stuff to headers than is needed though — we shouldn't need the graph or foreign headers at all

dgfitch commented 4 months ago

Confirmed, --data-only has no effect and the file is still unreadable.

On Wed, Feb 28, 2024 at 8:29 AM Nate Vack @.***> wrote:

One last question -- to confirm, using --data-only does not fix this, right? It's something in the headers structure itself, not the markers?

I think we're writing more stuff to headers than is needed though — we shouldn't need the graph or foreign headers at all

— Reply to this email directly, view it on GitHub https://github.com/uwmadison-chm/bioread/issues/39#issuecomment-1969107690, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAV4BBJRESUQPRCEK6K4TYV45LXAVCNFSM5VBATQE2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJWHEYTANZWHEYA . You are receiving this because you commented.Message ID: @.***>