imfusion.data#
Submodule for Data and Data-derived types.
- class imfusion.data.Data#
Bases:
pybind11_object- class Kind(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum- IMAGE = 1#
- IMAGE_SET = 3#
- IMAGE_STREAM = 5#
- POINT_SET = 7#
- STEREOIMAGESET = 14#
- SURFACE = 8#
- TRACKING_DATA = 10#
- TRACKING_STREAM = 9#
- UNKNOWN = 0#
- VOLUME = 2#
- VOLUME_SET = 4#
- VOLUME_STREAM = 6#
- class Modality(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum- CT = 2#
- LABEL = 8#
- MRI = 3#
- NA = 0#
- NM = 6#
- OCT = 7#
- ULTRASOUND = 4#
- VIDEO = 5#
- XRAY = 1#
- set_matrix_from_world(self: Data, arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) None#
- set_matrix_to_world(self: Data, arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) None#
- property components#
- Type:
- class imfusion.data.Mesh(*args, **kwargs)#
Bases:
DataFunction overload documentation:
- class Primitive(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
EnumEnumeration of supported mesh primitives.
- CONE = 5#
- CUBE = 3#
- CYLINDER = 1#
- GRID = 6#
- ICOSAHEDRON_SPHERE = 4#
- PYRAMID = 2#
- SPHERE = 0#
- add_face(self: Mesh, index: Annotated[numpy.typing.ArrayLike, numpy.int32, '[3, 1]'], force: bool) int#
- static create(shape: Primitive) Mesh#
Create a mesh primitive.
- Args:
shape: The shape of the primitive to create.
- face_normal(self: Mesh, index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
- face_vertices(self: Mesh, index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.int32], '[3, 1]']#
- halfedge_color(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']#
- halfedge_normal(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
- halfedge_vertices(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.int32], '[2, 1]']#
- is_vertex_manifold(self: Mesh, index: SupportsInt | SupportsIndex) bool#
- remove_face(self: Mesh, index: SupportsInt | SupportsIndex, remove_isolated_vertices: bool) bool#
- remove_faces(self: Mesh, indices: Sequence[SupportsInt | SupportsIndex], remove_isolated_vertices: bool) None#
- remove_vertices(self: Mesh, indices: Sequence[SupportsInt | SupportsIndex], remove_isolated_vertices: bool) None#
- set_halfedge_color(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) None#
- set_halfedge_color(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]'], alpha: SupportsFloat | SupportsIndex) None
Function overload documentation:
- set_halfedge_color(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) None
- set_halfedge_color(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]'], alpha: SupportsFloat | SupportsIndex) None
- set_halfedge_normal(self: Mesh, vertex_index: SupportsInt | SupportsIndex, face_index: SupportsInt | SupportsIndex, normal: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) None#
- set_vertex(self: Mesh, index: SupportsInt | SupportsIndex, vertex: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) None#
- set_vertex_color(self: Mesh, index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) None#
- set_vertex_color(self: Mesh, index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]'], alpha: SupportsFloat | SupportsIndex) None
Function overload documentation:
- set_vertex_color(self: Mesh, index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[4, 1]']) None
- set_vertex_color(self: Mesh, index: SupportsInt | SupportsIndex, color: Annotated[numpy.typing.ArrayLike, numpy.float32, '[3, 1]'], alpha: SupportsFloat | SupportsIndex) None
- set_vertex_normal(self: Mesh, index: SupportsInt | SupportsIndex, normal: Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']) None#
- vertex(self: Mesh, index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
- vertex_color(self: Mesh, index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float32], '[4, 1]']#
- vertex_normal(self: Mesh, index: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float64], '[3, 1]']#
- class imfusion.data.PointCloud(self: PointCloud, points: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']] = [], *, normals: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']] = [], colors: Sequence[Annotated[numpy.typing.ArrayLike, numpy.float64, '[3, 1]']] = [])#
Bases:
DataData structure representing a point cloud in 3d space. Each point can have an associated color and normal vector.
Constructs a point cloud with the specified points, normals and colors. If the number of colors / normals does not match the number of points, they will be ignored with a warning.
- Parameters:
points – Vertices of the point cloud.
normals – Normals of the point cloud. If the length does not match
points,normalswill be dropped with a warning.colors – Colors (RGB) of the point cloud. If the length does not match
points,colorswill be dropped with a warning.
- clone(self: PointCloud) PointCloud#
Create a new point cloud by deep copying an all data from this instance.
- transform_point_cloud(self: PointCloud, transformation: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) None#
Bases:
DataSet of images independent of their storage location.
This class is the main high-level container for image data consisting of one or multiple images or volumes, and should be used both in algorithms and visualization classes. Both a single focus and multiple selection is featured, as well as providing transformation matrices for each image.
The focus image of a
SharedImageSetcan be directly converted from and to a numpy array:>>> img = imfusion.SharedImageSet(np.ones([1, 10, 10, 10, 1], dtype='uint8')) >>> arr = np.array(img)
See
MemImagefor details.Function overload documentation:
- __init__(self: SharedImageSet) None
Creates an empty SharedImageSet.
- __init__(self: SharedImageSet, mem_image: MemImage) None
- __init__(self: SharedImageSet, shared_image: SharedImage) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.int8], greyscale: bool = False) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.uint8], greyscale: bool = False) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.int16], greyscale: bool = False) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.uint16], greyscale: bool = False) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.int32], greyscale: bool = False) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.uint32], greyscale: bool = False) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.float32], greyscale: bool = False) None
- __init__(self: SharedImageSet, array: Annotated[numpy.typing.ArrayLike, numpy.float64], greyscale: bool = False) None
- add(self: SharedImageSet, mem_image: MemImage) None
Function overload documentation:
- add(self: SharedImageSet, shared_image: SharedImage) None
- add(self: SharedImageSet, mem_image: MemImage) None
Returns True if all pixels / voxels is non-zero
Returns True if at least one pixel / voxel is non-zero
Return a copy of the array with storage values converted to original values.
- Parameters:
self – instance of a SharedImageSet which provides shift and scale
arr – array to be converted from storage values into original values
- Returns:
numpy.ndarray
Return a list of the indices of maximum values, channel-wise. The indices are represented as (x, y, z, image index).
- Returns:
List of indices (x, y, z, image index) returned as a list of numpy arrays.
Return a list of the indices of minimum values, channel-wise. The indices are represented as (x, y, z, image index).
- Returns:
List of indices (x, y, z, image index) returned as a list of numpy arrays.
Copies the contents of arr to the MemImage. Automatically calls setDirtyMem.
Returns a new SharedImageSet formed by new SharedImage instances obtained by converting the original ones into the requested PixelType.
This function accepts either: - a PixelType (e.g. imfusion.PixelType.UInt); - most of the numpy’s dtypes (e.g. np.uint); - python’s float or int types.
If the requested type already matches the input type, the returned SharedImageSet will contain clones of the original images.
Reorders the channels of an image based on the input indices, e.g.
indices[0]will correspond to the first channel of the output image.- Parameters:
indices – List of channel indices to swizzle the channels of the input.
- Returns:
SharedImageSetinstance with reordered channels.
Return a read-only descriptor view for a specific or selected image.
- static from_images(path: Sequence[str]) SharedImageSet
Function overload documentation:
- from_images(path: str) SharedImageSet
Load different images as a single
SharedImageSet.Currently supported image formats are: [bmp, pgm, png, ppm, jpg, jpeg, tif, tiff, jp2].
- Parameters:
folder_path – The directory where all images are located to be loaded as a
SharedImageSet.- Raises:
IOError if the file cannot be opened or if the extensions is not supported. –
- from_images(path: Sequence[str]) SharedImageSet
Load different images as a single
SharedImageSet.Currently supported image formats are: [bmp, pgm, png, ppm, jpg, jpeg, tif, tiff, jp2].
- Parameters:
file_paths – paths to image files to be loaded as a
SharedImageSet.- Raises:
IOError if the file cannot be opened or if the extensions is not supported. –
Create a SharedImageSet from a torch Tensor. If you want to copy metadata from an existing SharedImageSet you can pass it as the
get_metadata_fromargument. If you are using this, make sure that the size of the tensor’s batch dimension and the number of images in the SIS are equal. Ifget_metadata_fromis provided,propertieswill be copied from the SIS andworld_to_image_matrix,spacingandmodalityfrom the contained SharedImages.- Parameters:
cls – Instance of type i.e. SharedImageSet (this function is bound as a classmethod to SharedImageSet)
tensor (Tensor) – Instance of torch.Tensor
get_metadata_from (SharedImageSet | None) – Instance of SharedImageSet from which metadata should be copied.
- Returns:
New instance of SharedImageSet
- Return type:
Return the list of the maximum elements of images, channel-wise.
- Returns:
Channel-wise values returned as a numpy array.
Return a list of channel-wise average of image elements.
- Returns:
Channel-wise values returned as a numpy array.
Return the list of the minimum elements of images, channel-wise.
- Returns:
Channel-wise values returned as a numpy array.
Returns the norm of an image instance, channel-wise.
- Parameters:
order – Order of the norm. Use a number (e.g., 1 or 2) or ‘inf’. The default is the L2 norm.
- Returns:
Norm values per channel returned as a numpy array.
Convenience method for reading a SharedImageSet as original values, with shift and scale already applied.
- Parameters:
self – instance of a SharedImageSet
- Returns:
numpy.ndarray
Return a list of channel-wise production of image elements.
- Returns:
Channel-wise values returned as a numpy array.
Removes and deletes the SharedImage from the set.
Return a list of channel-wise sum of image elements.
- Returns:
Channel-wise values returned as a numpy array.
Convert SharedImageSet or a SharedImage to a torch.Tensor.
- Parameters:
self (DataElement | SharedImageSet | SharedImage) – Instance of SharedImageSet or SharedImage (this function bound as a method to SharedImageSet and SharedImage)
device (device) – Target device for the new torch.Tensor
dtype (dtype) – Type of the new torch.Tensor
same_as (Tensor) – Template tensor whose device and dtype configuration should be matched.
deviceanddtypeare still applied afterwards.
- Returns:
New torch.Tensor
- Return type:
- Type:
- Type:
- Type:
- Type:
- Type:
- Type:
Return a numpy compatible shape descripting the dimensions of this image.
The returned tuple has 5 entries: #frames, slices, height, width, channels
- Type:
Bases:
SharedImageSetSet of images with arbitrarily sampled tracking data.
Replaces per-image matrices of
SharedImageSetfromTrackingSequenceinstances.Construct from an existing
SharedImageSet(cloned, original stays valid) and aTrackingSequence, copy anotherTrackedSharedImageSet(including trackings), or build an empty set and calladd()/add_tracking().Function overload documentation:
- __init__(self: TrackedSharedImageSet) None
Creates an empty TrackedSharedImageSet.
- __init__(self: TrackedSharedImageSet, tracked_shared_image_set: TrackedSharedImageSet) None
Creates a deep copy of
tracked_shared_image_set, including images and tracking sequences. The original set is left unchanged.
- __init__(self: TrackedSharedImageSet, shared_image_set: SharedImageSet, tracking_sequence: TrackingSequence) None
Creates a TrackedSharedImageSet by cloning
shared_image_set(images, timestamps, properties, and name) and attaching a copy oftracking_sequence. The original set is left unchanged.For a full copy of an existing
TrackedSharedImageSet(including trackings), use the single-argument copy constructor instead.
Attaches a copy of
tracking_sequenceto this set.
Swaps all images, timestamps, properties, and the name with
image_set. After the call, this TrackedSharedImageSet holds the former contents ofimage_set, andimage_setholds the former contents of this set (typically empty if this set was empty). Does not create or modify tracking sequences. Prefer the constructor when you need a non-destructive copy.
- Type:
- Type:
- Type:
- Type:
List of tracking sequences owned by this set (references, not copies).
- Type:
- Type:
- Type:
- class imfusion.data.TrackingSequence(self: TrackingSequence, name: str = '')#
Bases:
Data- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) None#
- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], timestamp: SupportsFloat | SupportsIndex) None
- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], timestamp: SupportsFloat | SupportsIndex, quality: SupportsFloat | SupportsIndex) None
- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], timestamp: SupportsFloat | SupportsIndex, quality: SupportsFloat | SupportsIndex, flags: SupportsInt | SupportsIndex) None
Function overload documentation:
- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) None
- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], timestamp: SupportsFloat | SupportsIndex) None
- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], timestamp: SupportsFloat | SupportsIndex, quality: SupportsFloat | SupportsIndex) None
- add(self: TrackingSequence, mat: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]'], timestamp: SupportsFloat | SupportsIndex, quality: SupportsFloat | SupportsIndex, flags: SupportsInt | SupportsIndex) None
- clear(self: TrackingSequence) None#
- flags(self: TrackingSequence, num: SupportsInt | SupportsIndex = -1) int#
- matrix(self: TrackingSequence, num_or_time: SupportsInt | SupportsIndex | SupportsFloat | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']#
- quality(self: TrackingSequence, num: SupportsInt | SupportsIndex) float#
- quality(self: TrackingSequence, time: SupportsFloat | SupportsIndex, check_distance: bool = True, ignore_relative: bool = False) float
Function overload documentation:
- quality(self: TrackingSequence, num: SupportsInt | SupportsIndex) float
- quality(self: TrackingSequence, time: SupportsFloat | SupportsIndex, check_distance: bool = True, ignore_relative: bool = False) float
- raw_matrix(self: TrackingSequence, num: SupportsInt | SupportsIndex) Annotated[numpy.typing.NDArray[numpy.float64], '[4, 4]']#
- remove(self: TrackingSequence, pos: SupportsInt | SupportsIndex, count: SupportsInt | SupportsIndex = 1) None#
- set_raw_matrix(self: TrackingSequence, idx: SupportsInt | SupportsIndex, value: Annotated[numpy.typing.ArrayLike, numpy.float64, '[4, 4]']) None#
- set_timestamp(self: TrackingSequence, idx: SupportsInt | SupportsIndex, value: SupportsFloat | SupportsIndex) None#
- shift_timestamps(self: TrackingSequence, shift: SupportsFloat | SupportsIndex) None#
- timestamp(self: TrackingSequence, num: SupportsInt | SupportsIndex = -1) float#
- property relative_tracking#
- Type: