Skip to content

Commit c0089de

Browse files
committed
fix the indices
1 parent 9745ba9 commit c0089de

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

neo/rawio/axonrawio.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
written by Scott Harden. His unofficial documentation for the formats
2121
is here:
2222
https://swharden.com/pyabf/abf2-file-format/
23-
23+
strings section:
24+
[uModifierNameIndex, uCreatorNameIndex, uProtocolPathIndex, lFileComment, lADCCChannelNames, lADCUnitsIndex
25+
lDACChannelNameIndex, lDACUnitIndex, lDACFilePath, nLeakSubtractADC]
26+
['', 'Clampex', '', 'C:/path/protocol.pro', 'some comment', 'IN 0', 'mV', 'IN 1', 'mV', 'Cmd 0', 'pA',
27+
'Cmd 1', 'pA', 'Cmd 2', 'mV', 'Cmd 3', 'mV']
2428
2529
Information on abf 1 and 2 formats is available here:
2630
http://www.moleculardevices.com/pages/software/developer_info.html
@@ -472,15 +476,17 @@ def parse_axon_soup(filename):
472476
# not very robust.
473477
f.seek(sections["StringsSection"]["uBlockIndex"] * BLOCKSIZE)
474478
big_string = f.read(sections["StringsSection"]["uBytes"])
475-
476479
# this idea comes from pyABF https://github.com/swharden/pyABF
477480
# previously we searched for clampex, Clampex etc, but this was
478481
# brittle. pyABF believes that looking for the \x00\x00 is more
479482
# robust. We find these values, replace mu->u, then split into
480483
# a set of strings
481484
indexed_string = big_string[big_string.rfind(b'\x00\x00'):]
485+
# replace mu -> u for easy display
482486
indexed_string = indexed_string.replace(b'\xb5', b'\x75')
483-
indexed_string = indexed_string.split(b'\x00')
487+
# we need to remove one of the \x00 to have the indices be
488+
# the correct order
489+
indexed_string = indexed_string.split(b'\x00')[1:]
484490
strings = indexed_string
485491

486492
# ADC sections
@@ -495,8 +501,8 @@ def parse_axon_soup(filename):
495501
ADCInfo[key] = val[0]
496502
else:
497503
ADCInfo[key] = np.array(val)
498-
ADCInfo["ADCChNames"] = strings[ADCInfo["lADCChannelNameIndex"] - 1]
499-
ADCInfo["ADCChUnits"] = strings[ADCInfo["lADCUnitsIndex"] - 1]
504+
ADCInfo["ADCChNames"] = strings[ADCInfo["lADCChannelNameIndex"]]
505+
ADCInfo["ADCChUnits"] = strings[ADCInfo["lADCUnitsIndex"]]
500506
header["listADCInfo"].append(ADCInfo)
501507

502508
# protocol sections
@@ -509,7 +515,7 @@ def parse_axon_soup(filename):
509515
else:
510516
protocol[key] = np.array(val)
511517
header["protocol"] = protocol
512-
header["sProtocolPath"] = strings[header["uProtocolPathIndex"] - 1]
518+
header["sProtocolPath"] = strings[header["uProtocolPathIndex"]]
513519

514520
# tags
515521
listTag = []
@@ -538,8 +544,8 @@ def parse_axon_soup(filename):
538544
DACInfo[key] = val[0]
539545
else:
540546
DACInfo[key] = np.array(val)
541-
DACInfo["DACChNames"] = strings[DACInfo["lDACChannelNameIndex"] - 1]
542-
DACInfo["DACChUnits"] = strings[DACInfo["lDACChannelUnitsIndex"] - 1]
547+
DACInfo["DACChNames"] = strings[DACInfo["lDACChannelNameIndex"]]
548+
DACInfo["DACChUnits"] = strings[DACInfo["lDACChannelUnitsIndex"]]
543549

544550
header["listDACInfo"].append(DACInfo)
545551

0 commit comments

Comments
 (0)