Getting started with bffile
bffile is a modern Bio-Formats wrapper for Python.
It exposes the full power of Bio-Formats in a clean Pythonic API backed by lazy data access.
Features
- Full lazy indexing and slicing
(with no additional dependencis on dask/xarray/zarr) with
bffile.LazyBioArray - Custom zarr store presents files as complete multi-resolution OME-Zarr group
- Export to xarray DataArray with metadata-aware dimension and coordinate labels
- Export to Dask arrays for parallel and out-of-core computation
Batteries included
No special environment setup is required, thanks to
scyjava,
jgo,
jpype, and
cjdk:
just pip install bffile and you're ready to go.
Installation
pip install bffile
Optional extras for zarr, xarray, and dask support, include:
pip install bffile[zarr,xarray,dask]
Quick start
import bffile
# load directly into memory
data = bffile.imread("path/to/file", series=0)
# or use lazy access to load only what you need
with bffile.BioFile("path/to/file") as biofile:
# lazy series accessor
lazy_array = biofile[0].as_array()
# Load data into memory (T=0, C=1:4, Z=all, Y=100:200)
data = lazy_array[0, 1:4, :, 100:200]
See usage for more details and examples.