Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let tifffile.imread handle additional keyword arguments #4997

Merged
merged 1 commit into from Oct 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 5 additions & 12 deletions skimage/io/_plugins/tifffile_plugin.py
@@ -1,6 +1,6 @@
from warnings import warn
__all__ = ['imread', 'imsave']

from tifffile import TiffFile, imsave, parse_kwargs
from tifffile import imwrite as imsave, imread as tifffile_imread


def imread(fname, **kwargs):
Expand All @@ -16,22 +16,15 @@ def imread(fname, **kwargs):

Notes
-----
Provided by Christophe Golhke's tifffile.py [1]_, and supports many
Provided by the tifffile library [1]_, and supports many
advanced image types including multi-page and floating point.

References
----------
.. [1] http://www.lfd.uci.edu/~gohlke/code/tifffile.py
.. [1] https://pypi.org/project/tifffile/

"""
if 'img_num' in kwargs:
kwargs['key'] = kwargs.pop('img_num')

# parse_kwargs will extract keyword arguments intended for the TiffFile
# class and remove them from the kwargs dictionary in-place
tiff_keys = ['multifile', 'multifile_close', 'fastij', 'is_ome']
kwargs_tiff = parse_kwargs(kwargs, *tiff_keys)

# read and return tiff as numpy array
with TiffFile(fname, **kwargs_tiff) as tif:
return tif.asarray(**kwargs)
return tifffile_imread(fname, **kwargs)