Comments (3)
Awesome, this information dates back to ABF1 files so we have some documentation:
https://swharden.com/pyabf/abf1-file-format.md.html#the-abf-synch-section
The ABF Synch Section
The ABF Synch array is an important array that stores the start time and length
of each portion of the data if the data are not part of a continuous gap-free
acquisition. The data section might contain equal length or variable length
sweeps of data. The Synch Array contains a record to indicate the start time
and length of every sweep or Event in the data file. The ABF reading routines
automatically decode the Synch Array when providing information about the data.
A Synch array is created and used in the following acquisition modes:
ABF_VARLENEVENTS, ABF_FIXLENEVENTS & ABF_HIGHSPEEDOSC. The acquisition modes
ABF_GAPFREEFILE and ABF_WAVEFORMFILE do not always use a Synch array.
Offset | Header Entry Name | Type | Description |
---|---|---|---|
0 | lStart | long | Start time of sweep in fSynchTimeUnit units. |
4 | lLength | long | Length of the sweep in multiplexed samples. |
from pyabf.
I got this working in concept...
# THIS EXAMPLE ASSUMES A SINGLE CHANNEL
filePath = DATA_FOLDER + "/2020_06_16_0000.abf"
abf = pyabf.ABF(filePath)
sweepYs = []
sweepXs = []
with open(filePath, 'rb') as fb:
fb.seek(abf.dataByteStart)
for sweepIndex in abf.sweepList:
firstPoint = abf._syncArraySection.lStart[sweepIndex]
pointCount = abf._syncArraySection.lLength[sweepIndex]
sweepY = np.fromfile(fb, dtype=abf._dtype, count=pointCount)
sweepY = np.multiply(sweepY, abf._dataGain)
sweepY = np.add(sweepY, abf._dataOffset)
sweepYs.append(sweepY)
offsetSec = firstPoint / abf.dataRate
sweepX = np.arange(len(sweepY)) / abf.dataRate + offsetSec
sweepXs.append(sweepX)
plt.figure()
for i in abf.sweepList:
plt.plot(sweepXs[i], sweepYs[i])
plt.show()
Implementing this in the core pyABF library will require extreme care to ensure the existing behavior for fixed-length sweeps remains unmodified. The ABF reading function is definitely one I do not want to break 😅 I'm happy I'm protected by thousands of automated tests, but still, to avoid headaches I'll only move on this when I'm ready to approach this very carefully.
from pyabf.
Got it all figured out, merged in, and it's now live on pypi (pyabf 2.2.6)
pip install --upgrade pyabf
The sweepY
list may now be a variable size, and if absoluteTime
is True
then sweepX
returns proper times in the recording. With variable length recordings this means gaps in the data may be present:
import pyabf
import matplotlib.pyplot as plt
abf = pyabf.ABF("2020_06_16_0000.abf")
for sweepIndex in abf.sweepList:
abf.setSweep(sweepIndex, absoluteTime=True)
plt.plot(abf.sweepX, abf.sweepY)
plt.show()
from pyabf.
Related Issues (20)
- pyabf compatibility with pyInstaller HOT 4
- Support protocols with user list epoch durations HOT 10
- add type hints and improve documentation
- ABF() should accept a pathlib.Path
- Stop warning when invalid dates are detected
- refactor header reader into smaller files
- AttributeError in module pyabf.tools when trying to use Memtest HOT 2
- Fails to load files with more adc channels than dac channels HOT 3
- ABF.sampleRate
- FFT/Spectrogram analysis of ABF data HOT 10
- Memory usage builds up when iteratively open abf files HOT 6
- Tutorial code - Plot the Command Waveform HOT 1
- add return types to properties HOT 5
- investigate memory management in long-running applications HOT 2
- error: unpack requires a buffer of 1 bytes (end of file reached) HOT 5
- Folder loop with pyabf HOT 2
- parent/child grouping
- ValueError when printing the header HOT 3
- How to read the epoch that a user list is applied to?
- Acces to Telegraphed Gain HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyabf.