PIMS (Python Image Sequence) provides a lazy-loading, NumPy-like interface for accessing sequential image and video data from various file formats. It handles diverse inputs, including image directories, TIFF stacks, and common video formats, offering a consistent API for slicing and iteration. The library is actively maintained, with a recent major release (v0.7) in June 2024.
pip install pimsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to open a sequence of image files using `pims.open`, access individual frames, iterate through the sequence, and use NumPy-like slicing. It includes a basic setup to create dummy image files if Pillow is available.
Ensure `Pillow` or `tifffile` are installed: `pip install Pillow tifffile`. If still encountering issues, consider converting problematic TIFF files to a format supported by other PIMS readers or using specific PIMS readers like `pims.TiffStack_tifffile`.
Review `numpy 2.0` migration guides (e.g., from NumPy official docs). If other dependencies are not yet compatible, you might need to pin an older `numpy` version (e.g., `numpy<2.0`) in your environment until all libraries are updated. Use `ruff` with the `NPY201` rule for automatic code adaptation if applicable to your project.
Migrate your code to use PIMS pipelines. For grayscale conversion, use `pims.as_grey(reader_object)`. For custom processing, define a function and decorate it with `@pims.pipeline`.
Install the necessary optional dependencies based on the file types you need to read. For video files, `pip install imageio-ffmpeg` or `pip install pyav` is often required. For Bio-formats, install `jpype1`. Refer to the PIMS documentation for a full list of format-specific dependencies.