or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

0

# pyABF

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: pyabf

7

- **Language**: Python

8

- **Installation**: `pip install pyabf`

9

10

## Core Imports

11

12

```python

13

import pyabf

14

```

15

16

For accessing main classes:

17

18

```python

19

from pyabf import ABF, ATF

20

```

21

22

## Basic Usage

23

24

```python

25

import pyabf

26

27

# Load an ABF file

28

abf = pyabf.ABF("data.abf")

29

30

# Access basic file information

31

print(f"File contains {abf.sweepCount} sweeps")

32

print(f"Sample rate: {abf.sampleRate} Hz")

33

34

# Set the active sweep and access data

35

abf.setSweep(0)

36

voltage_data = abf.sweepY # ADC data (mV)

37

time_data = abf.sweepX # Time values (seconds)

38

command_data = abf.sweepC # Command waveform (DAC)

39

40

# Iterate through all sweeps

41

for sweepNumber in range(abf.sweepCount):

42

abf.setSweep(sweepNumber)

43

print(f"Sweep {sweepNumber}: {len(abf.sweepY)} data points")

44

45

# For ATF files (Axon Text Format)

46

atf = pyabf.ATF("data.atf")

47

atf.setSweep(0)

48

data = atf.sweepY

49

```

50

51

## Architecture

52

53

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

54

55

- **ABF Class**: Primary interface for Axon Binary Format files (ABF1 and ABF2)

56

- **ATF Class**: Interface for Axon Text Format files with similar API

57

58

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.

59

60

## Capabilities

61

62

### Core File Access

63

64

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

65

66

```python { .api }

67

class ABF:

68

def __init__(

69

self,

70

abfFilePath: Union[str, pathlib.Path],

71

loadData: bool = True,

72

cacheStimulusFiles: bool = True,

73

stimulusFileFolder: Union[str, None] = None

74

): ...

75

76

def setSweep(

77

self,

78

sweepNumber: int = 0,

79

channel: int = 0,

80

absoluteTime: bool = False

81

) -> None: ...

82

83

class ATF:

84

def __init__(

85

self,

86

atfFilePath: Union[str, pathlib.Path],

87

loadData: bool = True

88

): ...

89

90

def setSweep(self, sweepNumber: int = 0, channel: int = 0) -> None: ...

91

```

92

93

[Core File Access](./core-file-access.md)

94

95

### Data Access and Properties

96

97

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

98

99

```python { .api }

100

# Data access properties (available after setSweep)

101

@property

102

def sweepY(self) -> np.ndarray: ...

103

104

@property

105

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

106

107

@property

108

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

109

110

# File properties

111

@property

112

def sampleRate(self) -> int: ...

113

114

@property

115

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

116

117

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

118

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

119

```

120

121

[Data Access](./data-access.md)

122

123

### File Information and Metadata

124

125

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

126

127

```python { .api }

128

def headerText(self) -> str: ...

129

def headerMarkdown(self) -> str: ...

130

def headerHTML(self) -> str: ...

131

def headerLaunch(self) -> None: ...

132

133

@property

134

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

135

136

@property

137

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

138

139

@property

140

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

141

```

142

143

[File Information](./file-information.md)

144

145

### Analysis Tools

146

147

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

148

149

```python { .api }

150

from pyabf.tools import ap, memtest, sweep

151

152

# Action potential analysis

153

def ap_points_currentSweep(

154

abf,

155

dVthresholdPos: float = 15,

156

betweenSec1: Union[float, None] = None,

157

betweenSec2: Union[float, None] = None

158

) -> List[int]: ...

159

160

class Memtest:

161

def __init__(self, abf: ABF, channel: int = 0): ...

162

def summary(self) -> str: ...

163

```

164

165

[Analysis Tools](./analysis-tools.md)

166

167

### Utilities and Extensions

168

169

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

170

171

```python { .api }

172

from pyabf import abfWriter, filter, stimulus

173

174

def writeABF1(

175

sweepData: np.ndarray,

176

filename: Union[str, pathlib.Path],

177

sampleRateHz: float,

178

units: str = 'pA'

179

) -> None: ...

180

181

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

182

```

183

184

[Utilities](./utilities.md)

185

186

## Package Utilities

187

188

```python { .api }

189

def info() -> None: ...

190

def showInfo() -> None: ...

191

def help() -> None: ...

192

193

__version__: str

194

```

195

196

## Types

197

198

```python { .api }

199

import numpy as np

200

from typing import Union, List, Tuple

201

import pathlib

202

203

# Main types used throughout the API

204

Union[str, pathlib.Path] # File paths

205

np.ndarray # Data arrays

206

List[int] # Index lists

207

Tuple[str, str] # Name/unit pairs

208

```