Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions neo/rawio/openephysbinaryrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,31 @@ def _parse_header(self):
# all theses data are put in event array annotations
if "text" in info:
# text case
info["labels"] = info["text"].astype("U")
try:
info["labels"] = info["text"].astype("U")
except UnicodeDecodeError:
info["labels"] = np.array([e.decode('utf-8') for e in info['text']], dtype='U')
elif "metadata" in info:
# binary case
info["labels"] = info["channels"].astype("U")
try:
info["labels"] = info["channels"].astype("U")
except UnicodeDecodeError:
# non-ascii character, fallback on UTF-8 decoding byte by byte
info["labels"] = np.array([e.decode('utf-8') for e in info['channels']], dtype='U')
elif "channels" in info:
# ttl case use channels
info["labels"] = info["channels"].astype("U")
try:
info["labels"] = info["channels"].astype("U")
except UnicodeDecodeError:
# non-ascii character, fallback on UTF-8 decoding byte by byte
info["labels"] = np.array([e.decode('utf-8') for e in info['channels']], dtype='U')
elif "states" in info:
# ttl case use states
info["labels"] = info["states"].astype("U")
try:
info["labels"] = info["states"].astype("U")
except UnicodeDecodeError:
# non-ascii character, fallback on UTF-8 decoding byte by byte
info["labels"] = np.array([e.decode('utf-8') for e in info['states']], dtype='U')
else:
raise ValueError(f"There is no possible labels for this event!")

Expand Down
Loading