tomosipo.geometry.volume_vec module

class tomosipo.geometry.volume_vec.VolumeVectorGeometry(shape, pos, w=(1, 0, 0), v=(0, 1, 0), u=(0, 0, 1))[source]

Bases: object

Documentation for VolumeVectorGeometry

property corners

Returns a vector with the corners of the volume

Returns:

np.array Array with shape (num_steps, 8, 3), describing the 8 corners of volume orientation in (Z, Y, X)-coordinates.

Return type:

np.array

property lower_left_corner

Returns a vector with the positions of the lower-left corner the object

Returns:

np.array Array with shape (num_steps, 3), describing the position of the lower-left corner of each volume orientation in (Z, Y, X)-coordinates.

Return type:

np.array

property num_steps

The number of orientations and positions of this volume

A volume vector geometry can have multiple positions and orientations, similar to how an astra projection geometry has multiple angles. This property describes how many such “steps” are described by this object.

Returns:

the number of steps

Return type:

int

property pos
reshape(new_shape)[source]

Change the number of voxels without changing volume size

Parameters:

new_shape – int or (int, int, int) The new shape of the detector in pixels in (w, v, u) direction.

Returns:

self

Return type:

VolumeVectorGeometry

property shape
property size

Returns the absolute size of the volume

Note: Because the local coordinate frame of the volume may

change over time, the size of the volume may also change. If this happens, this property throws a ValueError.

Returns:

the size in each dimension of the volume (if constant)

Return type:

(scalar, scalar, scalar)

property sizes

Returns the absolute sizes of the volume

The size property is defined relative to the local coordinate frame of the object. Because the vectors w, u, v may change over time, abs_size is a vector with shape (num_steps, 3).

Returns:

a numpy array of shape (num_steps, 3) describing the size of the object.

Return type:

to_vec()[source]

Returns a volume vector geometry

Returns:

self

Return type:

VolumeVectorGeometry

property u
property v
property voxel_size

The voxel size of the volume

Note: Because the local coordinate frame of the volume may

change over time, the voxel size of the volume may also change. If this happens, this property throws a ValueError.

Returns:

the size in each dimension of the volume (if constant)

Return type:

(scalar, scalar, scalar)

property voxel_sizes

The voxel sizes of the volume

Note: Because the local coordinate frame of the volume may

change over time, the voxel size of the volume may also change.

Returns:

a numpy array of shape (num_steps, 3) describing the voxel size of the volume.

Return type:

np.array

property w
tomosipo.geometry.volume_vec.random_volume_vec()[source]

Create a random volume vector geometry

Useful for testing. :returns: a volume vector geometry with random size, position and orientation. :rtype: VolumeVectorGeometry

tomosipo.geometry.volume_vec.volume_vec(*, shape, pos=0, w=(1, 0, 0), v=(0, 1, 0), u=(0, 0, 1))[source]

Create an arbitrarily oriented volume geometry

Like the parallel and cone vector geometries, the volume vector geometry can be arbitrarily oriented and positioned.

The position describes the center of the volume. The vectors w, v, u describe the coordinate frame of a single voxel, just like u and v do for detector pixels of vector projection geometries.

Parameters:
  • shape (int | Tuple[int, int, int] | Iterable[int]) – The shape of the volume in voxels.

  • pos (float | Tuple[float, float, float] | Iterable[Tuple[float, float, float]] | ndarray) – A numpy array of dimension (num_steps, 3) describing the center of the volume in world-coordinates (z, y, x). You may also pass a 3-tuple or a scalar.

  • w (Tuple[float, float, float] | Iterable[Tuple[float, float, float]] | ndarray) – A numpy array of dimension (num_steps, 3) describing the w basis element in (z, y, x) coordinates. Default is (1, 0, 0).

  • v (Tuple[float, float, float] | Iterable[Tuple[float, float, float]] | ndarray) – A numpy array of dimension (num_steps, 3) describing the v basis element in (z, y, x) coordinates. Default is (0, 1, 0).

  • u (Tuple[float, float, float] | Iterable[Tuple[float, float, float]] | ndarray) – A numpy array of dimension (num_steps, 3) describing the u basis element in (z, y, x) coordinates. Default is (0, 0, 1).

Returns:

  • VolumeVectorGeometry – An arbitarily oriented volume geometry.