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

Fix ImageIOReader for images with channels and reordered axes #430

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions pims/imageio_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,24 @@ def __init__(self, filename, **kwargs):
)

first_frame = self.get_frame_2D(t=0)
self._shape = first_frame.shape
self._dtype = first_frame.dtype

self._setup_axes()
self._register_get_frame(self.get_frame_2D, 'yx')
self._setup_axes(first_frame.shape)
if len(first_frame.shape) == 2:
self._register_get_frame(self.get_frame_2D, 'yx')
else:
self._register_get_frame(self.get_frame_2D, 'yxc')

def _setup_axes(self):
def _setup_axes(self, frame_shape):
"""Setup the xyctz axes, iterate over t axis by default

"""
if self._shape[1] > 0:
self._init_axis('x', self._shape[1])
if self._shape[0] > 0:
self._init_axis('y', self._shape[0])
if frame_shape[1] > 0:
self._init_axis('x', frame_shape[1])
if frame_shape[0] > 0:
self._init_axis('y', frame_shape[0])
if len(frame_shape) > 2:
self._init_axis('c', frame_shape[3])
if self._len > 0:
self._init_axis('t', self._len)

Expand Down Expand Up @@ -138,10 +142,6 @@ def __iter__(self):
def frame_rate(self):
return self.get_metadata()['fps']

@property
def frame_shape(self):
return self._shape

@property
def pixel_type(self):
return self._dtype
Expand Down