Skip to main content

ASWIFT peak fitting utilities for square-wave voltammetry

Project description

ASWIFT

ASWIFT fits square-wave voltammetry (SWV) traces and extracts peak signal, background, peak voltage, and full-prominence peak width. Use the no-code ASWIFT Viewer for interactive analysis, or install the Python package to build ASWIFT into a custom workflow.

Setup

ASWIFT is available as a standalone desktop application and as a Python package. The standalone application includes everything needed to run the viewer; Python is not required.

Install the desktop application

Precompiled applications are available in the release_assets directory. Download the archive that matches your computer:

Download System
macos-arm64 Apple Silicon Mac (M1, M2, M3, M4, or newer)
macos-x64 Intel-based Mac
windows-x64 64-bit Windows

Unzip the archive, then open ASWIFT Viewer. Because ASWIFT is distributed outside the Apple App Store and Microsoft Store, your operating system may show a security warning the first time it opens. Follow the system prompt to allow the application to run; on macOS, this may require approval under Privacy & Security.

Install the Python package

ASWIFT requires Python 3.12 or newer. Install the core fitting utilities with:

pip install aswift

Install the viewer, pandas CSV helpers, plotting tools, and PalmSens .pssession support with:

pip install "aswift[viewer]"

PalmSens support uses pypalmsens, which requires the Microsoft .NET 9 Runtime. If ASWIFT reports that it could not create a .NET runtime or CoreCLR, install the runtime and restart ASWIFT.

Activate the Python environment in which ASWIFT was installed, then launch the viewer:

aswift-viewer

Example notebooks for SWV fitting, CSV workflows, and PalmSens data are in the examples directory.

Using the ASWIFT Viewer

Annotated overview of the ASWIFT Viewer interface

The viewer displays the selected voltammogram and its fitted background and peak, a table of values extracted from that fit, and a trend plot across the full dataset.

Load data

Choose an input source in the sidebar, then upload one or more SWV data files or enter the path to a directory containing a PalmSens dataset. Download correctly formatted sample files from the v1.0.2 example-data archive.

ASWIFT supports three input formats:

  • PalmSens .pssession: Select PalmSens .pssession and enter a folder containing .pssession files. Subfolders are searched automatically. ASWIFT extracts available frequency, acquisition time, and channel metadata and saves processed results as a structured JSON file in the selected directory. While the viewer remains open, newly added files are detected and processed automatically. Files accidentally downloaded with a .pssession.mp3 suffix are renamed before processing.

  • CSV: Upload either a simple sweep with voltage in the first column and one or more current traces in subsequent columns, or a structured table with one complete voltammogram per row plus metadata such as channel and frequency. Simple sweeps may have a header row or no header row. UTF-8, UTF-8 BOM, UTF-16, and Latin-1 encodings are accepted.

  • JSON: Upload structured fit results previously generated by ASWIFT. This lets you reopen, visualize, and analyze a processed dataset without fitting the raw data again.

If a trace cannot be fit but its raw voltage and current are available, the viewer still displays the raw trace for inspection.

Inspect and process results

Use the sidebar controls to choose what appears in the fit and trend plots:

  • Fit method: Choose the ASWIFT or polynomial-linear fitting method.
  • Workers: Increase the number of worker processes to accelerate larger datasets on multi-core computers.
  • Upload order: Keep uploaded order or sort uploaded files by file name.
  • Subfolder: Choose which PalmSens subfolder to inspect, or show all folders together.
  • Channel: Choose the potentiostat channel for the individual fit. Trend plots initially show all channels; click legend entries to hide or show them.
  • Frequency: Choose the SWV frequency shown in the individual fit and trend plots.
  • Sample index: Step through voltammograms for the selected folder, channel, and frequency. Samples are ordered by acquisition time when a timestamp is available and by upload order otherwise.
  • Normalize: Normalize peak heights to the average over a selected reference range. Normalization is calculated independently for every subfolder, method, frequency, and channel.

The Trend metric menu switches the time or measurement series among peak height, peak voltage, and full-prominence peak width when those values are available. Use the plot legend and toolbar to explore individual series.

Select Download results CSV at the bottom of the sidebar to export raw and normalized results with their associated metadata.

Python API

Fit and plot one trace

import numpy as np
from aswift import aswift_fit, plot_fit_result, poly_linear_fit

volts = np.asarray([...], dtype=float)
current = np.asarray([...], dtype=float)

result = aswift_fit(volts, current)
# Alternative model:
# result = poly_linear_fit(volts, current)

print(result.peak_signal, result.peak_voltage)
ax = plot_fit_result(result)

The returned FitResult contains:

  • peak_signal: background-subtracted peak height
  • peak_background: background current at the peak
  • peak_voltage: voltage at the peak maximum
  • fw_prominence: full-prominence peak width
  • peak_profile: fitted peak-only profile
  • background_profile: fitted background profile
  • fitted_current: combined peak and background profiles

Fit a structured dataframe

Use one row per voltammogram. The voltage and current columns each contain the full array for that trace; additional metadata columns such as file, hz, num, channel, and time are preserved. This workflow requires the batch, plot, or viewer extra.

from aswift import fit_dataframe, results_to_signal_table

results = fit_dataframe(df, method="aswift", n_workers=1)
signals = results_to_signal_table(
    results,
    calibration_lower_idx=0,
    calibration_upper_idx=4,
)

For large CPU-bound batches, independent traces can be fit in separate processes:

results = fit_dataframe(
    df,
    method="aswift",
    n_workers=4,
    parallel_backend="process",
    chunksize=16,
)

Single-worker fitting avoids process startup and serialization overhead and is often faster for small interactive datasets. Benchmark representative data before increasing n_workers.

Load PalmSens files

from aswift import fit_pssession_folder, pssession_folder_to_dataframe

df = pssession_folder_to_dataframe("path/to/pssession/folder", recursive=True)
df, results = fit_pssession_folder(
    "path/to/pssession/folder",
    recursive=True,
    n_workers=1,
)

ASWIFT orders traces using available timestamp, frequency, file number, and channel metadata. Elapsed time is reported in hours from the earliest measurement.

Development

Install the developer dependencies and run the test suite from the repository root:

python -m venv venv
source venv/bin/activate
python -m pip install -e ".[developer]"
NUMBA_CACHE_DIR=/private/tmp/numba-cache python -m pytest -q

Verify the distributable package with:

python -m build

Desktop packaging and release instructions are documented in release_assets/README.md. The maintainer checklist for publishing GitHub and PyPI releases is in docs/RELEASING.md.

Bug reports and feature requests

Please open a GitHub issue for bug reports, questions, feedback, or feature requests.

Citation

If you use ASWIFT in your research, please cite:

Yates, M., Ji, J., Yee, S., & Soh, H. T. (2026). Robust Regularization Enables Automated, Real-Time Square-Wave Voltammetry Signal Quantification. bioRxiv. https://doi.org/10.64898/2026.07.25.740173

Machine-readable citation metadata is available in CITATION.cff.

Acknowledgments

This work was supported by resources provided by the Soh Lab within Stanford University's School of Engineering. The authors thank Stan Yates for his development and consulting contributions in preparing ASWIFT for distribution as a PyPI package.

Author

Max Yates - PhD Candidate - GitHub profile

License

ASWIFT is licensed under the MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aswift-1.0.2.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aswift-1.0.2-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file aswift-1.0.2.tar.gz.

File metadata

  • Download URL: aswift-1.0.2.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for aswift-1.0.2.tar.gz
Algorithm Hash digest
SHA256 121eca2396c6f6fb5158b746996ccd26d0ded0d768e14239f2f9eece9303bd15
MD5 553e081ff20548ee61279f969457847d
BLAKE2b-256 ca296af50cdbd6b1875e6b7e292c2441580851a3f581c502c1219b1fed988e86

See more details on using hashes here.

Provenance

The following attestation bundles were made for aswift-1.0.2.tar.gz:

Publisher: publish-pypi.yml on Soh-Lab/aswift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aswift-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: aswift-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for aswift-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3b2149548b5a827080cc549c374ecfe0354cef5920d128c50110471ca18773d
MD5 abdde42ebe5e38d688f8b49628b84a65
BLAKE2b-256 a7c007e42b861af8f975c2a436cec0bf2ff18d9e756e5d04657875d75e479a30

See more details on using hashes here.

Provenance

The following attestation bundles were made for aswift-1.0.2-py3-none-any.whl:

Publisher: publish-pypi.yml on Soh-Lab/aswift

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page