camera_alignment_core.channel_info package#

Submodules#

camera_alignment_core.channel_info.channel_info_abc module#

class camera_alignment_core.channel_info.channel_info_abc.CameraPosition(value)#

Bases: Enum

An enumeration.

BACK = 'back'#
LEFT = 'left'#
static parse_position_from_detector_name(detector_name: str) CameraPosition#

Given a detector name like ‘Detector:Camera 2 (Left)’ and ‘Detector:Camera 1 (Back)’, return CameraPosition that best matches. This is done by naively searching for a CameraPosition value anywhere within the detector name.

This procedure is heuristic driven, but as of 2021-11, it holds up reliably across tests of CZI images acquired at AICS since 2018/2019ish. Detector names are specific to the hardware configuration of our Zeiss spinning disk microscopes. Configured otherwise (e.g., at another lab, or at AICS at another point in time), the heuristic shouldn’t be expected to hold up and this approach will require refactoring.

Parameters:

detector_name (str) –

This corresponds to the “Id” attribute from InstrumentDetector XML elements from embedded metadata within CZI images. Example XML path:

Directly: “Metadata/Information/Instrument/Detectors” Via channels: “Metadata/Information/Image/Dimensions/Channels/DetectorSettings/Detector”

class camera_alignment_core.channel_info.channel_info_abc.Channel(channel_index: int, channel_name: str, emission_wavelength: Optional[float], camera_name: str, camera_position: camera_alignment_core.channel_info.channel_info_abc.CameraPosition)#

Bases: object

camera_name: str#
camera_position: CameraPosition#
channel_index: int#
channel_name: str#
emission_wavelength: Optional[float]#
class camera_alignment_core.channel_info.channel_info_abc.ChannelInfo(image: AICSImage)#

Bases: ABC

This utility encapsulates behavior for querying for channels within an image.

Create a ChannelInfo using the channel_info_factory factory function exported from the channel_info module. That factory will provide a concrete class implementing this interface that is appropriate for a given image format.

abstract property channels: List[Channel]#

List of channels, in order, within image.

channels_from_camera_position(camera_position: CameraPosition) List[Channel]#

Return listing of Channels that were acquired on the camera with position camera_position.

Example

Get list of all back-camera channels >>> channel_info = channel_info_factory(“/path/to/image.czi”) >>> back_camera_channels = channel_info.channels_from_camera_position(CameraPosition.BACK)

find_channels_closest_in_emission_wavelength_between_cameras() Tuple[Channel, Channel]#

Return pair of Channels from separate cameras that are closest in their emission wavelength.

This is intended to be used to dynamically choose the two channels of an optical control image that should be used to generate an alignment matrix. As such, this method only has expected utility if the image passed to ChannelInfo is an optical control.

Returns:

Tuple[Channel, Channel] – Each Channel was acquired on a different camera, and among all the channels taken on each of the cameras, these are the channels that are closest in their emission wavelengths. Returned Channels are sorted in ascending order by their emission wavelength.

Return type:

A two-element tuple of Channel.

Raises:

ValueError : – If image was acquired using only one camera, its Channel(s) will be from the same camera, and therefore calling this method does not make sense. If somehow more than two cameras are used, the core logic of this method would break, and is likewise not supported.

camera_alignment_core.channel_info.czi_channel_info module#

class camera_alignment_core.channel_info.czi_channel_info.CziChannelInfo(image: AICSImage)#

Bases: ChannelInfo

ChannelInfo implementation specific to CZI images. See docstrings in channel_info_abc.py.

Notes

This implementation of ChannelInfo is required because the CZI -> OME metadata conversion is not yet (as of 2021-11) reliable. Once that conversion is production-ready and Channels can be reliably constituted from OME metadata, this can be safely deleted.

property channels: List[Channel]#

List of channels, in order, within image.

static is_czi_file(image_path: Union[str, Path]) bool#

Module contents#

class camera_alignment_core.channel_info.CameraPosition(value)#

Bases: Enum

An enumeration.

BACK = 'back'#
LEFT = 'left'#
static parse_position_from_detector_name(detector_name: str) CameraPosition#

Given a detector name like ‘Detector:Camera 2 (Left)’ and ‘Detector:Camera 1 (Back)’, return CameraPosition that best matches. This is done by naively searching for a CameraPosition value anywhere within the detector name.

This procedure is heuristic driven, but as of 2021-11, it holds up reliably across tests of CZI images acquired at AICS since 2018/2019ish. Detector names are specific to the hardware configuration of our Zeiss spinning disk microscopes. Configured otherwise (e.g., at another lab, or at AICS at another point in time), the heuristic shouldn’t be expected to hold up and this approach will require refactoring.

Parameters:

detector_name (str) –

This corresponds to the “Id” attribute from InstrumentDetector XML elements from embedded metadata within CZI images. Example XML path:

Directly: “Metadata/Information/Instrument/Detectors” Via channels: “Metadata/Information/Image/Dimensions/Channels/DetectorSettings/Detector”

class camera_alignment_core.channel_info.Channel(channel_index: int, channel_name: str, emission_wavelength: Optional[float], camera_name: str, camera_position: camera_alignment_core.channel_info.channel_info_abc.CameraPosition)#

Bases: object

camera_name: str#
camera_position: CameraPosition#
channel_index: int#
channel_name: str#
emission_wavelength: Optional[float]#
class camera_alignment_core.channel_info.ChannelInfo(image: AICSImage)#

Bases: ABC

This utility encapsulates behavior for querying for channels within an image.

Create a ChannelInfo using the channel_info_factory factory function exported from the channel_info module. That factory will provide a concrete class implementing this interface that is appropriate for a given image format.

abstract property channels: List[Channel]#

List of channels, in order, within image.

channels_from_camera_position(camera_position: CameraPosition) List[Channel]#

Return listing of Channels that were acquired on the camera with position camera_position.

Example

Get list of all back-camera channels >>> channel_info = channel_info_factory(“/path/to/image.czi”) >>> back_camera_channels = channel_info.channels_from_camera_position(CameraPosition.BACK)

find_channels_closest_in_emission_wavelength_between_cameras() Tuple[Channel, Channel]#

Return pair of Channels from separate cameras that are closest in their emission wavelength.

This is intended to be used to dynamically choose the two channels of an optical control image that should be used to generate an alignment matrix. As such, this method only has expected utility if the image passed to ChannelInfo is an optical control.

Returns:

Tuple[Channel, Channel] – Each Channel was acquired on a different camera, and among all the channels taken on each of the cameras, these are the channels that are closest in their emission wavelengths. Returned Channels are sorted in ascending order by their emission wavelength.

Return type:

A two-element tuple of Channel.

Raises:

ValueError : – If image was acquired using only one camera, its Channel(s) will be from the same camera, and therefore calling this method does not make sense. If somehow more than two cameras are used, the core logic of this method would break, and is likewise not supported.

camera_alignment_core.channel_info.channel_info_factory(image_path: Union[str, Path]) ChannelInfo#

Construct a concrete ChannelInfo instance that is type-appropriate for a given image.

Current concrete ChannelInfo implementations:
  1. CziChannelInfo, supporting CZI images.