Skip to content

Commit 016d6ee

Browse files
committed
Add more explanation, and some checks, for how we find the time units in the header of .pxp files [IgorIO]
1 parent 318e4ef commit 016d6ee

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

neo/io/igorproio.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,21 @@ def _wave_to_analogsignal(self, content, dirpath):
134134
name = str(header["bname"].decode("utf-8"))
135135
units = "".join([x.decode() for x in header["dataUnits"]])
136136
if "xUnits" in header:
137+
# "xUnits" is used in Versions 1, 2, 3 of .pxp files
137138
time_units = "".join([x.decode() for x in header["xUnits"]])
138139
elif "dimUnits" in header:
139-
time_units = header["dimUnits"].ravel()[0].decode()
140+
# Version 5 uses "dimUnits"
141+
# see https://github.com/AFM-analysis/igor2/blob/43fccf51714661fb96372e8119c59e17ce01f683/igor2/binarywave.py#L501
142+
_time_unit_structure = header["dimUnits"].ravel()
143+
# For the files we've seen so far, the first element of _time_unit_structure contains the units.
144+
# If someone has a file for which this assumption does not hold an Exception will be raised.
145+
if not all([element == b'' for element in _time_unit_structure[1:]]):
146+
raise Exception(
147+
"Neo cannot yet handle the units in this file. "
148+
"Please create a new issue in the Neo issue tracker at "
149+
"https://github.com/NeuralEnsemble/python-neo/issues/new/choose"
150+
)
151+
time_units = _time_unit_structure[0].decode()
140152
else:
141153
time_units = ""
142154
if len(time_units) == 0:

0 commit comments

Comments
 (0)