-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[MRG] Add support for event_type=3 when reading CNT data #3911
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
Conversation
|
Closes #3882 :D |
4f11e8c to
69fff4c
Compare
|
Problem is: I don't have an easy means of generating a small test CNT file with these type of events. |
mne/io/cnt/cnt.py
Outdated
| event_time = (offset - 900 - 75 * n_channels) // (n_channels * | ||
| n_bytes) | ||
| event_time = offset - 900 - 75 * n_channels | ||
| if event_type == 1 or event_type == 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if event_type in {1, 2} ?
mne/io/cnt/cnt.py
Outdated
| n_bytes) | ||
| event_time = offset - 900 - 75 * n_channels | ||
| if event_type == 1 or event_type == 2: | ||
| event_time = event_time // float(n_channels * n_bytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event_time /= float(n_channels * n_bytes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it needs to be integer division... does //= exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you're right.
Me neither. But the code is exactly what I did for my own file. |
actually, could you double verify that for me? Do you have a test file yourself for which you know the proper event indices? I'm currently checking this against eeglab but I might get it wrong. |
|
(seems to check out with eeglab on my data) |
Current coverage is 85.26% (diff: 33.33%)@@ master #3911 diff @@
==========================================
Files 347 349 +2
Lines 61934 61976 +42
Methods 0 0
Messages 0 0
Branches 9494 9501 +7
==========================================
- Hits 53016 52846 -170
- Misses 6255 6447 +192
- Partials 2663 2683 +20
|
|
@jona-sassenhagen feel free to test this version with any CNT file you may have laying around. It should give exactly the same output as eeglab. |
mne/io/cnt/cnt.py
Outdated
| if event_type == 3: | ||
| offset *= n_bytes * n_channels | ||
| event_time = offset - 900 - 75 * n_channels | ||
| event_time = int(round(event_time / float(n_channels * n_bytes))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why floating point operations? These should align well with integers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except that they don't. Needed to do this in order to replicate eeglab's output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or could eeglab's output be wrong in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, matlab is wrong. It should line up perfectly.
|
Tried it on my own files, works perfectly. |
larsoner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise LGTM. Please update whats_new.rst
| elif event_type == 2: | ||
| event_bytes = 19 | ||
| elif event_type == 3: | ||
| event_bytes = 19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif event_type in (2, 3): or do you see the current version as conceptually cleaner?
mne/io/cnt/cnt.py
Outdated
| if event_type == 3: | ||
| offset *= n_bytes * n_channels | ||
| event_time = offset - 900 - 75 * n_channels | ||
| event_time = event_time // (n_channels * n_bytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event_time //=
.cnt files used by NeuroScan systems support different ways of encoding events (perhaps these reflect old and new versions of the file format). MNE currently only supports types 1 and 2. This PR adds supports for the newer type 3 events.
ebcb016 to
32bfc04
Compare
|
I think this is ready to merge. I don't believe the travis failures are related to this PR. |
|
LGTM |
|
+1 for merge when Travis is happy |
|
cov plot is breaking things again. I'll try to look soon. In the meantime the CIs are happy otherwise. |
|
Thanks @wmvanvliet |
|
Thanks @wmvanvliet ! |
|
I'm looking at this thread, does anyone have testing data with event_type 2 and 3 ? cross reference #5493 |
.cnt files used by NeuroScan systems support different ways of encoding events (perhaps these reflect old and new versions of the file format). MNE currently only supports types 1 and 2. This PR adds supports for the newer type 3 events.
Closes #3882