Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install Python dependencies
run: pip install ipython numpydoc pytest scikit-image sphinx sphinx-copybutton sphinx-rtd-theme
run: pip install ipython numpydoc pytest imageio sphinx sphinx-copybutton sphinx-rtd-theme

- name: Install pims
run: python -m pip install -v .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
set -vxeuo pipefail
python -m pip install -v .
if [[ ${{ matrix.optional-deps }} = extras ]]; then
python -mpip install av jinja2 jpype1 matplotlib moviepy scikit-image tifffile
python -mpip install av jinja2 jpype1 matplotlib moviepy imageio tifffile
fi
python -m pip install coverage pytest
python -m pip list
Expand Down
1 change: 1 addition & 0 deletions doc/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PIMS is easy to install on Windows, OSX, or Linux. Its dependencies are:

For basic image reading one of the following is required:

* `imageio <https://imageio.github.io/>`_
* `scikit-image <http://scikit-image.org/>`_
* `matplotlib <http://matplotlib.org/>`_

Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dependencies:
- slicerator
- pillow
- matplotlib
- scikit-image
- jinja2
- av
- tifffile
Expand Down
5 changes: 2 additions & 3 deletions pims/image_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
from pims.frame import Frame

try:
from skimage.io import imread
except ImportError:
try:
from imageio import v2 as iio
except ImportError:
import imageio as iio

def imread(*args, **kwargs): # Strip metadata for consistency.
return np.asarray(iio.imread(*args, **kwargs))

except ImportError:
from skimage.io import imread

class ImageReader(FramesSequence):
"""Reads a single image into a length-1 reader.
Expand Down
22 changes: 11 additions & 11 deletions pims/image_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ImageSequence(FramesSequence):
which will ignore extraneous files or a list of files to open
in the order they should be loaded. When a path to a zipfile is
specified, all files in the zipfile will be loaded.
plugin : string
plugin : string, optional, deprecated
Passed on to skimage.io.imread if scikit-image is available.
If scikit-image is not available, this will be ignored and a warning
will be issued. Not available in combination with zipfiles.
Expand All @@ -51,15 +51,15 @@ class ImageSequence(FramesSequence):
>>> frame_count = len(video) # Number of frames in video
>>> frame_shape = video.frame_shape # Pixel dimensions of video
"""
def __init__(self, path_spec, plugin=None):
if not imread.__module__.startswith("skimage"):
if plugin is not None:
warn("A plugin was specified but ignored. Plugins can only "
"be specified if scikit-image is available. Instead, "
"ImageSequence will use imageio")
self.kwargs = dict()
else:
self.kwargs = dict(plugin=plugin)
def __init__(self, path_spec, **kwargs):
self.kwargs = kwargs
if 'plugin' in self.kwargs:
warn_msg = "The 'plugin' parameter is deprecated and will be removed in a future release."
if imread.__module__.startswith("skimage"):
warn(warn_msg, DeprecationWarning)
else:
warn(warn_msg + " 'plugin' will be ignored because imageio is used for image reading.", DeprecationWarning)
self.kwargs.pop('plugin')

self._is_zipfile = False
self._zipfile = None
Expand Down Expand Up @@ -333,7 +333,7 @@ class ImageSequenceND(FramesSequenceND, ImageSequence):
specified, all files in the zipfile will be loaded. The filenames
should contain the indices of T, Z and C, preceded by a axis
identifier such as: 'file_t001c05z32'.
plugin : string, optional
plugin : string, optional, deprecated
Passed on to skimage.io.imread if scikit-image is available.
If scikit-image is not available, this will be ignored and a warning
will be issued. Not available in combination with zipfiles.
Expand Down
16 changes: 8 additions & 8 deletions pims/tests/test_imseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def setUp(self):
self.filename = os.path.join(self.filepath, '*.png')
self.frame0 = frames[0]
self.frame1 = frames[1]
self.kwargs = dict(plugin='pil')
self.klass = pims.ImageSequence
self.v = self.klass(self.filename, **self.kwargs)
self.v = self.klass(self.filename)
self.expected_shape = shape
self.expected_len = 5
self.tempdir = tempfile.mkdtemp()
Expand All @@ -52,6 +51,10 @@ def tearDown(self):
os.remove(self.tempfile)
os.rmdir(self.tempdir)

def test_plugin_deprecation(self):
with self.assertWarns(DeprecationWarning):
pims.ImageSequence(self.filename, plugin='PIL')


class TestImageSequenceWithMPL(_image_series, unittest.TestCase):
def setUp(self):
Expand All @@ -65,9 +68,8 @@ def setUp(self):
self.filename = os.path.join(self.filepath, '*.png')
self.frame0 = frames[0]
self.frame1 = frames[1]
self.kwargs = dict(plugin='matplotlib')
self.klass = pims.ImageSequence
self.v = self.klass(self.filename, **self.kwargs)
self.v = self.klass(self.filename)
self.expected_shape = shape
self.expected_len = 5

Expand All @@ -89,9 +91,8 @@ def setUp(self):
for fn in self.filenames]
self.frame0 = frames[0]
self.frame1 = frames[1]
self.kwargs = dict(plugin='matplotlib')
self.klass = pims.ImageSequence
self.v = self.klass(self.filename, **self.kwargs)
self.v = self.klass(self.filename)
self.expected_shape = shape
self.expected_len = len(self.filenames)

Expand All @@ -112,9 +113,8 @@ def setUp(self):
self.filename = os.path.join(self.filepath, 'T76*.png')
self.frame0 = frames[0]
self.frame1 = frames[2]
self.kwargs = dict(plugin='matplotlib')
self.klass = pims.ImageSequence
self.v = self.klass(self.filename, **self.kwargs)
self.v = self.klass(self.filename)
self.expected_shape = shape
self.expected_len = len(self.filenames)

Expand Down