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

Multiple issues with gettings durations for events from Open Ephys binary files #1437

Open
johnmbarrett opened this issue Mar 19, 2024 · 7 comments
Assignees
Labels
Milestone

Comments

@johnmbarrett
Copy link

Describe the bug
OpenEphysBinaryRawIO._parse_header refuses to extract durations when the number of rising edges detected exceeds the number of falling edges, even though there is enough information to compute almost all durations in this case, and also incorrectly assumes that successive events always have alternating polarity.

To Reproduce

  1. Download this OpenEphys dataset: https://drive.google.com/file/d/1Hr3-GFOpOkNc1hgXdVr5HTunchQm4enw/view?usp=drive_link
  2. Unzip the dataset somewhere
  3. Run the following code
from neo.rawio.openephysbinaryrawio import OpenEphysBinaryRawIO

folder = # fill in the folder you unzipped the data to

io = OpenEphysBinaryRawIO(folder)

io._parse_header()

timestamps, durations, labels = io._get_event_timestamps(0,0,0,None,None)

Expected behaviour
The correct durations are returned for all events

Actual behaviour
durations is None

Environment:

Additional context
For the first problem, the check on line 245 of openephysbinaryrawio.py is unnecessarily stringent. It should be less than or equal, not strict equality.

Moreover, the logic in this section doesn't work when events from multiple binary channels are interleaved on the same event stream (which is allowed by the Open Ephys specification and happens for e.g. data from an Intan RHD2000 USB evaluation board), as it incorrectly assumes that events alternate between rising and falling. However, if multiple channels are interleaved, then two rising or two falling events from different channels can follow each other, and so the duration calculation on line 246 is wrong. In the example dataset, this happens for the 26th & 27th events, in which a falling edge on channel 2 follows a falling edge on channel 3. A better approach would be, for each rising edge, to look for the next falling edge with the same absolute state value (and either drop that event from the list or assign it a NaN duration if none is found, rather than Noneing out the entire durations array)

@alejoe91 alejoe91 self-assigned this Mar 27, 2024
@alejoe91 alejoe91 added this to the 0.13.1 milestone Apr 5, 2024
@alejoe91
Copy link
Contributor

@johnmbarrett would you have time to make a PR and propose a fix?

@zm711 zm711 modified the milestones: 0.13.1, 0.14.0 May 3, 2024
@vigji
Copy link
Contributor

vigji commented Nov 14, 2024

Reporting here similar issues.

I am opening OpenEphys-saved data from a NIDAQ board where I acquire two digital inputs. When I load it using spikeinterface - which relies on this afaik - durations are all messed up as it seems that the falling edge of one signal cuts the duration of the other signal (parts of the recordings where one of the digital signals is just off have no issue). @alejoe91 can you confirm this could be the problem?

any plans on fixing this upstream? ATM I have to write custom loading from the events folder where everything else is loaded with spikeinterface :(

@alejoe91
Copy link
Contributor

HI guys, this fell a bit out of my radar, my bad!

I'll add it to my todo list and try to propose a fix by the end of next week.

Cheers

@vigji
Copy link
Contributor

vigji commented Dec 2, 2024

any update here @alejoe91 ?

@alejoe91
Copy link
Contributor

alejoe91 commented Dec 2, 2024

Hey @vigji

Sorry I haven't had time to work on this. Any chance you want to give it a try yourself and make a PR?

@vigji
Copy link
Contributor

vigji commented Dec 2, 2024

Sure! On it :)

@vigji
Copy link
Contributor

vigji commented Dec 2, 2024

@johnmbarrett would be great to know if #1603 fix the issue for you! (I can't download the 17Gb right now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants