How to use the aicspylibczi.CziFile function in aicspylibczi

To help you get started, weā€™ve selected a few aicspylibczi 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 / czi_reader.py View on Github external
def metadata(self) -> _Element:
        """
        Load and return the metadata from the CZI file

        Returns
        -------
        The lxml Element Tree of the metadata
        """
        # We can't serialize lxml element trees so don't save the tree to the object
        # state
        return CziFile(self._file).meta
github AllenCellModeling / aicsimageio / aicsimageio / readers / czi_reader.py View on Github external
The dimensions to read from the file as a dictionary of string to integer.
            Default: None (Read all data from the image)

        Returns
        -------
        data: np.ndarray
            The data read for the dimensions provided.
        read_dimensions: List[Tuple[str, int]]]
            The dimension sizes that were returned from the read.
        """
        # Catch optional read dim
        if read_dims is None:
            read_dims = {}

        # Init czi
        czi = CziFile(img)

        # Read image
        log.debug(f"Reading dimensions: {read_dims}")
        data, dims = czi.read_image(**read_dims)

        # Drop dims that shouldn't be provided back
        ops = []
        real_dims = []
        for i, dim_info in enumerate(dims):
            # Expand dimension info
            dim, size = dim_info

            # If the dim was provided in the read dims we know a single plane for that
            # dimension was requested so remove it
            if dim in read_dims:
                ops.append(0)
github AllenCellModeling / aicsimageio / aicsimageio / readers / czi_reader.py View on Github external
def _read_immediate(self) -> da.core.Array:
        # Init temp czi
        czi = CziFile(self._file)

        # Safely construct the numpy array or catch any exception
        try:
            # Get image dims indicies
            image_dim_indices = czi.dims_shape()

            # Catch inconsistent scene dimension sizes
            if len(image_dim_indices) > 1:
                # Choose the provided scene
                log.info(
                    f"File contains variable dimensions per scene, "
                    f"selected scene: {self.specific_s_index} for data retrieval."
                )

                # Get the specific scene
                if self.specific_s_index < len(image_dim_indices):
github AllenCellModeling / aicsimageio / aicsimageio / readers / czi_reader.py View on Github external
In that case, use this parameter to specify a specific scene to construct a
            dask array for.
            Default: 0 (select the first scene)

        Returns
        -------
        img: dask.array.core.Array
            The constructed dask array where certain dimensions are chunked.
        dims: str
            The dimension order as a string.
        """
        # Resolve image path
        img = CziReader._resolve_image_path(img)

        # Init temp czi
        czi = CziFile(img)

        # Safely construct the dask array or catch any exception
        try:
            return CziReader._daread(img=img, czi=czi, chunk_by_dims=chunk_by_dims, S=S)

        except Exception as e:
            # A really bad way to close any connection to the CZI object
            czi._bytes = None
            czi.reader = None

            raise e
github AllenCellModeling / aicsimageio / aicsimageio / readers / czi_reader.py View on Github external
def dims(self) -> str:
        if self._dims is None:
            self._dims = CziFile(self._file).dims
        return self._dims

aicspylibczi

A python module and a python extension for Zeiss (CZI/ZISRAW) microscopy files.

GPL-3.0
Latest version published 5 months ago

Package Health Score

66 / 100
Full package analysis

Popular aicspylibczi functions