forked from mne-tools/mne-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MRG][FIX] Fix GDF returning all annotations with same description (m…
…ne-tools#5866) * fix GDF annotations * sanitizing * deprecate find_edf_events * update whatsnew * TST: find_edf_events deprecation * wip * use a simple function and call it when loading the module * add the gdf_encodes.txt * Fix gdf test * Clean-up * remove one function * Python is really nice! * fix nitpicks (+ adding missing file) * skip test * missing file to manifest + sdist * typo + comments * fix md5
- Loading branch information
Showing
9 changed files
with
384 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Helper functions for EDF, EDF+, BDF converters to FIF.""" | ||
|
||
# Authors: Teon Brooks <teon.brooks@gmail.com> | ||
# Martin Billinger <martin.billinger@tugraz.at> | ||
# Nicolas Barascud <nicolas.barascud@ens.fr> | ||
# Stefan Appelhoff <stefan.appelhoff@mailbox.org> | ||
# Joan Massich <mailsik@gmail.com> | ||
# | ||
# License: BSD (3-clause) | ||
|
||
import re | ||
from ...utils import hashfunc | ||
|
||
|
||
def _load_gdf_events_lut(fname, md5): | ||
if hashfunc(fname, hash_type='md5') != md5: | ||
raise ValueError("File %s is corrupted. mdf5 hashes don't match." % | ||
fname) | ||
|
||
# load the stuff | ||
with open(fname, 'r') as fh: | ||
elements = [line for line in fh if not line.startswith("#")] | ||
|
||
event_id, event_name = list(), list() | ||
for elem in elements: | ||
event_id_i, *event_name_i = elem.split('\t') | ||
event_id.append(int(event_id_i, 0)) | ||
clean_name = re.sub('[ \t]+', ' ', ' '.join(event_name_i)) | ||
clean_name = re.sub('\n', '', clean_name) | ||
event_name.append(clean_name) | ||
|
||
return dict(zip(event_id, event_name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.