darsia.CoordinateSystem#

class CoordinateSystem(img)[source]#

Bases: object

Class for coordinate system for general space-time images.

A coordinate system has knowledge about the conversion of voxels (in standard format), i.e., ijk format with (0,0,0) being identified with the top left front corner. This implicitly concludes that the coordinate system is directly related to a certain fixed indexing, provided at initialization. Conversion maps from voxels to coordinates and vice-versa are provided.

Generate a coordinate system based on the metadata of an existing image.

Parameters:
imgdarsia.Image

Image for which a coordinate system shall be constructed.

Methods

coordinate(voxel)

Conversion from voxel to Cartesian coordinate, i.e., from (row,col) to (x,y) format plus scaling for a 2d image.

coordinate_vector(pixel_vector)

Conversion from vectors (relative distances) in terms of pixels to coordinates.

length(num, axis)

Convert number of voxels/voxels to metric units, when interpreting in some given axis.

num_voxels(length, axis)

Convert length in metric units to number of voxels, when interpreting the length in some given axis.

pixel_vector(coordinate_vector)

Analogue to self.coorindate_vector().

voxel(coordinate)

Conversion from Cartesian coordinate to voxel in matrix indexing format.

Attributes

coordinates

Coordinate array of image, collecting all coordinates.

voxels

Voxel array of image, collecting all voxels.

indexing

Indexing of the underlying image.

dim

Dimension of the underlying space.

shape

Dimensions of the underlying images in terms of voxels.

dimensions

Physical dimensions in each index direction.

axes

Axes of the underlying space.

voxel_size

Voxel size in each dimension/axis.

domain

Extremal points/bounding box of the active coordinate system / the image.

max_coordinate

Extremal coordinate (max) of the active coordinate system / the image.

min_coordinate

Extremal coordinate (min) of the active coordinate system / the image.

coordinate(voxel)[source]#

Conversion from voxel to Cartesian coordinate, i.e., from (row,col) to (x,y) format plus scaling for a 2d image.

Handles both single and multiple voxels.

Parameters:
voxelnp.ndarray, list, tuple, Coordinate, or Voxel

Voxel location in the same format as the indexing of the underlying baseline image (see __init__); one voxel per row.

Returns:
np.ndarray

Corresponding coordinate in (x,y) format.

coordinate_vector(pixel_vector)[source]#

Conversion from vectors (relative distances) in terms of pixels to coordinates.

Parameters:
pixel_vectornp.ndarray

Vector(s) in pixel plane (one vector per row).

Returns:
np.ndarray

Coordinate vector(s) in Cartesian format.

length(num, axis)[source]#

Convert number of voxels/voxels to metric units, when interpreting in some given axis.

Parameters:
numint or array

Number(s) of voxels/voxels.

axisstr

Axis “x”, “y”, or “z”.

Returns:
float or array

Length in metric units.

num_voxels(length, axis)[source]#

Convert length in metric units to number of voxels, when interpreting the length in some given axis.

Parameters:
lengthfloat or 1d array of floats

Length(s) in metric units.

axisstr

Axis “x”, “y”, or “z”.

Returns:
int or array

Number(s) of voxels.

pixel_vector(coordinate_vector)[source]#

Analogue to self.coorindate_vector().

voxel(coordinate)[source]#

Conversion from Cartesian coordinate to voxel in matrix indexing format.

Handles both single and multiple coordinates.

Parameters:
coordinatenp.ndarray, list, Coordinate or Voxel

Coordinate in Cartesian format, i.e., [x,y,z]; one coordinate per row.

Returns:
np.ndarray

Corresponding pixels in “ij”/”ijk” format.

axes#

Axes of the underlying space.

property coordinates#

Coordinate array of image, collecting all coordinates.

Returns:
CoordinateArray

Coordinate array of image.

dim#

Dimension of the underlying space.

dimensions#

Physical dimensions in each index direction.

domain#

Extremal points/bounding box of the active coordinate system / the image.

indexing#

Indexing of the underlying image.

max_coordinate#

Extremal coordinate (max) of the active coordinate system / the image.

min_coordinate#

Extremal coordinate (min) of the active coordinate system / the image.

shape#

Dimensions of the underlying images in terms of voxels.

voxel_size#

Voxel size in each dimension/axis.

property voxels#

Voxel array of image, collecting all voxels.

Returns:
VoxelArray

Voxel array of image.