qubalab.images.metadata package

qubalab.images.metadata.image_channel module

class qubalab.images.metadata.image_channel.ImageChannel(name: str, color: tuple[float, float, float])

Bases: object

Simple data class to store the name and the color of a channel of an image.

Parameters:
  • name – the name of the channel

  • color – the RGB color of the channel, with each component between 0 and 1

color: tuple[float, float, float]
name: str

qubalab.images.metadata.image_metadata module

class qubalab.images.metadata.image_metadata.ImageMetadata(path: str, name: str, shapes: tuple[ImageShape, ...], pixel_calibration: PixelCalibration, is_rgb: bool, dtype: dtype, channels: tuple[ImageChannel, ...] | None = None, downsamples=None)

Bases: object

Simple class to store core metadata for a pyramidal image.

Parameters:
  • path – the local path to the image

  • name – the image name

  • shapes – the image shape, for each resolution of the image

  • pixel_calibration – the pixel calibration information of the image

  • is_rgb – whether pixels of the image are stored with the RGB format

  • dtype – the type of the pixel values

  • _channels – the channels of the image (optional)

  • _downsamples – the downsamples of the image (optional)

property channels: tuple[ImageChannel, ...]

The channels of the image.

property downsamples: tuple[float, ...]

The downsamples of the image.

property height: int

The height of the full-resolution image.

property n_channels: int

The number of channels of the image.

property n_resolutions: int

The number of resolutions of the image.

property n_timepoints: int

The number of time points of the image.

property n_z_slices: int

The number of z-slices of the image.

property shape: ImageShape

The dimensions of the full-resolution image.

property width: int

The width of the full-resolution image.

qubalab.images.metadata.image_shape module

class qubalab.images.metadata.image_shape.ImageShape(x: int, y: int, t: int = 1, c: int = 1, z: int = 1)

Bases: object

Simple data class to store an image shape.

Parameters:
  • x – the image width

  • y – the image height

  • t – the number of time points

  • c – the number of channels

  • z – the number of z-stacks

as_tuple(dims: str = 'tczyx') tuple

Return a tuple describing this ImageShape.

Parameters:

dims – the format the resulting tuple should have. Each character must be one of ‘tczyx’

Returns:

a tuple describing this ImageShape with the specified format

Raises:

AttributeError – when a character of dims is not in ‘tczyx’

c: int = 1
from_tczyx() ImageShape

Create an ImageShape from a list of arguments.

Parameters:

args – image width, image height, number of time points, number of channels, number of z-stacks (in that order)

Returns:

an ImageShape corresponding to the arguments

Raises:

IndexeError – when there are less than five arguments

t: int = 1
x: int
y: int
z: int = 1

qubalab.images.metadata.pixel_calibration module

class qubalab.images.metadata.pixel_calibration.PixelCalibration(length_x: PixelLength = PixelLength(length=1.0, unit='pixels'), length_y: PixelLength = PixelLength(length=1.0, unit='pixels'), length_z: PixelLength = PixelLength(length=1.0, unit='pixels'))

Bases: object

Simple data class for storing pixel calibration information.

Parameters:
  • length_x – the pixel size along the x-axis

  • length_y – the pixel size along the y-axis

  • length_z – the pixel size along the z-axis

is_calibrated() bool

Indicate if this PixelCalibration has at least one non-default length.

Returns:

whether this PixelCalibration has at least one non-default length

length_x: PixelLength = PixelLength(length=1.0, unit='pixels')
length_y: PixelLength = PixelLength(length=1.0, unit='pixels')
length_z: PixelLength = PixelLength(length=1.0, unit='pixels')
class qubalab.images.metadata.pixel_calibration.PixelLength(length: float = 1.0, unit: str = 'pixels')

Bases: object

Simple data class to store pixel size information, along one dimension.

Can be thought of as the pixel width, pixel height or pixel depth (z-spacing).

Parameters:
  • length – the length of the pixel, by default 1

  • unit – a text describing the unit of length, by default “pixels”

static create_microns(length: float) PixelLength

Create a PixelLength with a unit of micrometers (µm).

Parameters:

length – the length of the pixel

Returns:

a pixel length of the provided length with the ‘micrometer’ unit

static create_unknown(length: float) PixelLength

Create a PixelLength with an unknown unit.

Parameters:

length – the length of the pixel

Returns:

a pixel length of the provided length with no unit

is_default() bool

Returns True if this is a default value (length is 1.0 and unit is ‘pixels’)

Returns:

whether this is a default pixel length

length: float = 1.0
unit: str = 'pixels'