Skip to main content

image CI pre-commit.ci status Publish documentation Build and upload to PyPI Coverage DOI

Action Potential features

ap_features is package for computing features of action potential traces. This includes chopping, background correction and feature calculations.

Parts of this library is written in numba and is therefore highly performant. This is useful if you want to do feature calculations on a large number of traces.

Quick start

import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp

import ap_features as apf

time = np.linspace(0, 999, 1000)
res = solve_ivp(
    apf.testing.fitzhugh_nagumo,
    [0, 1000],
    [0.0, 0.0],
    t_eval=time,
)
trace = apf.Beats(y=res.y[0, :], t=time)
print(f"Number of beats: {trace.num_beats}")
print(f"Beat rates: {trace.beat_rates}")

# Get a list of beats
beats = trace.beats
# Pick out the second beat
beat = beats[1]

# Compute features
print(f"APD30: {beat.apd(30):.3f}s, APD80: {beat.apd(80):.3f}s")
print(f"cAPD30: {beat.capd(30):.3f}s, cAPD80: {beat.capd(80):.3f}s")
print(f"Time to peak: {beat.ttp():.3f}s")
print(f"Decay time from max to 90%: {beat.tau(a=0.1):.3f}s")
Number of beats: 5
Beat rates: [779.2207792207793, 769.2307692307693, 779.2207792207793, 759.493670886076]
APD30: 37.823s, APD80: 56.564s
cAPD30: 88.525s, cAPD80: 132.387s
Time to peak: 21.000s
Decay time from max to 90%: 53.618s

Install

Install the package with pip

python -m pip install ap_features

See installation instructions for more options.

Available features

The list of currently implemented features are as follows

  • Action potential duration (APD)
  • Corrected action potential duration (cAPD)
  • Decay time (Time for the signal amplitude to go from maximum to (1 - a) * 100 % of maximum)
  • Time to peak (ttp)
  • Upstroke time (time from (1-a)*100 % signal amplitude to peak)
  • Beating frequency
  • APD up (The duration between first intersections of two APD lines)
  • Maximum relative upstroke velocity
  • Maximum upstroke velocity
  • APD integral (integral of the signals above the APD line)

Documentation

Documentation is hosted at GitHub pages: https://computationalphysiology.github.io/ap_features/

Note that the documentation is written using jupyterbook and contains an interactive demo

License

  • Free software: LGPLv2.1

Source Code

Release files for ap-features 2026.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ap-features 2026.2.1
File Size Uploaded
ap_features-2026.2.1.tar.gz 449.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ap-features 2026.2.1
File Interpreter ABI Platform
ap_features-2026.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 500.9 kB

Release files / ap_features-2026.2.1.tar.gz

Download URL ap_features-2026.2.1.tar.gz
Size 449.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5a69c59e79cf6c5b8503a2b30ed52ff2c3cae10334aa8b29b6d659ed9db725ef
BLAKE2b-256 checksum
How to use checksums
2b51d6caaec35c06ebdc5b5baa551c0298cf6d7816bec18eb67dc0ffba4dd8d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 25, 2026.

Transparency log

Release files / ap_features-2026.2.1-py3-none-any.whl

Download URL ap_features-2026.2.1-py3-none-any.whl
Size 51.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fa87316c84616608d9689911e3d9ee2232d5f969ce5e36517bffb4f8b14758d
BLAKE2b-256 checksum
How to use checksums
242a551774e0d4e74e647e640c7f13fd79bf2727328fa6eecdcebca26186551e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.2.1 This release

2 release files

0.1.2

10 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page