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

ABF1 file writing bug #65

Closed
swharden opened this issue Dec 2, 2018 · 1 comment
Closed

ABF1 file writing bug #65

swharden opened this issue Dec 2, 2018 · 1 comment
Assignees

Comments

@swharden
Copy link
Owner

swharden commented Dec 2, 2018

At present the ABF file writer has a fixed scaling factor (fInstrumentScaleFactor, fSignalGain, fADCProgrammableGain, etc). This causes the ABF writer to crash if ABF values being saved are outside the range supported by the fixed scaling factor. For example, the current code will crash on voltage-clamp ABFs with data greater than +/- 1000 pA.

To correct this issue, the ABF writer will be made smarter by using a custom scaling factor determined by the maximum and minimum data values. This ticket will track progress toward this end.

A new ABF (f1.abf) was added to the data section to test against.

Relevant code (the section where the fixed scale factors are defined) is:

fSignalGain = 1 # always 1
fADCProgrammableGain = 1 # always 1
lADCResolution = 2**15 # 16-bit signed = +/- 32768
fInstrumentScaleFactor = 0.005 # good for -2k to +2k pA scale
fADCRange = 10
valueScale = lADCResolution / fADCRange * fInstrumentScaleFactor
struct.pack_into('i', data, 252, lADCResolution)
struct.pack_into('f', data, 244, fADCRange)
for i in range(16):
struct.pack_into('f', data, 922+i*4, fInstrumentScaleFactor)
struct.pack_into('f', data, 1050+i*4, fSignalGain)
struct.pack_into('f', data, 730+i*4, fADCProgrammableGain)
struct.pack_into('8s', data, 602+i*8, b'pA')

note: the original discussion about ABF1 file writing was at: #60 (comment)

@swharden swharden self-assigned this Dec 2, 2018
@swharden
Copy link
Owner Author

swharden commented Dec 3, 2018

This issue has been corrected in pyABF 2.0.31 (live now)

pip install --upgrade pyabf

@swharden swharden closed this as completed Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant