Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect recording length for 2.0.0.0 gap-free files #139

Open
VonEconomo opened this issue Sep 12, 2024 · 5 comments
Open

Incorrect recording length for 2.0.0.0 gap-free files #139

VonEconomo opened this issue Sep 12, 2024 · 5 comments

Comments

@VonEconomo
Copy link

VonEconomo commented Sep 12, 2024

I work with files from various ABF versions, for version 2.0.0.0 files, self._protocolSection.fEpisodeStartToStart appears to be set to a value that's significantly smaller than the actual sweep length, leading to an underestimation of the sweep Interval (sweepIntervalSec), and subsequently the total recording length (dataLengthSec).

Problematic Code in abf.py:

pyABF/src/pyabf/abf.py

Lines 419 to 431 in 2a0c1b0

# set sweepIntervalSec (can be different than sweepLengthSec)
if self.abfVersion["major"] == 1:
self.sweepIntervalSec = self.sweepLengthSec
if self.abfVersion["major"] == 2:
self.sweepIntervalSec = self._protocolSection.fEpisodeStartToStart
if self.sweepIntervalSec == 0:
self.sweepIntervalSec = self.sweepLengthSec
# determine total ABF recording length
self.dataLengthSec = self.sweepIntervalSec*self.sweepCount
if self.sweepCount > 1:
self.dataLengthSec += self.sweepLengthSec
self.dataLengthMin = self.dataLengthSec / 60.0

In my case,

if self.sweepIntervalSec == 0:
                self.sweepIntervalSec = self.sweepLengthSec

does not seem to catch the issue. In the 2.0 recordings that are available to me, fEpisodeStartToStart is consistently reported as 5. I did not further investigate this issue and solved it for me by setting

self.sweepIntervalSec = self.sweepLengthSec

regardless of the version.

My question now:

Why use fEpisodeStartToStart at all?

@swharden

This comment was marked as outdated.

@swharden
Copy link
Owner

swharden commented Sep 12, 2024

Solution

I want to highlight your solution for others who may land here after searching for this issue:

this issue and solved it for me by setting

self.sweepIntervalSec = self.sweepLengthSec

My question now: Why use fEpisodeStartToStart at all?

ABFs can be configured with an inter-sweep interval that is different from the sweep length. E.g., "record a 5 second sweep once every 30 seconds". I assume this is why the header has separate lActualAcqLength and fEpisodeStartToStart values. It's possible that is is supported in newer "version 2" abf files, but not 2.0.0.0 files 🤔

@VonEconomo

This comment was marked as outdated.

@swharden
Copy link
Owner

Thanks! Here's a ZIP of the sample ABF file in question: V2_dataLengthSec_Example.zip

It looks this this is a gap free file, so the inter-sweep interval value may not be relevant to this recording. However, the bug you initially described that causes this gap-free file to be read incorrectly is important to resolve! I'll look into fixing this and making a new release shortly.

Thanks so much for reporting this!

@swharden swharden changed the title Incorrect dataLengthSec Calculation for ABF Version 2.0.0.0 Files Incorrect recording length for 2.0.0.0 gap-free files Sep 12, 2024
@VonEconomo
Copy link
Author

Thanks for the explanation and the swift response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants