or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

analysis-tools.mdcore-file-access.mddata-access.mdfile-information.mdindex.mdutilities.md
tile.json

tessl/pypi-pyabf

Python library for reading electrophysiology data from Axon Binary Format (ABF) files

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyabf@2.3.x

To install, run

npx @tessl/cli install tessl/pypi-pyabf@2.3.0

index.mddocs/

pyABF

A Python library for reading electrophysiology data from Axon Binary Format (ABF) files. pyabf provides an intuitive Pythonic API to access ABF file contents including sweep data, time series information, and command waveforms, making it ideal for electrophysiology research and data analysis workflows.

Package Information

  • Package Name: pyabf
  • Language: Python
  • Installation: pip install pyabf

Core Imports

import pyabf

For accessing main classes:

from pyabf import ABF, ATF

Basic Usage

import pyabf

# Load an ABF file
abf = pyabf.ABF("data.abf")

# Access basic file information
print(f"File contains {abf.sweepCount} sweeps")
print(f"Sample rate: {abf.sampleRate} Hz")

# Set the active sweep and access data
abf.setSweep(0)
voltage_data = abf.sweepY  # ADC data (mV)
time_data = abf.sweepX     # Time values (seconds)  
command_data = abf.sweepC  # Command waveform (DAC)

# Iterate through all sweeps
for sweepNumber in range(abf.sweepCount):
    abf.setSweep(sweepNumber)
    print(f"Sweep {sweepNumber}: {len(abf.sweepY)} data points")

# For ATF files (Axon Text Format)
atf = pyabf.ATF("data.atf")
atf.setSweep(0)
data = atf.sweepY

Architecture

pyabf is built around two main classes that provide similar interfaces:

  • ABF Class: Primary interface for Axon Binary Format files (ABF1 and ABF2)
  • ATF Class: Interface for Axon Text Format files with similar API

The library uses a sweep-based access pattern where you set an active sweep and then access data through properties like sweepY, sweepX, and sweepC. This design allows efficient memory usage and intuitive data access patterns familiar to electrophysiologists.

Capabilities

Core File Access

Primary classes for loading and accessing ABF and ATF files, with sweep-based data access patterns and comprehensive metadata extraction.

class ABF:
    def __init__(
        self, 
        abfFilePath: Union[str, pathlib.Path],
        loadData: bool = True,
        cacheStimulusFiles: bool = True,
        stimulusFileFolder: Union[str, None] = None
    ): ...
    
    def setSweep(
        self,
        sweepNumber: int = 0,
        channel: int = 0,
        absoluteTime: bool = False
    ) -> None: ...

class ATF:
    def __init__(
        self, 
        atfFilePath: Union[str, pathlib.Path],
        loadData: bool = True
    ): ...
    
    def setSweep(self, sweepNumber: int = 0, channel: int = 0) -> None: ...

Core File Access

Data Access and Properties

Access to sweep data, time series, metadata, and file properties through the ABF/ATF object interfaces.

# Data access properties (available after setSweep)
@property
def sweepY(self) -> np.ndarray: ...

@property  
def sweepX(self) -> np.ndarray: ...

@property
def sweepC(self) -> np.ndarray: ...

# File properties
@property
def sampleRate(self) -> int: ...

@property
def sweepCount(self) -> int: ...

def getAllYs(self, channelIndex: int = 0) -> np.ndarray: ...
def getAllXs(self, channelIndex: int = 0) -> np.ndarray: ...

Data Access

File Information and Metadata

Functions and properties for accessing file metadata, header information, and generating various output formats.

def headerText(self) -> str: ...
def headerMarkdown(self) -> str: ...
def headerHTML(self) -> str: ...
def headerLaunch(self) -> None: ...

@property
def fileGUID(self) -> str: ...

@property
def md5(self) -> str: ...

@property
def fileUUID(self) -> str: ...

File Information

Analysis Tools

Specialized analysis modules for action potential detection, membrane test analysis, and sweep-level measurements.

from pyabf.tools import ap, memtest, sweep

# Action potential analysis
def ap_points_currentSweep(
    abf, 
    dVthresholdPos: float = 15,
    betweenSec1: Union[float, None] = None,
    betweenSec2: Union[float, None] = None
) -> List[int]: ...

class Memtest:
    def __init__(self, abf: ABF, channel: int = 0): ...
    def summary(self) -> str: ...

Analysis Tools

Utilities and Extensions

Additional functionality including file writing, filtering, stimulus waveform handling, and deprecated plotting functions.

from pyabf import abfWriter, filter, stimulus

def writeABF1(
    sweepData: np.ndarray,
    filename: Union[str, pathlib.Path], 
    sampleRateHz: float,
    units: str = 'pA'
) -> None: ...

def gaussian(abf: ABF, sigmaMs: float = 5, channel: int = 0) -> ABF: ...

Utilities

Package Utilities

def info() -> None: ...
def showInfo() -> None: ...  
def help() -> None: ...

__version__: str

Types

import numpy as np
from typing import Union, List, Tuple
import pathlib

# Main types used throughout the API
Union[str, pathlib.Path]  # File paths
np.ndarray               # Data arrays
List[int]               # Index lists
Tuple[str, str]         # Name/unit pairs