A python package for background and shading correction of optical microscopy images
Project description
BaSiCPy
A python package for background and shading correction of optical microscopy images
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.
Simple examples
Notebook | Description | Colab Link |
---|---|---|
timelapse_brightfield | 100 continuous brightfield frames of a time-lapse movie of differentiating mouse hematopoietic stem cells. | |
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. | |
WSI_brain | you can stitch image tiles together to view the effect of shading correction |
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 Mac (Intel chip), Linux or WSL2 users
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 Mac users with M1 / M2 chip
BaSiCPy requires jax
,
which has potential build issue with M1 chips.
One easiest solution is using Miniforge
as explained here.
In the Miniforge environment, please try the following:
conda install -c conda-forge jax jaxlib
pip install basicpy
For Windows users
BaSiCPy requires jax
which does not support Windows officially.
However, thanks to cloudhan/jax-windows-builder, we can install BaSiCPy as follows:
pip install "jax[cpu]==0.4.11" -f https://whls.blob.core.windows.net/unstable/index.html --use-deprecated legacy-resolver
pip install ml-dtypes==0.2.0
pip install basicpy
One may need to add
import jax
jax.config.update('jax_platform_name', 'cpu')
at the top of the script to ensure that JAX uses CPU.
For details and latest updates, see this issue.
Install with dev dependencies
git clone https://github.com/peng-lab/BaSiCPy.git
cd BaSiCPy
python -m venv venv
source venv/bin/activate
pip install -e '.[dev]'
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:
- New features and bug fixes should be pushed to
dev
- 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. - Additional fixes/features can be added to the current development release by using
bump2version build
. - 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file basicpy-1.2.0.tar.gz
.
File metadata
- Download URL: basicpy-1.2.0.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9775c595a7d05747e66668c267e6b829e21fc7a66a13878443e31a03a7133879 |
|
MD5 | edb866e4a3b1596b17e09d24facabbd9 |
|
BLAKE2b-256 | f3f6929b424c462de72654907b79010627892edc76260710e46fbb8914aa43f8 |
File details
Details for the file BaSiCPy-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: BaSiCPy-1.2.0-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cad5612e5f8f7b1ac6faa3a14f6bf9b34979efdd022fc58b72eb50ff73f9663c |
|
MD5 | e3761ee18adf668a0507d17ce904b7ea |
|
BLAKE2b-256 | cfa37b32e17ef275d2a33311ad595d186fce87e3e73e12d277825b616225b999 |