Skip to main content

BaSiCPy

A python package for background and shading correction of optical microscopy images

PyPI Status Python Version License Tests pre-commit Black Read the Docs

All Contributors

BaSiCPy is a python package for background and shading correction of optical microscopy images. It is developed based on the Matlab version of BaSiC tool with major improvements in the algorithm.

Reference:

  • BaSiCPy: A robust and scalable shadow correction tool for optical microscopy images (in prep.)
  • A BaSiC Tool for Background and Shading Correction of Optical Microscopy Images by Tingying Peng, Kurt Thorn, Timm Schroeder, Lichao Wang, Fabian J Theis, Carsten Marr*, Nassir Navab*, Nature Communication 8:14836 (2017). doi: 10.1038/ncomms14836.

Backend note

Starting from version 2.0, BaSiCPy uses a PyTorch backend as the primary implementation.

The earlier JAX-based implementation is still available through older releases of the package.

Simple examples

Notebook Description Colab Link
timelapse_brightfield 100 continuous brightfield frames of a time-lapse movie of differentiating mouse hematopoietic stem cells. Open In Colab
timelapse_nanog 189 continuous fluorescence frames of a time-lapse movie of differentiating mouse embryonic stem cells, which move much more slower compared to the fast moving hematopoietic stem cells, resulting in a much larger correlation between frames. Note that in this challenging case, the automatic parameters are no longer optimal, so we use the manual parameter setting (larger smooth regularization on both flat-field and dark-field) to improve BaSiC’s performance. Open In Colab
WSI_brain you can stitch image tiles together to view the effect of shading correction Open In Colab

You can also find examples of running the package at notebooks folder. Data used in the examples and a description can be downloaded from Zenodo.


Usage

See Read the Docs for the detailed usage.

Installation

For CPU version

Install from PyPI

pip install basicpy

or install the latest development version

git clone https://github.com/peng-lab/BaSiCPy.git
cd BaSiCPy
pip install .

For GPU version

To use BaSiCPy with GPU acceleration:

  • 🧩 Install PyTorch according to your system configuration by following the official PyTorch installation guide.
  • 💡 Install BaSiCPy (PyTorch backend only):
    pip install basicpy
    

Development

bump2version

This repository uses bump2version to manage dependencies. New releases are pushed to PyPi in the CI pipeline when a new version is committed with a version tag and pushed to the repo.

The development flow should use the following process:

  1. New features and bug fixes should be pushed to dev
  2. When tests have passed a new development version is ready to be release, use bump2version major|minor|patch. This will commit and create a new version tag with the -dev suffix.
  3. Additional fixes/features can be added to the current development release by using bump2version build.
  4. Once the new bugs/features have been tested and a main release is ready, use bump2version release to remove the -dev suffix.

After creating a new tagged version, push to Github and the version will be built and pushed to PyPi.

All-contributors

This repository uses All Contributors to manage the contributor list. Please execute the following to add/update contributors.

yarn
yarn all-contributors add username contribution
yarn all-contributors generate # to reflect the changes to README.md

For the possible contribution types, see the All Contributors documentation.

Contributors

Current version


Nicholas-Schaub

📆 👀 🚇 ⚠️ 💻 🤔

Tim Morello

💻 📖 👀 ⚠️ 🤔 🚇

Tingying Peng

🔣 💵 📆 📢 💻

Yohsuke T. Fukai

🔬 💻 🤔 👀 ⚠️ 💬 🚇

YuLiu-web

📖 📓

For details on the contribution roles, see the documentation.

Old version (f3fcf19), used as the reference implementation to check the approximate algorithm

  • Lorenz Lamm (@LorenzLamm)
  • Mohammad Mirkazemi (@Mirkazemi)

Metadata

Release files for BaSiCPy 2.0.0

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

Source distribution (sdist)

Source distribution for BaSiCPy 2.0.0
File Size Uploaded
basicpy-2.0.0.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for BaSiCPy 2.0.0
File Interpreter ABI Platform
basicpy-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.7 kB

Release files / basicpy-2.0.0.tar.gz

Download URL basicpy-2.0.0.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9d285b55e81908b9bb05850da54064066ae97c4ae8aefd28fac173fe4f605c17
BLAKE2b-256 checksum
How to use checksums
c5ce8aa1abe0c83933880d1af2610907ce68fa03d24b4e34d155d1e9ace8e571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / basicpy-2.0.0-py3-none-any.whl

Download URL basicpy-2.0.0-py3-none-any.whl
Size 27.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fae0b24ed237fb8093830e02b1cc4e417b9542ccad19d9c741d7789808e60c16
BLAKE2b-256 checksum
How to use checksums
03f7871b23aaccee8221b0b049242f3549c69cbb798c09bbc2709a705a27a600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7
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