|
14 | 14 | and available here: |
15 | 15 | http://www.mathworks.com/matlabcentral/fileexchange/22114-abf2load |
16 | 16 |
|
| 17 | +
|
| 18 | +The StringsSection parsing (parse_axon_soup) now relies on an idea |
| 19 | +presented in pyABF MIT License Copyright (c) 2018 Scott W Harden |
| 20 | +written by Scott Harden. His unofficial documentation for the formats |
| 21 | +is here: |
| 22 | +https://swharden.com/pyabf/abf2-file-format/ |
| 23 | +
|
| 24 | +
|
17 | 25 | Information on abf 1 and 2 formats is available here: |
18 | 26 | http://www.moleculardevices.com/pages/software/developer_info.html |
19 | 27 |
|
@@ -461,21 +469,19 @@ def parse_axon_soup(filename): |
461 | 469 | # strings sections |
462 | 470 | # hack for reading channels names and units |
463 | 471 | # this section is not very detailed and so the code |
464 | | - # not very robust. The idea is to remove the first |
465 | | - # part by finding one of th following KEY |
466 | | - # unfortunately the later part contains a the file |
467 | | - # that can contain by accident also one of theses keys... |
| 472 | + # not very robust. |
468 | 473 | f.seek(sections["StringsSection"]["uBlockIndex"] * BLOCKSIZE) |
469 | 474 | big_string = f.read(sections["StringsSection"]["uBytes"]) |
470 | | - goodstart = -1 |
471 | | - for key in [b"AXENGN", b"clampex", b"Clampex", b"EDR3", b"CLAMPEX", b"axoscope", b"AxoScope", b"Clampfit"]: |
472 | | - # goodstart = big_string.lower().find(key) |
473 | | - goodstart = big_string.find(b"\x00" + key) |
474 | | - if goodstart != -1: |
475 | | - break |
476 | | - assert goodstart != -1, "This file does not contain clampex, axoscope or clampfit in the header" |
477 | | - big_string = big_string[goodstart + 1 :] |
478 | | - strings = big_string.split(b"\x00") |
| 475 | + |
| 476 | + # this idea comes from pyABF https://github.com/swharden/pyABF |
| 477 | + # previously we searched for clampex, Clampex etc, but this was |
| 478 | + # brittle. pyABF believes that looking for the \x00\x00 is more |
| 479 | + # robust. We find these values, replace mu->u, then split into |
| 480 | + # a set of strings |
| 481 | + indexed_string = big_string[big_string.rfind(b'\x00\x00'):] |
| 482 | + indexed_string = indexed_string.replace(b'\xb5', b'\x75') |
| 483 | + indexed_string = indexed_string.split(b'\x00') |
| 484 | + strings = indexed_string |
479 | 485 |
|
480 | 486 | # ADC sections |
481 | 487 | header["listADCInfo"] = [] |
|
0 commit comments