We are happy to announce the release of AICSImageIO 4.5.0!
AICSImageIO is a library for image reading, metadata conversion, and image writing for microscopy formats in pure Python. It aims to be able to read microscopy images into a single unified API regardless of size, format, or location, while additionally writing images and converting metadata to a standard common format.
If you are new to the library, please see our full [documentation](https://allencellmodeling.github.io/aicsimageio/) for always up-to-date usage and a quickstart README.
Highlights
TIFF Glob Reading
This release adds a `TiffGlobReader`! Incredibly useful for all the datasets comprised of image stacks stored as multiple TIFFs. And with it, a specific indexer pattern already stored for MicroManager users.
python
Given files with names like "s001_t002_c03_z04.tif"
reader = TiffGlobReader("path/to/data/*.tif")
We can use this to read single image tiffs generated by MicroManager
Micromanager creates directories for each position so we need to recursively glob
for the images files and pass the list to TiffGlobReader.
Note that all images are named according to "img_channel000_position001_time000000003_z004.tif"
glob_files = glob.glob("path/to/data/**/*.tif", recursive=True)
since the numbers in Micromanager files are not in STCZ order we
need to use a different indexer than default. For convenience
when working MicroManager generated files you can use the provided indexer: TiffGlobReader.MicroManagerIndexer
mm_reader = TiffGlobReader(glob_files, indexer=TiffGlobReader.MicroManagerIndexer)
as an example of making a custom indexer
you can manually create the MicroManagerIndexer like so:
import pandas as pd
from pathlib import Path
import re
def mm_indexer(path_to_img):
inds = re.findall(r”d+”, Path(path_to_img).name)
series = pd.Series(inds, index=["C", "S", "T", "Z"]).astype(int)
return series
mm_reader = TiffGlobReader(glob_files, indexer=mm_indexer)
Thanks to jrussell25 and ianhi for these additions!
YX Chunking for Large Files Read by BioformatsReader
If the image you are trying to read using `BioformatsReader` has YX planes that are incredibly large, you may find the new parameters `dask_tiles` and `tile_size` useful to additionally chunk the YX dimensions by the provided tile size.
python
bf_default = BioformatsReader("my_file.svs")
bf_tiled = BioformatsReader("my_file.svs", dask_tiles=True)
bf_tiled_custom = BioformatsReader("my_file.svs", dask_tiles=True, tile_size=(1024, 1024))
assert bf_default.dask_data.chunksize == (1, 1, 1, 4096, 4096)
assert bf_tiled.dask_data.chunksize == (1, 1, 1, 240, 240)
assert bf_tiled_custom.dask_data.chunksize == (1, 1, 1, 1024, 1024)
Thanks to NHPatterson for this addition!
Other Changes
The `Dimensions` object now has a `__getitem__`.
python
img = AICSImage("my_file.tiff")
img.dims <Dimensions T:50, C:1, Z: 1, Y: 480, X: 480>
img.dims["T", "Y"] = (50, 480)
Contributors and Reviewers this Release (alphabetical)
Jackson Maxfield Brown (JacksonMaxfield)
Ian Hunt-Isaak (ianhi)
Talley Lambert (tlambert03)
Heath Patterson (NHPatterson)
Madison Swain-Bowden (AetherUnbound)
John Russell (jrussell25)
Dan Toloudis (toloudis)