uwmadison-chm / bioread

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

read error on acknowledge file #36

Closed bpinsard closed 2 years ago

bpinsard commented 2 years ago

Hi, I get the following error on opening a few acknowledge files that we acquired (here is a debug trace in ipython).

.... 
OSError: [Errno 22] Invalid argument
In [2]: %debug
> .../lib/python3.6/site-packages/bioread/reader.py(263)__read_journal_v4()
    261                     self.encoding, errors='ignore').strip('\0')
    262         # Either way, we should seek to this point.
--> 263         self.acq_file.seek(self.journal_length_header.data_end)
ipdb> self.journal_length_header.data_end
-318777935
ipdb> self.journal_length_header.offset
11703
ipdb> self.journal_length_header.journal_len
-318789638

Does that indicate that the files are corrupted?

dgfitch commented 2 years ago

Might be truncated... do you get any errors when opening in Acknowledge, or does it open fine?

njvack commented 2 years ago

Probably the file is okay (as long as it really is an acqknowledge file) but Something is Amiss in reading the journal. Since the journal comes before the data in the file, we really do need to figure out what's going on there. There's no spec from Biopac on these, so the code is all hacks and guesses.

Can you post the file?

bpinsard commented 2 years ago

Thanks for your suggestions. I went back to the acquisition computer where Acqknowledge is installed, and on opening the files where it occured, it says it's corrupted and offers to fix it. It might be worth setting an error message suggesting that fix. I cannot share the file, unfortunately.

I will try to investigate the differences between the corrupted and fixed files to see what the fix did.

njvack commented 2 years ago

Thanks for the update; I've never heard of acqknowledge detecting and fixing corruption before. Neat!

Yeah, suggesting people try to read the file in acqknowledge is a good idea; at least it deserves documentation on the web page.

The other thing we could try code-wise is, if we've read the main header successfully and know how many channels there are, we could scan forward to try and find the channel data type headers if the journal or foreign data headers are "obviously bad" (we already do this for the foreign data header)