How to use the aicsimageio.exceptions.UnsupportedFileFormatError function in aicsimageio

To help you get started, we’ve selected a few aicsimageio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AllenCellModeling / aicsimageio / aicsimageio / readers / reader.py View on Github external
def __init__(
        self, file: types.ImageLike, dask_kwargs: Dict[str, Any] = {}, **kwargs
    ):
        # This will both fully expand and enforce that the filepath exists
        file = self._resolve_image_path(file)

        # Check type
        if not self.is_this_type(file):
            raise exceptions.UnsupportedFileFormatError(
                f"Reader does not support file or object: {file}"
            )

        # Store this filepath
        self._file = file

        # Store dask client and cluster setup
        self._dask_kwargs = dask_kwargs
        self._client = None
        self._cluster = None
github AllenCellModeling / aicsimageio / aicsimageio / readers / default_reader.py View on Github external
# functions
                lazy_arrays = np.ndarray(operating_shape, dtype=object)
                for indicies, _ in np.ndenumerate(lazy_arrays):
                    lazy_arrays[indicies] = da.from_delayed(
                        delayed(self._get_data)(self._file, indicies[0]),
                        shape=sample.shape,
                        dtype=sample.dtype,
                    )

                # Block them into a single dask array
                return da.block(lazy_arrays.tolist())

            # Catch all other image types as unsupported
            # https://imageio.readthedocs.io/en/stable/userapi.html#imageio.core.format.Reader.get_length
            else:
                raise exceptions.UnsupportedFileFormatError(self._file)
github AllenCellModeling / aicsimageio / aicsimageio / readers / default_reader.py View on Github external
# Handle many image formats like gif, mp4, etc
                elif image_length > 1:
                    frames = []
                    for frame in reader.iter_data():
                        frames.append(frame)

                    return np.stack(frames)

                # Catch all other image types as unsupported
                # https://imageio.readthedocs.io/en/stable/userapi.html#imageio.core.format.Reader.get_length
                else:
                    raise exceptions.UnsupportedFileFormatError(self._file)

        # Reraise unsupported file format
        except exceptions.UnsupportedFileFormatError:
            raise exceptions.UnsupportedFileFormatError(self._file)
github AllenCellModeling / aicsimageio / aicsimageio / aics_image.py View on Github external
def determine_reader(data: types.ImageLike) -> Type[Reader]:
        """
        Cheaply check to see if a given file is a recognized type and return the
        appropriate reader for the file.
        """
        # Iterate through the ordered supported readers to find the right one
        for reader_class in SUPPORTED_READERS:
            if reader_class.is_this_type(data):
                return reader_class

        raise UnsupportedFileFormatError(data)
github AllenCellModeling / aicsimageio / aicsimageio / readers / default_reader.py View on Github external
# Handle many image formats like gif, mp4, etc
                elif image_length > 1:
                    frames = []
                    for frame in reader.iter_data():
                        frames.append(frame)

                    return np.stack(frames)

                # Catch all other image types as unsupported
                # https://imageio.readthedocs.io/en/stable/userapi.html#imageio.core.format.Reader.get_length
                else:
                    raise exceptions.UnsupportedFileFormatError(self._file)

        # Reraise unsupported file format
        except exceptions.UnsupportedFileFormatError:
            raise exceptions.UnsupportedFileFormatError(self._file)
github AllenCellModeling / aicsimageio / aicsimageio / aics_image.py View on Github external
def determine_reader(data: types.ImageLike) -> Type[Reader]:
        """
        Cheaply check to see if a given file is a recognized type and return the
        appropriate reader for the file.
        """
        # Iterate through the ordered supported readers to find the right one
        for reader_class in SUPPORTED_READERS:
            if reader_class.is_this_type(data):
                return reader_class

        raise UnsupportedFileFormatError(data)