Skip to content

Commit

Permalink
Merge branch 'master' into persyst
Browse files Browse the repository at this point in the history
  • Loading branch information
adam2392 authored Sep 4, 2020
2 parents e8c32bd + 3d16144 commit 5f7f97f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ Changelog
- Add ``component_order`` parameter to :class:`mne.decoding.CSP` which allows switching between ``mutual_info`` (default) and ``alternate`` (a simpler and frequently used option) by `Martin Billinger`_ and `Clemens Brunner`_
- Speed up reading of annotations in EDF+ files by `Jeroen Van Der Donckt`_
- Add reader for Persyst (.lay + .dat format) data in :func:`mne.io.read_raw_persyst` by `Adam Li`_
Bug
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,5 @@
.. _Lau Møller Andersen: https://github.com/ualsbombe
.. _Martin Schulz: https://github.com/marsipu
.. _Jeroen Van Der Donckt: https://github.com/jvdd
13 changes: 8 additions & 5 deletions mne/io/edf/edf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Stefan Appelhoff <[email protected]>
# Joan Massich <[email protected]>
# Clemens Brunner <[email protected]>
# Jeroen Van Der Donckt (IDlab - imec) <[email protected]>
#
# License: BSD (3-clause)

Expand Down Expand Up @@ -1354,6 +1355,7 @@ def _read_annotations_edf(annotations):
triggers = re.findall(pat, annot_file.read())
else:
tals = bytearray()
annotations = np.atleast_2d(annotations)
for chan in annotations:
this_chan = chan.ravel()
if this_chan.dtype == np.int32: # BDF
Expand All @@ -1362,12 +1364,13 @@ def _read_annotations_edf(annotations):
# Why only keep the first 3 bytes as BDF values
# are stored with 24 bits (not 32)
this_chan = this_chan[:, :3].ravel()
for s in this_chan:
tals.extend(s)
# As ravel() returns a 1D array we can add all values at once
tals.extend(this_chan)
else:
for s in this_chan:
i = int(s)
tals.extend(np.uint8([i % 256, i // 256]))
this_chan = chan.astype(int)
# Exploit np vectorized processing
tals.extend(np.uint8([this_chan % 256, this_chan // 256])
.flatten('F'))

# use of latin-1 because characters are only encoded for the first 256
# code points and utf-8 can triggers an "invalid continuation byte"
Expand Down

0 comments on commit 5f7f97f

Please sign in to comment.