Skip to content

Conversation

@wmvanvliet
Copy link
Contributor

@wmvanvliet wmvanvliet commented Jan 17, 2017

.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

@jona-sassenhagen
Copy link
Contributor

Closes #3882

:D

@wmvanvliet
Copy link
Contributor Author

Problem is: I don't have an easy means of generating a small test CNT file with these type of events.

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:
Copy link
Contributor

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} ?

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)
Copy link
Contributor

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)

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right.

@jona-sassenhagen
Copy link
Contributor

Problem is: I don't have an easy means of generating a small test CNT file with these type of events.

Me neither.

But the code is exactly what I did for my own file.

@wmvanvliet
Copy link
Contributor Author

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.

@wmvanvliet
Copy link
Contributor Author

(seems to check out with eeglab on my data)

@wmvanvliet wmvanvliet changed the title Add support for event_type=3 when reading CNT data [MRG] Add support for event_type=3 when reading CNT data Jan 18, 2017
@codecov-io
Copy link

codecov-io commented Jan 18, 2017

Current coverage is 85.26% (diff: 33.33%)

Merging #3911 into master will decrease coverage by 0.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   

Sunburst

Powered by Codecov. Last update 953764b...99cb51b

@wmvanvliet wmvanvliet changed the title [MRG] Add support for event_type=3 when reading CNT data [WIP] Add support for event_type=3 when reading CNT data Jan 18, 2017
@wmvanvliet
Copy link
Contributor Author

@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.

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)))
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@jona-sassenhagen
Copy link
Contributor

Tried it on my own files, works perfectly.

Copy link
Member

@larsoner larsoner left a 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
Copy link
Member

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?

if event_type == 3:
offset *= n_bytes * n_channels
event_time = offset - 900 - 75 * n_channels
event_time = event_time // (n_channels * n_bytes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event_time //=

@larsoner larsoner added this to the 0.14 milestone Jan 20, 2017
.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.
@wmvanvliet wmvanvliet changed the title [WIP] Add support for event_type=3 when reading CNT data [MRG] Add support for event_type=3 when reading CNT data Jan 24, 2017
@wmvanvliet
Copy link
Contributor Author

I think this is ready to merge. I don't believe the travis failures are related to this PR.

@jaeilepp
Copy link
Contributor

LGTM

@agramfort
Copy link
Member

+1 for merge when Travis is happy

@larsoner
Copy link
Member

cov plot is breaking things again. I'll try to look soon. In the meantime the CIs are happy otherwise.

@larsoner larsoner merged commit a94f81a into mne-tools:master Jan 24, 2017
@larsoner
Copy link
Member

Thanks @wmvanvliet

@wmvanvliet wmvanvliet deleted the event_type branch January 24, 2017 14:19
@jona-sassenhagen
Copy link
Contributor

Thanks @wmvanvliet !

@massich
Copy link
Contributor

massich commented Mar 5, 2019

I'm looking at this thread, does anyone have testing data with event_type 2 and 3 ?

cross reference #5493

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

Successfully merging this pull request may close these issues.

7 participants