ddd_pylib.

ImageUtils#

class ddd_pylib.ImageUtils[source]#

Bases: object

Methods

static completeCalibrationFrom(imA, imB)[source]#

Completes the calibration of image B from image A. Only the axes present in image B will be completed. If an axis already has a scale or unit in image B, it will not be overwritten.

Parameters:
static copyCalibrationTo(imA, imB)[source]#

Copies the calibration (scale and units) from image A to image B. Only the axes present in image B will be copied. If an axis is not present in image A, it will not be copied.

Parameters:
static ensureAxes(da, axes=['T', 'Z', 'Y', 'X'])[source]#

Forces the DataArray to have the specified axes. If an axis is missing, it is added with size 1.

Parameters:
Return type:

DataArray

static ensureCalibration(img)[source]#

Ensures that the image has calibration information (scale and units) for valid axes. If not present, it sets default values.

Parameters:

img (DataArray)

static getAnisotropy(img)[source]#

Computes the anisotropy factor Z/X for a given image. Return 1.0 if the image does not have a Z dimension. Handles different units for Z and X.

Parameters:

img (DataArray)

Return type:

float

static removeExtraAxes(da, axes=['T', 'Z', 'Y', 'X'])[source]#

Removes any axes from the DataArray that are not in the specified list of axes.

Parameters:
Return type:

DataArray

static scaleToTuple(img)[source]#

Returns the scale of the image as a tuple, in the order of the image’s dimensions. If a dimension does not have a scale, it defaults to _DEFAULT_SCALING.

Parameters:

img (DataArray)

static unitsToTuple(img)[source]#

Returns the units of the image as a tuple, in the order of the image’s dimensions. If a dimension does not have a unit, it defaults to _DEFAULT_UNITS.

Parameters:

img (DataArray)

static writeTiff(folder, img, use_imj=True)[source]#

Writes a xr.DataArray image to a TIFF file in the specified folder. The folder is created if it doesn’t exist. The ‘name’ attribute of the DataArray is used as the filename. If the name is None, ‘image’ is used as a default.

Parameters: