{"id":13717161,"url":"https://github.com/AllenCellModeling/aicsimageio","last_synced_at":"2025-05-07T06:32:01.984Z","repository":{"id":37493157,"uuid":"194131198","full_name":"AllenCellModeling/aicsimageio","owner":"AllenCellModeling","description":"Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Python","archived":false,"fork":false,"pushed_at":"2025-01-15T17:25:41.000Z","size":181512,"stargazers_count":213,"open_issues_count":8,"forks_count":50,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-06T21:20:53.102Z","etag":null,"topics":["bio-formats","dask","image-metadata","imageio","microscopy","python","scientific-computing","scientific-formats","xarray"],"latest_commit_sha":null,"homepage":"https://allencellmodeling.github.io/aicsimageio","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AllenCellModeling.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":"docs/GOVERNANCE.md","roadmap":"docs/ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-27T16:43:22.000Z","updated_at":"2025-04-08T00:33:41.000Z","dependencies_parsed_at":"2023-02-09T16:00:40.275Z","dependency_job_id":"346a8eaf-2872-444c-a87c-cc9489524fcb","html_url":"https://github.com/AllenCellModeling/aicsimageio","commit_stats":{"total_commits":552,"total_committers":37,"mean_commits":14.91891891891892,"dds":0.5615942028985508,"last_synced_commit":"e5c6287d7cba4f806c17552ca6cfbb4db1d313fd"},"previous_names":[],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllenCellModeling%2Faicsimageio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllenCellModeling%2Faicsimageio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllenCellModeling%2Faicsimageio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AllenCellModeling%2Faicsimageio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AllenCellModeling","download_url":"https://codeload.github.com/AllenCellModeling/aicsimageio/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252826900,"owners_count":21810201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bio-formats","dask","image-metadata","imageio","microscopy","python","scientific-computing","scientific-formats","xarray"],"created_at":"2024-08-03T00:01:18.670Z","updated_at":"2025-05-07T06:31:58.269Z","avatar_url":"https://github.com/AllenCellModeling.png","language":"Python","readme":"# AICSImageIO\n\n\u003e [!WARNING]  \n\u003e AICSImageIO is now in maintenance mode only.  Please take a look at its compatible successor [`bioio`](https://github.com/bioio-devs/bioio) ([see here for migration guide](https://bioio-devs.github.io/bioio/MIGRATION.html))\n\n[![Build Status](https://github.com/AllenCellModeling/aicsimageio/actions/workflows/build-main.yml/badge.svg)](https://github.com/AllenCellModeling/aicsimageio/actions)\n[![Documentation](https://github.com/AllenCellModeling/aicsimageio/workflows/Documentation/badge.svg)](https://AllenCellModeling.github.io/aicsimageio/)\n[![Code Coverage](https://codecov.io/gh/AllenCellModeling/aicsimageio/branch/main/graph/badge.svg)](https://app.codecov.io/gh/AllenCellModeling/aicsimageio/branch/main)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4906608.svg)](https://doi.org/10.5281/zenodo.4906608)\n\nImage Reading, Metadata Conversion, and Image Writing for Microscopy Images in Pure Python\n\n\n---\n\n## Features\n\n-   Supports reading metadata and imaging data for:\n    -   `OME-TIFF`\n    -   `TIFF`\n    -   `ND2` -- (`pip install aicsimageio[nd2]`)\n    -   `DV` -- (`pip install aicsimageio[dv]`)\n    -   `CZI` -- (`pip install aicspylibczi\u003e=3.1.1 fsspec\u003e=2022.8.0`)\n    -   `LIF` -- (`pip install readlif\u003e=0.6.4`)\n    -   `PNG`, `GIF`, [etc.](https://github.com/imageio/imageio) -- (`pip install aicsimageio[base-imageio]`)\n    -   Files supported by [Bio-Formats](https://docs.openmicroscopy.org/bio-formats/latest/supported-formats.html) -- (`pip install aicsimageio bioformats_jar`) (Note: requires `java` and `maven`, see below for details.)\n-   Supports writing metadata and imaging data for:\n    -   `OME-TIFF`\n    -   `PNG`, `GIF`, [etc.](https://github.com/imageio/imageio) -- (`pip install aicsimageio[base-imageio]`)\n-   Supports reading and writing to\n    [fsspec](https://github.com/intake/filesystem_spec) supported file systems\n    wherever possible:\n\n    -   Local paths (i.e. `my-file.png`)\n    -   HTTP URLs (i.e. `https://my-domain.com/my-file.png`)\n    -   [s3fs](https://github.com/dask/s3fs) (i.e. `s3://my-bucket/my-file.png`)\n    -   [gcsfs](https://github.com/dask/gcsfs) (i.e. `gcs://my-bucket/my-file.png`)\n\n    See [Cloud IO Support](#cloud-io-support) for more details.\n\n## Installation\n\n**Stable Release:** `pip install aicsimageio`\u003cbr\u003e\n**Development Head:** `pip install git+https://github.com/AllenCellModeling/aicsimageio.git`\n\nAICSImageIO is supported on Windows, Mac, and Ubuntu.\nFor other platforms, you will likely need to build from source.\n\n#### Extra Format Installation\n\nTIFF and OME-TIFF reading and writing is always available after\ninstalling `aicsimageio`, but extra supported formats can be\noptionally installed using `[...]` syntax.\n\n-   For a single additional supported format (e.g. ND2): `pip install aicsimageio[nd2]`\n-   For a single additional supported format (e.g. ND2), development head: `pip install \"aicsimageio[nd2] @ git+https://github.com/AllenCellModeling/aicsimageio.git\"`\n-   For a single additional supported format (e.g. ND2), specific tag (e.g. `v4.0.0.dev6`): `pip install \"aicsimageio[nd2] @ git+https://github.com/AllenCellModeling/aicsimageio.git@v4.0.0.dev6\"`\n-   For faster OME-TIFF reading with tile tags: `pip install aicsimageio[bfio]`\n-   For multiple additional supported formats: `pip install aicsimageio[base-imageio,nd2]`\n-   For all additional supported (and openly licensed) formats: `pip install aicsimageio[all]`\n-   Due to the GPL license, LIF support is not included with the `[all]` extra, and must be installed manually with `pip install aicsimageio readlif\u003e=0.6.4`\n-   Due to the GPL license, CZI support is not included with the `[all]` extra, and must be installed manually with `pip install aicsimageio aicspylibczi\u003e=3.1.1 fsspec\u003e=2022.8.0`\n-   Due to the GPL license, Bio-Formats support is not included with the `[all]` extra, and must be installed manually with `pip install aicsimageio bioformats_jar`. **Important!!** Bio-Formats support also requires a `java` and `mvn` executable in the environment. The simplest method is to install `bioformats_jar` from conda: `conda install -c conda-forge bioformats_jar` (which will additionally bring `openjdk` and `maven` packages).\n\n## Documentation\n\nFor full package documentation please visit\n[allencellmodeling.github.io/aicsimageio](https://allencellmodeling.github.io/aicsimageio/index.html).\n\n## Quickstart\n\n### Full Image Reading\n\nIf your image fits in memory:\n\n```python\nfrom aicsimageio import AICSImage\n\n# Get an AICSImage object\nimg = AICSImage(\"my_file.tiff\")  # selects the first scene found\nimg.data  # returns 5D TCZYX numpy array\nimg.xarray_data  # returns 5D TCZYX xarray data array backed by numpy\nimg.dims  # returns a Dimensions object\nimg.dims.order  # returns string \"TCZYX\"\nimg.dims.X  # returns size of X dimension\nimg.shape  # returns tuple of dimension sizes in TCZYX order\nimg.get_image_data(\"CZYX\", T=0)  # returns 4D CZYX numpy array\n\n# Get the id of the current operating scene\nimg.current_scene\n\n# Get a list valid scene ids\nimg.scenes\n\n# Change scene using name\nimg.set_scene(\"Image:1\")\n# Or by scene index\nimg.set_scene(1)\n\n# Use the same operations on a different scene\n# ...\n```\n\n#### Full Image Reading Notes\n\nThe `.data` and `.xarray_data` properties will load the whole scene into memory.\nThe `.get_image_data` function will load the whole scene into memory and then retrieve\nthe specified chunk.\n\n### Delayed Image Reading\n\nIf your image doesn't fit in memory:\n\n```python\nfrom aicsimageio import AICSImage\n\n# Get an AICSImage object\nimg = AICSImage(\"my_file.tiff\")  # selects the first scene found\nimg.dask_data  # returns 5D TCZYX dask array\nimg.xarray_dask_data  # returns 5D TCZYX xarray data array backed by dask array\nimg.dims  # returns a Dimensions object\nimg.dims.order  # returns string \"TCZYX\"\nimg.dims.X  # returns size of X dimension\nimg.shape  # returns tuple of dimension sizes in TCZYX order\n\n# Pull only a specific chunk in-memory\nlazy_t0 = img.get_image_dask_data(\"CZYX\", T=0)  # returns out-of-memory 4D dask array\nt0 = lazy_t0.compute()  # returns in-memory 4D numpy array\n\n# Get the id of the current operating scene\nimg.current_scene\n\n# Get a list valid scene ids\nimg.scenes\n\n# Change scene using name\nimg.set_scene(\"Image:1\")\n# Or by scene index\nimg.set_scene(1)\n\n# Use the same operations on a different scene\n# ...\n```\n\n#### Delayed Image Reading Notes\n\nThe `.dask_data` and `.xarray_dask_data` properties and the `.get_image_dask_data`\nfunction will not load any piece of the imaging data into memory until you specifically\ncall `.compute` on the returned Dask array. In doing so, you will only then load the\nselected chunk in-memory.\n\n### Mosaic Image Reading\n\nRead stitched data or single tiles as a dimension.\n\nReaders that support mosaic tile stitching:\n\n-   `LifReader`\n-   `CziReader`\n\n#### AICSImage\n\nIf the file format reader supports stitching mosaic tiles together, the\n`AICSImage` object will default to stitching the tiles back together.\n\n```python\nimg = AICSImage(\"very-large-mosaic.lif\")\nimg.dims.order  # T, C, Z, big Y, big X, (S optional)\nimg.dask_data  # Dask chunks fall on tile boundaries, pull YX chunks out of the image\n```\n\nThis behavior can be manually turned off:\n\n```python\nimg = AICSImage(\"very-large-mosaic.lif\", reconstruct_mosaic=False)\nimg.dims.order  # M (tile index), T, C, Z, small Y, small X, (S optional)\nimg.dask_data  # Chunks use normal ZYX\n```\n\nIf the reader does not support stitching tiles together the M tile index will be\navailable on the `AICSImage` object:\n\n```python\nimg = AICSImage(\"some-unsupported-mosaic-stitching-format.ext\")\nimg.dims.order  # M (tile index), T, C, Z, small Y, small X, (S optional)\nimg.dask_data  # Chunks use normal ZYX\n```\n\n#### Reader\n\nIf the file format reader detects mosaic tiles in the image, the `Reader` object\nwill store the tiles as a dimension.\n\nIf tile stitching is implemented, the `Reader` can also return the stitched image.\n\n```python\nreader = LifReader(\"ver-large-mosaic.lif\")\nreader.dims.order  # M, T, C, Z, tile size Y, tile size X, (S optional)\nreader.dask_data  # normal operations, can use M dimension to select individual tiles\nreader.mosaic_dask_data  # returns stitched mosaic - T, C, Z, big Y, big, X, (S optional)\n```\n\n#### Single Tile Absolute Positioning\n\nThere are functions available on both the `AICSImage` and `Reader` objects\nto help with single tile positioning:\n\n```python\nimg = AICSImage(\"very-large-mosaic.lif\")\nimg.mosaic_tile_dims  # Returns a Dimensions object with just Y and X dim sizes\nimg.mosaic_tile_dims.Y  # 512 (for example)\n\n# Get the tile start indices (top left corner of tile)\ny_start_index, x_start_index = img.get_mosaic_tile_position(12)\n```\n\n### Metadata Reading\n\n```python\nfrom aicsimageio import AICSImage\n\n# Get an AICSImage object\nimg = AICSImage(\"my_file.tiff\")  # selects the first scene found\nimg.metadata  # returns the metadata object for this file format (XML, JSON, etc.)\nimg.channel_names  # returns a list of string channel names found in the metadata\nimg.physical_pixel_sizes.Z  # returns the Z dimension pixel size as found in the metadata\nimg.physical_pixel_sizes.Y  # returns the Y dimension pixel size as found in the metadata\nimg.physical_pixel_sizes.X  # returns the X dimension pixel size as found in the metadata\n```\n\n### Xarray Coordinate Plane Attachment\n\nIf `aicsimageio` finds coordinate information for the spatial-temporal dimensions of\nthe image in metadata, you can use\n[xarray](http://xarray.pydata.org/en/stable/index.html) for indexing by coordinates.\n\n```python\nfrom aicsimageio import AICSImage\n\n# Get an AICSImage object\nimg = AICSImage(\"my_file.ome.tiff\")\n\n# Get the first ten seconds (not frames)\nfirst_ten_seconds = img.xarray_data.loc[:10]  # returns an xarray.DataArray\n\n# Get the first ten major units (usually micrometers, not indices) in Z\nfirst_ten_mm_in_z = img.xarray_data.loc[:, :, :10]\n\n# Get the first ten major units (usually micrometers, not indices) in Y\nfirst_ten_mm_in_y = img.xarray_data.loc[:, :, :, :10]\n\n# Get the first ten major units (usually micrometers, not indices) in X\nfirst_ten_mm_in_x = img.xarray_data.loc[:, :, :, :, :10]\n```\n\nSee `xarray`\n[\"Indexing and Selecting Data\" Documentation](http://xarray.pydata.org/en/stable/indexing.html)\nfor more information.\n\n### Cloud IO Support\n\n[File-System Specification (fsspec)](https://github.com/intake/filesystem_spec) allows\nfor common object storage services (S3, GCS, etc.) to act like normal filesystems by\nfollowing the same base specification across them all. AICSImageIO utilizes this\nstandard specification to make it possible to read directly from remote resources when\nthe specification is installed.\n\n```python\nfrom aicsimageio import AICSImage\n\n# Get an AICSImage object\nimg = AICSImage(\"http://my-website.com/my_file.tiff\")\nimg = AICSImage(\"s3://my-bucket/my_file.tiff\")\nimg = AICSImage(\"gcs://my-bucket/my_file.tiff\")\n\n# Or read with specific filesystem creation arguments\nimg = AICSImage(\"s3://my-bucket/my_file.tiff\", fs_kwargs=dict(anon=True))\nimg = AICSImage(\"gcs://my-bucket/my_file.tiff\", fs_kwargs=dict(anon=True))\n\n# All other normal operations work just fine\n```\n\nRemote reading requires that the file-system specification implementation for the\ntarget backend is installed.\n\n-   For `s3`: `pip install s3fs`\n-   For `gs`: `pip install gcsfs`\n\nSee the [list of known implementations](https://filesystem-spec.readthedocs.io/en/latest/?badge=latest#implementations).\n\n### Saving to OME-TIFF\n\nThe simpliest method to save your image as an OME-TIFF file with key pieces of\nmetadata is to use the `save` function.\n\n```python\nfrom aicsimageio import AICSImage\n\nAICSImage(\"my_file.czi\").save(\"my_file.ome.tiff\")\n```\n\n**Note:** By default `aicsimageio` will generate only a portion of metadata to pass\nalong from the reader to the OME model. This function currently does not do a full\nmetadata translation.\n\nFor finer grain customization of the metadata, scenes, or if you want to save an array\nas an OME-TIFF, the writer class can also be used to customize as needed.\n\n```python\nimport numpy as np\nfrom aicsimageio.writers import OmeTiffWriter\n\nimage = np.random.rand(10, 3, 1024, 2048)\nOmeTiffWriter.save(image, \"file.ome.tif\", dim_order=\"ZCYX\")\n```\n\nSee\n[OmeTiffWriter documentation](./aicsimageio.writers.html#aicsimageio.writers.ome_tiff_writer.OmeTiffWriter.save)\nfor more details.\n\n#### Other Writers\n\nIn most cases, `AICSImage.save` is usually a good default but there are other image\nwriters available. For more information, please refer to\n[our writers documentation](https://allencellmodeling.github.io/aicsimageio/aicsimageio.writers.html).\n\n## Benchmarks\n\nAICSImageIO is benchmarked using [asv](https://asv.readthedocs.io/en/stable/).\nYou can find the benchmark results for every commit to `main` starting at the 4.0\nrelease on our\n[benchmarks page](https://AllenCellModeling.github.io/aicsimageio/_benchmarks/index.html).\n\n## Development\n\nSee our\n[developer resources](https://allencellmodeling.github.io/aicsimageio/developer_resources)\nfor information related to developing the code.\n\n## Citation\n\nIf you find `aicsimageio` useful, please cite this repository as:\n\n\u003e Eva Maxfield Brown, Dan Toloudis, Jamie Sherman, Madison Swain-Bowden, Talley Lambert, AICSImageIO Contributors (2021). AICSImageIO: Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Pure Python [Computer software]. GitHub. https://github.com/AllenCellModeling/aicsimageio\n\nbibtex:\n\n```bibtex\n@misc{aicsimageio,\n  author    = {Brown, Eva Maxfield and Toloudis, Dan and Sherman, Jamie and Swain-Bowden, Madison and Lambert, Talley and {AICSImageIO Contributors}},\n  title     = {AICSImageIO: Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Pure Python},\n  year      = {2021},\n  publisher = {GitHub},\n  url       = {https://github.com/AllenCellModeling/aicsimageio}\n}\n```\n\n_Free software: BSD-3-Clause_\n\n_(The LIF component is licensed under GPLv3 and is not included in this package)_\n_(The Bio-Formats component is licensed under GPLv2 and is not included in this package)_\n_(The CZI component is licensed under GPLv3 and is not included in this package)_\n","funding_links":[],"categories":["Python","Other","🛸 Other"],"sub_categories":["🛠️ Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAllenCellModeling%2Faicsimageio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAllenCellModeling%2Faicsimageio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAllenCellModeling%2Faicsimageio/lists"}