Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
9ec7ed7
Beginning work for converting the entire project over to dask
Jan 7, 2020
93877d2
Add function for get image data as da
Jan 8, 2020
3f5b749
Add basic file path checking to Reader base class init
Jan 8, 2020
a57dfd1
Finish default reader
Jan 8, 2020
d824771
Convert NdArrayReader to ArrayLikeReader to support both numpy and dask
Jan 8, 2020
319d607
Add imreada function to get back dask array
Jan 8, 2020
0d0bd32
Rename init param for ArrayLikeReader from arr to data
Jan 8, 2020
ffadb9d
Fix lazy load init with a todo for later
Jan 8, 2020
f20b746
Starting work on switching czi reader from vender czi file to pylibczi
Jan 8, 2020
7882abd
Fix typo in get_image_data_da function name
Jan 9, 2020
abfc8bd
Working czireader daread to dask array
Jan 10, 2020
be71c24
Create stable API by specifying functions as either dask or numpy
Jan 10, 2020
90e25c0
Fix already daskified readers dims property to use dask data
Jan 10, 2020
41d69fd
Add checks for task count after running basic reader operations
Jan 18, 2020
8f6b5c3
Include dask and toolz dependencies in setup
Jan 18, 2020
2234b71
Delayed dask CziReader and tests
Jan 18, 2020
3ebf3e5
Add comments to daread
Jan 19, 2020
ed7058f
Various file formatting
Jan 19, 2020
b095ec7
Add dask image dep for tiff reading
Jan 19, 2020
457517d
Remove dask image dep and add TiffFile upgrade dep
Jan 19, 2020
2819a29
Change internal czi scene holder parameter name
Jan 19, 2020
1e39796
Add checks for open files between basics and loaded
Jan 19, 2020
31064a8
Add delayed tiff reader and tests
Jan 19, 2020
1646cd2
Get rid of default reader dims setter
Jan 19, 2020
402b163
Add test case for checking that Y and X are always added to chunk dims
Jan 19, 2020
d104dff
Get rid of dims setter on arraylike reader
Jan 19, 2020
b75bc7d
Move _resolve_image_path to base class and run during init
Jan 19, 2020
2f48750
Reorder test asserts
Jan 19, 2020
973a077
Write better conflicting dimension sizes scene check in czi reader
Jan 19, 2020
78a78da
Add tests for resolve image path
Jan 19, 2020
1bd92e0
Add a bit of documentation on TiffReader
Jan 19, 2020
92f3bc3
Rewrite OmeTiffReader to use TiffReader as base
Jan 19, 2020
33ef395
Add tests for CziReader for get channel names
Jan 19, 2020
69feeb8
Add utf marker to test tiff reader
Jan 19, 2020
3de6681
Update transforms to allow either dask or numpy
Jan 19, 2020
8123d70
Update writer tests
Jan 19, 2020
3db18cf
Fix various linting errors and recursion error in aicsimage
Jan 19, 2020
839795c
Switch which element type is returned from czi metadata
Jan 19, 2020
99d461c
Get rid of inconsistant shape error
Jan 19, 2020
0e38bd0
Almost all tests passing, only tests failing rely on numpy function
Jan 19, 2020
534c5ae
Add dask multi-operator version of np.split to transforms
Jan 19, 2020
0863ba8
aicspylibczi is not supported on python 3.6
Jan 19, 2020
b989b7d
Move from warn to warning as warn is depricated
Jan 19, 2020
ec49c2d
Bug fixes for da cumsum
Jan 20, 2020
68347a2
Support tiffs with bad dimension labels by merging guess with valid dims
Jan 20, 2020
d65ee02
Check known dims kwarg on aicsimageio object during init for valid dims
Jan 20, 2020
e568252
Add test for reshaping data when provided dims that it doesn't have
Jan 20, 2020
4da0f36
Add dask interactive deps
Jan 22, 2020
f4fd6b2
Do not resolve paths because mounted drives are symlinked
Jan 22, 2020
8815020
Add dask cluster examples with various configurations
Jan 22, 2020
47bb32c
Fix non existing variable for is_this_type
Jan 22, 2020
4b5acfe
Remove extra get reader call on default reader
Jan 23, 2020
bfbebb8
Fix bug and add tests for variable per scene dims czi file
Jan 23, 2020
dea3df6
Remove Dimension B as it was unused
Jan 25, 2020
90e5f24
Add docstring to read image
Jan 25, 2020
562d3d6
Remove TypeError from CziReader failed scene selection
Jan 25, 2020
cbe47d1
Fix typo in comment
Jan 25, 2020
52ef679
Add log statement informing the user we default due to variable dims
Jan 25, 2020
58b3ab7
Remove _size_s as it isn't used
Jan 25, 2020
d3c83d8
Div points in transforms can always be numpy
Jan 25, 2020
c163dcd
Add doc format info to init files
Jan 25, 2020
e445749
Only return scene dimension if multiple scenes present in tiff
Jan 25, 2020
74377dd
Add back dims setters to chosen readers
Jan 25, 2020
c5889e7
Add back tiff dtype func and ome tiff is ome func
Jan 25, 2020
0983548
Fix how tiff dimensions are guessed
Jan 25, 2020
01be591
Update python requires until pylibczi has been released on 3.6
Jan 25, 2020
579ad54
Shuffle dependencies around
Jan 25, 2020
c29c906
Add shape property to AICSImage object
Jan 25, 2020
c27b61a
Add test for AICSImage.shape property
Jan 25, 2020
9da4d5c
Get rid of random S string in favour of Dimensions.Scene
Jan 25, 2020
65ce16f
Add view napari function
Jan 25, 2020
bf70a19
Use reader property instead of _reader in aicsimage calls
Jan 26, 2020
e4f9002
Add tests for napari and fix minor bugs
Jan 26, 2020
95a0a19
Add dtype function back to CziReader and add test
Jan 26, 2020
52e28e9
Add back various utility functions to CziReader and TiffReader
Jan 26, 2020
cb6f7b3
Change typing on OmeTiffReader is this type
Jan 26, 2020
709a1ae
Add dask cluster and client spawning during context manager
Jan 26, 2020
7651477
Add tests and fix bugs for dask client and cluster context manager
Jan 26, 2020
8fd1663
Rename dask utilities to have standard naming
Jan 26, 2020
f56fe95
Move around how the dask utils tests are run
Jan 27, 2020
e021055
Change the dask utils tests to simply mock the utility function
Jan 27, 2020
305fba0
Add back load slice function to tiff reader
Jan 27, 2020
a519f02
Add documentation
Jan 27, 2020
207ebdc
Remove aicsimageio planning image from README
Jan 27, 2020
46e68ae
Fix typo in README
Jan 27, 2020
15356f8
Update issue templates and workflows
Jan 27, 2020
0615d33
Convert tests to check for specific file rather than any open files
Jan 27, 2020
cc5722a
Change wordings in README
Jan 27, 2020
c01117c
Add back Python 3.6 builds
Jan 31, 2020
1757cbf
Add dask utils `cluster_and_client` context manager and update README
Jan 31, 2020
03ee29b
Fix README line break
Jan 31, 2020
4340196
Make "ArrayLike" type for np.ndarray and da.core.Array
Jan 31, 2020
c98861b
Unpack CZIReader dim info during items instead of inside loop
Jan 31, 2020
863234d
Catch any unsupported file format on DefaultReader and reraise
Jan 31, 2020
5175fa7
Break out of loop on first detection that tiff scenes are variable sizes
Jan 31, 2020
d74a799
Removed unused typing in transforms and arraylike reader
Jan 31, 2020
75dfaf5
Unpack TiffReader np index during enumerate instead of inside loop
Jan 31, 2020
b58fbdf
Move back to only supporting 3.7
Jan 31, 2020
c0b38da
Add a log statement informing the user that we guessed a Tiff dimension
Jan 31, 2020
0b11a3e
Resolves #69, Change context manager API to use dask_kwargs param
Jan 31, 2020
a6d27ea
Change reader is_this_type to use `_resolve_image_path`
Jan 31, 2020
083a006
No need to save values cluster and client in dask utils context mngr
Jan 31, 2020
e451ba3
Add back python 3.6 builds
Jan 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions .github/issue_template/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
**Description:**
A clear and concise description of what the bug is.
---
name: Bug Report
about: '"Something''s wrong..."'
title: ''
labels: ''
assignees: ''

**Expected Behavior:**
A clear and concise description of what you expected to happen.
---

**System and Software:**
## System and Software
* aicsimageio Version:
* Python Version:
* Operating System:

**Steps to Reproduce:**
```
Paste the command(s) you used and the output.
```

**Additional context**
Add any other context about the problem here.
## Description
*A clear description of the bug*




## Expected Behavior
*What did you expect to happen instead?*




## Reproduction
*A minimal example that exhibits the behavior.*




## Environment
*Any additional information about your environment*
26 changes: 22 additions & 4 deletions .github/issue_template/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
**Description:**
A clear and concise description of what you want to happen.
---
name: Feature Request
about: '"It would be really cool if x did y..."'
title: ''
labels: ''
assignees: ''

**Additional context**
Add any other context or screenshots about the feature request here.
---

## Use Case
*Please provide a use case to help us understand your request in context*




## Solution
*Please describe your ideal solution*




## Alternatives
*Please describe any alternatives you've considered, even if you've dismissed them*
23 changes: 17 additions & 6 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docs
name: Documentation

on:
push:
Expand All @@ -9,12 +9,23 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install .[all]
- name: Generate Docs
uses: JacksonMaxfield/github-pages-deploy-action-python@master
env:
run: |
make gen-docs
touch docs/_build/html/.nojekyll
- name: Publish Docs
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_BRANCH: master # The branch the action should deploy from.
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs/_build/html # The folder the action should deploy. This example folder is generated by Sphinx
BUILD_SCRIPT: pip install .[dev] && make docs && touch docs/_build/html/.nojekyll # The build script the action should run prior to deploying.
FOLDER: docs/_build/html/ # The folder the action should deploy.
12 changes: 6 additions & 6 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@master
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
Expand All @@ -38,12 +38,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@master
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@master
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package
- name: Build Package
run: |
python setup.py sdist bdist_wheel
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@v1
with:
user: aicspypi
password: ${{ secrets.PYPI_TOKEN }}
13 changes: 6 additions & 7 deletions .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,29 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@master
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
- name: Test with pytest
run: |
pytest --cov-report xml --cov=aicsimageio aicsimageio/tests/
codecov -t ${{ secrets.CODECOV_TOKEN }}

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@master
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ instance/
docs/_build/
docs/aicsimageio.*rst

# Dask workers
dask-worker-space/

# PyBuilder
target/

Expand Down
135 changes: 97 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,128 @@ A Python library for reading and writing image data with specific support for ha
---

## Features
* Supports reading metadata and imaging data from file path or buffered bytes for:
* Supports reading metadata and imaging data for:
* `CZI`
* `OME-TIFF`
* `TIFF`
* Any additional format supported by `imageio`
* Any additional format supported by [`imageio`](https://github.com/imageio/imageio)
* Supports writing metadata and imaging data for:
* `OME-TIFF`
* `TIFF`
* Any additional format supported by `imageio`

### Disclaimer:
This package is under heavy revision in preparation for version 3.0.0 release. The quick start below is representative
of how to interact with the package under 3.0.0 and not under the current stable release.
## Installation
**Stable Release:** `pip install aicsimageio`<br>
**Development Head:** `pip install git+https://github.com/AllenCellModeling/aicsimageio.git`

## Documentation
For full package documentation please visit
[allencellmodeling.github.io/aicsimageio](https://allencellmodeling.github.io/aicsimageio/index.html).

## Quick Start

### Full Image Reading
```python
from aicsimageio import AICSImage, imread

# For numpy array of image data
im = imread("/path/to/your/file_or_buffer.ome.tiff")
# Get an AICSImage object
img = AICSImage("my_file.tiff")
img.data # returns 6D STCZYX numpy array
img.dims # returns string "STCZYX"
img.shape # returns tuple of dimension sizes in STCZYX order
img.size("STC") # returns tuple of dimensions sizes for just STC
img.get_image_data("CZYX", S=0, T=0) # returns 4D CZYX numpy array

# For AICSImage object that
with AICSImage("/path/to/your/file_or_buffer.ome.tiff") as im:
# use im object
# Get 6D STCZYX numpy array
data = imread("my_file.tiff")
```

# To specify a known dimension order
with AICSImage("/path/to/your/file_or_buffer.ome.tiff", known_dims="SYX") as im:
# use im object
### Delayed Image Slice Reading
```python
from aicsimageio import AICSImage, imread_dask

# Get an AICSImage object
img = AICSImage("my_file.tiff")
img.dask_data # returns 6D STCZYX dask array
img.dims # returns string "STCZYX"
img.shape # returns tuple of dimension sizes in STCZYX order
img.size("STC") # returns tuple of dimensions sizes for just STC
img.get_image_dask_data("CZYX", S=0, T=0) # returns 4D CZYX dask array

# Read specified portion of dask array
lazy_s0t0 = img.get_image_dask_data("CZYX", S=0, T=0) # returns 4D CZYX dask array
s0t0 = lazy_s0t0.compute() # returns 4D CZYX numpy array

# Or use normal numpy array slicing
lazy_data = imread_dask("my_file.tiff")
lazy_s0t0 = lazy_data[0, 0, :]
s0t0 = lazy_s0t0.compute()
```

# if you instantiate an AICSImage:
im = AICSImage("/path/to/your/file_or_buffer.ome.tiff")
# you should close it when done:
im.close()
When using the `dask_data` array, it is important to know when to `compute` or `persist` data and when to keep
chaining computation. [Here is a good rundown on the trade offs.](https://stackoverflow.com/questions/41806850/dask-difference-between-client-persist-and-client-compute#answer-41807160)

# Image data is stored in `data` attribute
im.data # returns the image data numpy array

# Image dimension sizes can be obtained via properties:
im.size_z # returns the size of the Z dimension. X,Y,Z,C,T, and S supported.
### Speed up IO and Processing with Dask Clients and Clusters
```python
from aicsimageio import AICSImage, dask_utils

# Create a local dask cluster and client for the duration of the context manager
with AICSImage("filename.ome.tiff") as img:
# do your work like normal
print(img.dask_data.shape)

# Specify arguments for the local cluster initialization
with AICSImage("filename.ome.tiff", dask_kwargs={"nworkers": 4}) as img:
# do your work like normal
print(img.dask_data.shape)

# Connect to a dask client for the duration of the context manager
with AICSImage("filename.ome.tiff", dask_kwargs={"address": "tcp://localhost:12345"}) as img:
# do your work like normal
print(img.dask_data.shape)

# Or spawn a local cluster and / or connect to a client outside of a context manager
# This uses the same "address" and dask kwargs as above
# If you pass an address in, it will create and shutdown the client and no cluster will be created.
# Similar to AICSImage, these objects will be connected and useable for the lifespan of the context manager.
with dask_utils.cluster_and_client() as (cluster, client):

img1 = AICSImage("1.tiff")
img2 = AICSImage("2.tiff")
img3 = AICSImage("3.tiff")

# Do your image processing work
```

# Image dimensions can also be obtained as a tuple in two ways:
im.size("ZYX") # returns a tuple containing the Z, Y, and X sizes only
im.get_image_data(out_orientation="ZYX").shape # returns same as above
### Metadata Reading
```python
from aicsimageio import AICSImage

# Image metadata is stored in `metadata` attribute
im.metadata # returns whichever metadata parser best suits the file format
# Get an AICSImage object
img = AICSImage("my_file.tiff")
img.metadata # returns the metadata object for this image type
img.get_channel_names() # returns a list of string channel names if found in the metadata
```

# Subsets or transposes of the image data can be requested:
im.get_image_data(out_orientation="ZYX") # returns a 3d data block containing only the ZYX dimensions
### Napari Interactive Viewer
[napari](https://github.com/Napari/napari) is a fast, interactive, multi-dimensional image viewer for python and
it is pretty useful for imaging data that this package tends to interact with.
```python
from aicsimageio import AICSImage

# Get an AICSImage object
img = AICSImage("my_file.tiff")
img.view_napari() # launches napari GUI and viewer
Comment thread
evamaxfield marked this conversation as resolved.
```

## Notes
* Image data numpy arrays are always returned as six dimensional in dimension order `STCZYX`
* Image `data` and `dask_data` are always returned as six dimensional in dimension order `STCZYX`
or `Scene`, `Time`, `Channel`, `Z`, `Y`, and `X`.
* Each file format may use a different metadata parser it is dependent on the reader's implementation.

## Installation
**Stable Release:** `pip install aicsimageio`<br>
**Development Head:** `pip install git+https://github.com/AllenCellModeling/aicsimageio.git`

## Documentation
For full package documentation please visit [allencellmodeling.github.io/aicsimageio](https://allencellmodeling.github.io/aicsimageio/index.html).
* The `AICSImage` object will only pull the `Scene`, `Time`, `Channel`, `Z`, `Y`, `X` dimensions from the reader.
If your file has dimensions outside of those, use the base reader classes `CziReader`, `OmeTiffReader`, `TiffReader`,
or `DefaultReader`.
* We make some choices for the user based off the image data during `img.view_napari`.
If you don't want this behavior, simply pass the `img.dask_data` into `napari.view_image` instead.

## Development
See [CONTRIBUTING.md](CONTRIBUTING.md) for information related to developing the code.
Expand Down
4 changes: 4 additions & 0 deletions aicsimageio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from .aics_image import AICSImage # noqa: F401
from .aics_image import imread # noqa: F401
from .aics_image import imread_dask # noqa: F401

# Do not edit this string manually, always use bumpversion
# Details in CONTRIBUTING.md
Expand Down
Loading