diff --git a/dev/python/2024-09-17 verjinia.py b/dev/python/2024-09-17 verjinia.py new file mode 100644 index 0000000..444ef54 --- /dev/null +++ b/dev/python/2024-09-17 verjinia.py @@ -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) \ No newline at end of file diff --git a/src/pyabf/abf.py b/src/pyabf/abf.py index cb2b0c7..e0da035 100644 --- a/src/pyabf/abf.py +++ b/src/pyabf/abf.py @@ -327,8 +327,8 @@ def _readHeadersV2(self, fb: BufferedReader): try: # This is the correct way, but it doesn't seem to work for every ABF. # I think this is because there is a bug in the string indexer. - #self.userList = self._stringsIndexed.indexedStrings[self._userListSection.nStringIndex[0]] - #self.userList = [float(x) for x in self.userList.split(",")] + # self.userList = self._stringsIndexed.indexedStrings[self._userListSection.nStringIndex[0]] + # self.userList = [float(x) for x in self.userList.split(",")] # This is weird but it's been in the code for a while and seems to work. firstBlockStrings = self._stringsSection._stringsRaw[0].split( @@ -351,6 +351,14 @@ 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): + self.dataPointCount = variableDataPointCount + # tags self.tagComments = self._tagSection.sComment self.tagTimesSec = self._tagSection.lTagTime @@ -376,7 +384,7 @@ def _readHeadersV2(self, fb: BufferedReader): self._dataGain = [1]*self.channelCount self._dataOffset = [0]*self.channelCount for i in range(self.channelCount): - #adcIndex = self._adcSection.nADCSamplingSeq[i] + # adcIndex = self._adcSection.nADCSamplingSeq[i] # NOTE: ADC sequence is handled inside the ADC section so it doesn't need to be handled here adcIndex = i self._dataGain[i] /= self._adcSection.fInstrumentScaleFactor[adcIndex]