How to use the aicsimageio.constants.Dimensions.Channel 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 / aics_image.py View on Github external
napari.view_image(
                        data,
                        is_pyramid=False,
                        ndisplay=3 if Dimensions.SpatialZ in dims else 2,
                        title=title,
                        axis_labels=dims.replace(Dimensions.Channel, ""),
                        rgb=rgb,
                        **kwargs,
                    )

            # Handle all other images besides RGB not requested
            else:
                # Channel axis
                c_axis = (
                    dims.index(Dimensions.Channel)
                    if Dimensions.Channel in dims
                    else None
                )

                # Set visible based on number of channels
                if c_axis is not None:
                    if data.shape[c_axis] > 3:
                        visible = False
                    else:
                        visible = True
                else:
                    visible = True

                # Drop channel from dims string
                dims = (
                    dims.replace(Dimensions.Channel, "")
                    if Dimensions.Channel in dims
github AllenCellModeling / aicsimageio / aicsimageio / readers / reader.py View on Github external
"""
        Attempts to use the image's metadata to get the image's channel names.

        Parameters
        ----------
        scene: int
            The index of the scene for which to return channel names.

        Returns
        -------
        channels_names: Optional[List[str]]
            List of strings representing the channel names.
            If channel dimension not present in file, return None.
        """
        # Check for channels dimension
        if Dimensions.Channel not in self.dims:
            return None

        # Channel dimension in reader data, get default channel names
        channel_index = self.dims.index(Dimensions.Channel)
        channel_dim_size = self.dask_data.shape[channel_index]
        return [str(i) for i in range(channel_dim_size)]
github AllenCellModeling / aicsimageio / aicsimageio / readers / lif_reader.py View on Github external
[
             {'S': (0, 3), 'T': (0,7), 'X': (0, 475), 'Y': (0, 325), 'Z': (0, 4)}
            ].
            The result for a similarly shaped file but with different number of time
            points per scene would yield
            [
             {'S': (0, 1), 'T': (0,8), 'X': (0, 475), 'Y': (0, 325), 'Z': (0, 4)},
             {'S': (1, 2), 'T': (0,6), 'X': (0, 475), 'Y': (0, 325), 'Z': (0, 4)},
             {'S': (2, 3), 'T': (0,7), 'X': (0, 475), 'Y': (0, 325), 'Z': (0, 4)}
            ]

        """
        shape_list = [
            {
                Dimensions.Time: (0, img.nt),
                Dimensions.Channel: (0, img.channels),
                Dimensions.SpatialZ: (0, img.nz),
                Dimensions.SpatialY: (0, img.dims[1]),
                Dimensions.SpatialX: (0, img.dims[0]),
            }
            for idx, img in enumerate(lif.get_iter_image())
        ]
        consistent = all(elem == shape_list[0] for elem in shape_list)
        if consistent:
            shape_list[0][Dimensions.Scene] = (0, len(shape_list))
            shape_list = [shape_list[0]]
        else:
            for idx, lst in enumerate(shape_list):
                lst[Dimensions.Scene] = (idx, idx + 1)
        return shape_list
github AllenCellModeling / aicsimageio / aicsimageio / aics_image.py View on Github external
if Dimensions.Channel in dims
                    else None
                )

                # Set visible based on number of channels
                if c_axis is not None:
                    if data.shape[c_axis] > 3:
                        visible = False
                    else:
                        visible = True
                else:
                    visible = True

                # Drop channel from dims string
                dims = (
                    dims.replace(Dimensions.Channel, "")
                    if Dimensions.Channel in dims
                    else dims
                )

                # Run napari
                with napari.gui_qt():
                    napari.view_image(
                        data,
                        is_pyramid=False,
                        ndisplay=3 if Dimensions.SpatialZ in dims else 2,
                        channel_axis=c_axis,
                        axis_labels=dims,
                        title=title,
                        visible=visible,
                        **kwargs,
                    )
github AllenCellModeling / aicsimageio / aicsimageio / aics_image.py View on Github external
def size_c(self) -> int:
        """
        Returns
        -------
        size: int
            The size of the Channel dimension.
        """
        return self.size(Dimensions.Channel)[0]
github AllenCellModeling / aicsimageio / aicsimageio / readers / default_reader.py View on Github external
def get_channel_names(self, scene: int = 0) -> Optional[List[str]]:
        # Check for channel in dims
        if Dimensions.Channel in self.dims:
            channel_index = self.dims.index(Dimensions.Channel)
            channel_dim_size = self.dask_data.shape[channel_index]

            # RGB vs RGBA vs other
            if channel_dim_size == 3:
                return ["Red", "Green", "Blue"]
            elif channel_dim_size == 4:
                return ["Red", "Green", "Blue", "Alpha"]
            else:
                return [str(i) for i in range(channel_dim_size)]

        return None
github AllenCellModeling / aicsimageio / aicsimageio / aics_image.py View on Github external
# Handle RGB entirely differently
            if rgb:
                # Swap channel to last dimension
                new_dims = f"{dims.replace(Dimensions.Channel, '')}{Dimensions.Channel}"
                data = transforms.transpose_to_dims(
                    data=data, given_dims=dims, return_dims=new_dims
                )

                # Run napari
                with napari.gui_qt():
                    napari.view_image(
                        data,
                        is_pyramid=False,
                        ndisplay=3 if Dimensions.SpatialZ in dims else 2,
                        title=title,
                        axis_labels=dims.replace(Dimensions.Channel, ""),
                        rgb=rgb,
                        **kwargs,
                    )

            # Handle all other images besides RGB not requested
            else:
                # Channel axis
                c_axis = (
                    dims.index(Dimensions.Channel)
                    if Dimensions.Channel in dims
                    else None
                )

                # Set visible based on number of channels
                if c_axis is not None:
                    if data.shape[c_axis] > 3:
github AllenCellModeling / aicsimageio / aicsimageio / aics_image.py View on Github external
napari.view_image(
                        data,
                        is_pyramid=False,
                        ndisplay=3 if Dimensions.SpatialZ in dims else 2,
                        title=title,
                        axis_labels=dims.replace(Dimensions.Channel, ""),
                        rgb=rgb,
                        **kwargs,
                    )

            # Handle all other images besides RGB not requested
            else:
                # Channel axis
                c_axis = (
                    dims.index(Dimensions.Channel)
                    if Dimensions.Channel in dims
                    else None
                )

                # Set visible based on number of channels
                if c_axis is not None:
                    if data.shape[c_axis] > 3:
                        visible = False
                    else:
                        visible = True
                else:
                    visible = True

                # Drop channel from dims string
                dims = (
                    dims.replace(Dimensions.Channel, "")
                    if Dimensions.Channel in dims
github AllenCellModeling / aicsimageio / aicsimageio / readers / lif_reader.py View on Github external
def size_c(self) -> int:
        return self._size_of_dimension(Dimensions.Channel)
github AllenCellModeling / aicsimageio / aicsimageio / readers / czi_reader.py View on Github external
def size_c(self) -> int:
        return self._size_of_dimension(Dimensions.Channel)