0
# Data Access and Properties
1
2
Access to sweep data, time series, metadata, and file properties through the ABF/ATF object interfaces. All data access properties require calling `setSweep()` first to select the active sweep and channel.
3
4
## Capabilities
5
6
### Primary Data Properties
7
8
Core data access properties available after calling `setSweep()`.
9
10
```python { .api }
11
# Data attributes (set by setSweep method)
12
sweepY: np.ndarray
13
"""
14
ADC data for the current sweep and channel.
15
16
Returns:
17
numpy array of voltage/current measurements in native units
18
(typically mV for voltage clamp, pA for current clamp)
19
20
Note: Must call setSweep() before accessing this attribute
21
"""
22
23
sweepX: np.ndarray
24
"""
25
Time values for the current sweep.
26
27
Returns:
28
numpy array of time points in seconds
29
30
Behavior depends on absoluteTime parameter in setSweep():
31
- False (default): Time from start of current sweep
32
- True: Absolute time from start of recording
33
"""
34
35
@property
36
def sweepC(self) -> np.ndarray:
37
"""
38
Command waveform (DAC) data for the current sweep.
39
40
Returns:
41
numpy array of command values in native units
42
(typically mV for voltage commands, pA for current commands)
43
44
Note: Returns the stimulus waveform applied during this sweep.
45
Can also be used as setter: abf.sweepC = new_data
46
"""
47
```
48
49
### Advanced Data Access
50
51
Additional data access methods and properties.
52
53
```python { .api }
54
55
def sweepD(self, digOutNumber: int = 0) -> np.ndarray:
56
"""
57
Digital output data for the current sweep.
58
59
Parameters:
60
- digOutNumber: Digital output channel number (0-based)
61
62
Returns:
63
numpy array of digital output states (0 or 1)
64
"""
65
66
@property
67
def sweepTimesSec(self) -> np.ndarray:
68
"""
69
Time values in seconds for current sweep.
70
71
Returns:
72
numpy array of time points in seconds
73
"""
74
75
@property
76
def sweepTimesMin(self) -> np.ndarray:
77
"""
78
Time values in minutes for current sweep.
79
80
Returns:
81
numpy array of time points in minutes
82
"""
83
84
@property
85
def sweepDerivative(self) -> np.ndarray:
86
"""
87
Derivative of the current sweep data.
88
89
Returns:
90
numpy array representing dY/dt of current sweep
91
"""
92
```
93
94
### Multi-Sweep Data Access
95
96
Methods for accessing data across all sweeps.
97
98
```python { .api }
99
def getAllYs(self, channelIndex: int = 0) -> np.ndarray:
100
"""
101
Get all sweep data for a specific channel.
102
103
Parameters:
104
- channelIndex: Zero-indexed channel number
105
106
Returns:
107
1D numpy array containing all data for the specified channel
108
"""
109
110
def getAllXs(self, channelIndex: int = 0) -> np.ndarray:
111
"""
112
Get time array for a specific channel.
113
114
Parameters:
115
- channelIndex: Zero-indexed channel number
116
117
Returns:
118
1D numpy array of time points in seconds
119
"""
120
```
121
122
### File Properties
123
124
Core properties describing the file and data structure.
125
126
```python { .api }
127
@property
128
def sweepCount(self) -> int:
129
"""Number of sweeps in the file."""
130
131
@property
132
def channelCount(self) -> int:
133
"""Number of data channels."""
134
135
# File attributes
136
sweepPointCount: int
137
"""Number of data points per sweep."""
138
139
@property
140
def sampleRate(self) -> int:
141
"""Sample rate in Hz."""
142
143
dataRate: float
144
"""Data acquisition rate."""
145
```
146
147
### Channel Information
148
149
Attributes for accessing channel names and units.
150
151
```python { .api }
152
# Channel attributes (lists)
153
adcNames: List[str]
154
"""List of ADC channel names."""
155
156
adcUnits: List[str]
157
"""List of ADC channel units."""
158
159
dacNames: List[str]
160
"""List of DAC channel names."""
161
162
dacUnits: List[str]
163
"""List of DAC channel units."""
164
```
165
166
### Usage Examples
167
168
```python
169
import pyabf
170
import numpy as np
171
172
# Load file and access single sweep data
173
abf = pyabf.ABF("recording.abf")
174
abf.setSweep(0)
175
176
# Basic data access
177
voltage = abf.sweepY # ADC data (e.g., membrane potential)
178
time = abf.sweepX # Time points
179
command = abf.sweepC # Command waveform (e.g., current injection)
180
181
print(f"Sweep duration: {time[-1]} seconds")
182
print(f"Data points: {len(voltage)}")
183
print(f"Sample rate: {abf.sampleRate} Hz")
184
185
# Access different sweeps
186
for sweep_num in range(abf.sweepCount):
187
abf.setSweep(sweep_num)
188
max_voltage = np.max(abf.sweepY)
189
print(f"Sweep {sweep_num} max voltage: {max_voltage} mV")
190
191
# Multi-channel data
192
if abf.channelCount > 1:
193
for channel in range(abf.channelCount):
194
abf.setSweep(0, channel=channel)
195
data = abf.sweepY
196
print(f"Channel {channel} ({abf.adcNames[channel]}): "
197
f"{len(data)} points in {abf.adcUnits[channel]}")
198
199
# Get all data at once
200
all_sweeps = abf.getAllYs(channelIndex=0) # Shape: (sweeps, points)
201
all_times = abf.getAllXs(channelIndex=0)
202
203
# Calculate mean across all sweeps
204
mean_sweep = np.mean(all_sweeps, axis=0)
205
206
# Access digital outputs
207
abf.setSweep(0)
208
digital_out = abf.sweepD(digOutNumber=0)
209
210
# Absolute time mode
211
abf.setSweep(5, absoluteTime=True)
212
absolute_time = abf.sweepX # Time from recording start
213
```
214
215
## Data Units and Scaling
216
217
```python { .api }
218
# Data is automatically scaled to appropriate units
219
# ADC data: typically mV (voltage) or pA (current)
220
# DAC data: typically mV (voltage commands) or pA (current commands)
221
# Time data: always in seconds
222
# Digital data: 0 or 1 (boolean states)
223
224
# Channel units are available via:
225
voltage_units = abf.adcUnits[0] # e.g., "mV"
226
command_units = abf.dacUnits[0] # e.g., "pA"
227
```