ImageMeta

larcv is built on the idea that sparse data exists in a real space: active pixels in a detector, for example, or thresholded points in an image. The data, however, have a relationship to the full space and to all the other auxilliary data products that come with them. To simplify the mapping between data products in larcv, we implement the concept of ImageMeta.

With the exception of the particle data product, each of the data products that larcv can serialize has an associated vector of projection IDs which can serve as a multipurpose enumeration of detectors: it can be the multiple wire-planes of a LArTPC, or several readout regions in a segmented detector. It is up the creator of the data to decide. To describe the properties of the volume indicated by the projection ID, an ImageMeta object is stored with each projection that describes the physical volume in terms of number of voxels, voxel size, and origin across all dimensions.

The ImageMeta objects also provide a convenient interface for raveling/unraveling a multi-dimension index, identical to the numpy scheme of mapping a multi-index to a single flattened array index. The ImageMeta interface is shared across all data products that have a spatial relation, ensuring consistent development patterns. The ImageMeta objects also provide the absolute positioning of all objects, enabling full images to be built from objects that represent only a subset of a detector, potentially.

Below, we include the API for ImageMeta2D, but please note that ImageMeta is available as ImageMeta1D, ImageMeta2D, ImageMeta3D, and ImageMeta4D. The API is the same in all cases (in fact in C++ these are just different template specializations.)

class larcv.ImageMeta2D

Generalized class for interpreting sparse (or dense) images from their in-memory layout to physical values. An ImageMeta object is defined by it’s origin, size, and number of voxels as well as a unique index, representing an identifier in a multi-view image, for example.

Optionally, a unit can be provided to convert pixel locations to real-space coordinates, if desired.

compress(*args, **kwargs)

Overloaded function.

  1. compress(self: larcv.pylarcv.ImageMeta2D, compression: List[int[2]]) -> larcv.pylarcv.ImageMeta2D

    Compress the image meta by a unique compression factor along each axis. Compession only affects voxel size. Compression factor must be an integer > 0.

  2. compress(self: larcv.pylarcv.ImageMeta2D, compression: int) -> larcv.pylarcv.ImageMeta2D

    Compress the image meta by the same compression factor along each axis. Compession only affects voxel size. Compression factor must be an integer > 0.

coordinate(self: larcv.pylarcv.ImageMeta2D, index: int, axis: int) int

Convert single-value index to coordinate along specified axis.

coordinates(*args, **kwargs)

Overloaded function.

  1. coordinates(self: larcv.pylarcv.ImageMeta2D, index: int) -> List[int]

Convert single-value index to coordinates vector. Similar to numpy.unravel.

  1. coordinates(self: larcv.pylarcv.ImageMeta2D, index: List[int], output_coordinates: List[int]) -> None

    “Convert a vector of indexes to coordinate location. Similar to numpy.unravel. Coordinates is flattened here as [x0, y0, z0, x1, y1, z1, x2, y2, z2, x3 ….].”

dump(self: larcv.pylarcv.ImageMeta2D) str

Return a string representation of this ImageMeta.

id(self: larcv.pylarcv.ImageMeta2D) int

Same as projection_id.

image_size(*args, **kwargs)

Overloaded function.

  1. image_size(self: larcv.pylarcv.ImageMeta2D, axis: int) -> float

Return the size of the image on specified axis.

  1. image_size(self: larcv.pylarcv.ImageMeta2D) -> float

Return the size of the image on all axes.

index(*args, **kwargs)

Overloaded function.

  1. index(self: larcv.pylarcv.ImageMeta2D, coordinate: List[int]) -> int

Convert the 1D coordinate vector to a single index location. Similar to numpy.ravel.

  1. index(self: larcv.pylarcv.ImageMeta2D, arg0: List[int], arg1: List[int]) -> None

    “Convert the flattened, multi-coordinate vector to a single index location. Similar to numpy.ravel. Coordinates is flattened here as [x0, y0, z0, x1, y1, z1, x2, y2, z2, x3 ….].”

is_valid(self: larcv.pylarcv.ImageMeta2D) bool

Check if this ImageMeta is valid.

max(*args, **kwargs)

Overloaded function.

  1. max(self: larcv.pylarcv.ImageMeta2D, axis: int) -> float

Return the maximum of the ImageMeta space along specified axis.

  1. max(self: larcv.pylarcv.ImageMeta2D) -> List[float]

Return the maximum of the ImageMeta space across all axes.

min(*args, **kwargs)

Overloaded function.

  1. min(self: larcv.pylarcv.ImageMeta2D, axis: int) -> float

Return the minimum of the ImageMeta space along specified axis.

  1. min(self: larcv.pylarcv.ImageMeta2D) -> List[float]

Return the minimum of the ImageMeta space across all axes.

n_dims(self: larcv.pylarcv.ImageMeta2D) int

Return the total number of dimensions.

number_of_voxels(*args, **kwargs)

Overloaded function.

  1. number_of_voxels(self: larcv.pylarcv.ImageMeta2D, axis: int) -> int

Return the number of voxels on the specified axis.

  1. number_of_voxels(self: larcv.pylarcv.ImageMeta2D) -> int

Return the number of voxels on all axes.

origin(*args, **kwargs)

Overloaded function.

  1. origin(self: larcv.pylarcv.ImageMeta2D, axis: int) -> float

Return the origin on the specified axis

  1. origin(self: larcv.pylarcv.ImageMeta2D) -> float

Return the origin on all axes

position(*args, **kwargs)

Overloaded function.

  1. position(self: larcv.pylarcv.ImageMeta2D, index: int) -> List[float]

Provide absolute position of the center of a specified pixel index.

  1. position(self: larcv.pylarcv.ImageMeta2D, coordinates: List[int]) -> List[float]

Provide absolute position of the center of a specified pixel coordinates.

  1. position(self: larcv.pylarcv.ImageMeta2D, index: int, axis: int) -> float

Provide absolute position of the center of a specified pixel index along axis.

  1. position(self: larcv.pylarcv.ImageMeta2D, coordinates: List[int], axis: int) -> float

Provide absolute position of the center of a specified pixel coordinates along axis.

position_to_coordinate(*args, **kwargs)

Overloaded function.

  1. position_to_coordinate(self: larcv.pylarcv.ImageMeta2D, position: List[float]) -> List[int]

Return the coordinates of the voxel that contains specified position.

  1. position_to_coordinate(self: larcv.pylarcv.ImageMeta2D, position: float, axis: int) -> int

Return the coordinate of the voxel that contains specified position, along specified axis.

position_to_index(self: larcv.pylarcv.ImageMeta2D, position: List[float]) int

Return the index of the voxel that contains specified position.

projection_id(self: larcv.pylarcv.ImageMeta2D) int

Return the projection ID.

set_dimension(self: larcv.pylarcv.ImageMeta2D, axis: int, image_size: float, number_of_voxels: int, origin: float = 0) None

Set the dimension properties of image_size, number_of_voxels, and origin for the specified axis.

set_projection_id(self: larcv.pylarcv.ImageMeta2D, id: int) None

Set the projection ID for this ImageMeta.

total_volume(self: larcv.pylarcv.ImageMeta2D) float

Return the total volume of this ImageMeta.

total_voxels(self: larcv.pylarcv.ImageMeta2D) int

Return the total number of voxels in this ImageMeta.

unit(self: larcv.pylarcv.ImageMeta2D) larcv.pylarcv.DistanceUnit_t

Return the unit of this ImageMeta.

voxel_dimensions(*args, **kwargs)

Overloaded function.

  1. voxel_dimensions(self: larcv.pylarcv.ImageMeta2D, axis: int) -> float

Return the voxel dimension along axis.

  1. voxel_dimensions(self: larcv.pylarcv.ImageMeta2D) -> List[float]

Return the voxel dimensions along all axes.