Skip to main content

BSD 3-Clause License Python package index download statistics PyPI version

impy

impy is an all-in-one multi-dimensional image analysis library. The core array, ImgArray, is a subclass of numpy.ndarray, tagged with information such as:

  • image axes
  • scale of each axis
  • directory of the original image
  • and other image metadata

Documentation

Documentation is available here.

Installation

  • use pip
pip install impy-array
pip install impy-array[tiff]    # with supports for reading/writing .tif files
pip install impy-array[mrc]     # with supports for reading/writing .mrc files
pip install impy-array[napari]  # viewer support
pip install impy-array[all]     # install everything
  • from source
git clone https://github.com/hanjinliu/impy

Code as fast as you speak

Almost all the functions, such as filtering, deconvolution, labeling, single molecule detection, and even those pure numpy functions, are aware of image metadata. They "know" which dimension corresponds to "z" axis, which axes they should iterate along or where to save the image. As a result, your code will be very concise:

import impy as ip
import numpy as np

img = ip.imread("path/to/image.tif")   # Read images with metadata.
img["z=3;t=0"].imshow()                # Plot image slice at z=3 and t=0.
img["y=N//4:N//4*3"].imshow()          # `N` for the size of the axis.
img_fil = img.gaussian_filter(sigma=2) # Paralell batch denoising. No more for loop!
img_prj = np.max(img_fil, axis="z")    # Z-projection (numpy is aware of image axes!).
img_prj.imsave("image_max.tif")        # Save in the same place. Don't spend time on searching for the directory!

Supports many file formats

impy automatically chooses the proper reader/writer according to the extension.

  • Tiff file (".tif", ".tiff")
  • LSM file (".lsm")
  • MRC file (".mrc", ".rec", ".st", ".map", ".map.gz")
  • Zarr file (".zarr")
  • ND2 file (".nd2")
  • Other image file (".png", ".jpg")

Lazy loading

With the lazy submodule, you can easily make image processing workflows for large images.

import impy as ip

img = ip.lazy.imread("path/to/very-large-image.tif")
out = img.gaussian_filter()
out.imsave("image_filtered.tif")

Switch between CPU and GPU

impy can internally switches the functions between numpy and cupy.

img.gaussian_filter()  # <- CPU
with ip.use("cupy"):
    img.gaussian_filter()  # <- GPU
ip.Const["RESOURCE"] = "cupy"  # <- globally use GPU

Seamless interface between napari

napari is an interactive viewer for multi-dimensional images. impy has a simple and efficient interface with it, via the object ip.gui. Since ImgArray is tagged with image metadata, you don't have to care about axes or scales. Just run

ip.gui.add(img)

Extend your function for batch processing

Already have a function for numpy and scipy? Decorate it with @ip.bind

@ip.bind
def imfilter(img, param=None):
    # Your function here.
    # Do something on a 2D or 3D image and return image, scalar or labels
    return out

and it's ready for batch processing!

img.imfilter(param=1.0)

Command line usage

impy also supports command-line-based image analysis. All methods of ImgArray are available from the command line, such as

impy path/to/image.tif ./output.tif --method gaussian_filter --sigma 2.0

which is equivalent to

import impy as ip
img = ip.imread("path/to/image.tif")
out = img.gaussian_filter(sigma=2.0)
out.imsave("./output.tif")

For more complex procedures, it is possible to send images directly to IPython

impy path/to/image.tif -i
thr = img.gaussian_filter().threshold()

Metadata

Release files for impy-array 2.5.3

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

Source distribution (sdist)

Source distribution for impy-array 2.5.3
File Size Uploaded
impy_array-2.5.3.tar.gz 155.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for impy-array 2.5.3
File Interpreter ABI Platform
impy_array-2.5.3-py3-none-any.whl Python 3 none any Details

Total release size: 340.9 kB

Release files / impy_array-2.5.3.tar.gz

Download URL impy_array-2.5.3.tar.gz
Size 155.7 kB
Tags Source
SHA-256 checksum
How to use checksums
048e8df3cfb82dda3198ef6ed8a3dc6895c038cc2d9ac62c2258f148adb07ac1
BLAKE2b-256 checksum
How to use checksums
3f26d761920ec6ff5b9b3901311d8e877bfd168ea232941684b6261c670c48d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.2

Release files / impy_array-2.5.3-py3-none-any.whl

Download URL impy_array-2.5.3-py3-none-any.whl
Size 185.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cadba4263709691c07f7a5f71255ef88c690b0a9810a2ec51748a41edaa013f4
BLAKE2b-256 checksum
How to use checksums
5cb61ee682ea7ae918090e66679be9ab43ea9a649f7030758b19e8818fc921a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.2

Release history Release notifications | RSS feed

This release

2.5.3 This release

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.5.0

2 release files

2.4.10

2 release files

2.4.9

2 release files

2.4.8

2 release files

2.4.7

2 release files

2.4.6

2 release files

2.4.5

2 release files

2.4.4

2 release files

2.4.3

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.3

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.6

2 release files

2.2.5

2 release files

2.2.4

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.26.1

2 release files

1.26.0

2 release files

1.25.2

2 release files

1.25.1

2 release files

1.25.0

2 release files

1.24.3

2 release files

1.24.2

2 release files

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