Skip to content

Commit

Permalink
ABF: improve support for variable sweep lengths
Browse files Browse the repository at this point in the history
resolves #140
  • Loading branch information
swharden committed Sep 17, 2024
1 parent 06247e0 commit f6019ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
19 changes: 19 additions & 0 deletions dev/python/2024-09-17 verjinia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
import pathlib

try:
PATH_HERE = pathlib.Path(__file__).parent
PATH_ABFS = PATH_HERE.joinpath("../../data/abfs/").resolve()
PATH_SRC = PATH_HERE.joinpath("../../src/").resolve()
print(PATH_SRC)
sys.path.insert(0, str(PATH_SRC))
import pyabf
except:
raise EnvironmentError()
1

if __name__ == "__main__":
abf = pyabf.ABF(R"C:\Users\swharden\Documents\Temp\24215056.abf")

for abf_path in pathlib.Path(PATH_ABFS).glob("*.abf"):
abf = pyabf.ABF(abf_path)
9 changes: 9 additions & 0 deletions src/pyabf/abf.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,15 @@ def _readHeadersV2(self, fb: BufferedReader):
self.sweepCount = self._headerV2.lActualEpisodes
self.channelList = list(range(self.channelCount))

# correct dataPointCount for ABFs with variable length sweeps
# https://github.com/swharden/pyABF/issues/140
# https://github.com/swharden/pyABF/issues/108
if hasattr(self, "_synchArraySection"):
variableDataPointCount = sum(self._synchArraySection.lLength)
if (variableDataPointCount > 0 and variableDataPointCount != self.dataPointCount):
print(f"Changing {self.dataPointCount:,} to {variableDataPointCount:,}")
self.dataPointCount = variableDataPointCount

# tags
self.tagComments = self._tagSection.sComment
self.tagTimesSec = self._tagSection.lTagTime
Expand Down

0 comments on commit f6019ae

Please sign in to comment.