Speed up coding/extending image analysis in Python.
Project description
A numpy extension for efficient and powerful image analysis workflow
impy is an all-in-one image analysis library, equipped with parallel processing, GPU support, GUI based tools and so on.
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
- 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") # Read images with metadata.
img["z=3;t=0"].imshow() # Plot image slice at z=3 and t=0.
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(f"Max-{img.name}") # Save in the same place. Don't spend time on searching for the directory!
Supported file formats
impy automatically chooses proper reader/writer according to the extension.
- Tiff file (".tif", ".tiff")
- MRC file (".mrc", ".rec", ".st", ".map", ".map.gz")
- Zarr file (".zarr")
- Other image file (".png", ".jpg")
Switch between CPU and GPU
impy can internally switches the functions between numpy and cupy.
You can use GPU for calculation very easily.
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)
Commaind line usage
impy also supports command line based image analysis. All method of ImgArray is available
from commad 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 procedure, it is possible to send image directly to IPython
impy path/to/image.tif -i
thr = img.gaussian_filter().threshold()
or to napari
impy path/to/image.tif -n
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file impy-array-2.2.0.tar.gz.
File metadata
- Download URL: impy-array-2.2.0.tar.gz
- Upload date:
- Size: 151.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.13.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56fcf05c43a9d94bbd39d244a26b66ffc0b7fa27c91024c1a05e25f46a9fa022
|
|
| MD5 |
ae3ed2dd55e66c5cd57ce1883d152ed4
|
|
| BLAKE2b-256 |
da1f47dea808c23ff28c50e746295732ffa5dc51265e83997bb87f71ff758351
|
File details
Details for the file impy_array-2.2.0-py3-none-any.whl.
File metadata
- Download URL: impy_array-2.2.0-py3-none-any.whl
- Upload date:
- Size: 170.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.13.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8110ae366920afabfc5111b3f4a2684411c274d6fc9aa7b1700fcdfcdca8df95
|
|
| MD5 |
6ccbe76d0646bdafbd1a18309a45c37f
|
|
| BLAKE2b-256 |
d89612f8ee5e06b0997da52cdfde45c3ea4f31b9727ddb129b864e71d33b3694
|