skshapes.Mask
- class skshapes.Mask(*, indices=None, flat_indices=None, shape, device=None)
Bases:
GridStructureA D-dimensional mask over a voxel grid.
A
Maskobject can be created from torch.Tensors indicating indices of the voxels contained in the mask. The shape of the mask must also be provided.Masks are manipulated like sets of voxels. They are also used to select only a subset of the values of an image.
- Parameters:
indices (
Int64[Tensor, '*_']|None) – The indices of the voxels that are included in the mask. It should be a tensor of shape(N,D)whereNis the number of voxels present in the mask.shape (
tuple[int,...]) – The shape of the original grid on which the mask is defined.device (
str|device|None) – The device on which the shape is stored (e.g."cpu"or"cuda"). If None it is inferred from the input.
- __init__(*, indices=None, flat_indices=None, shape, device=None)
Methods
__init__(*[, indices, flat_indices, device])connected_components(*, offsets)convolution(*, offsets[, kernel])copy()difference(other)intersection(other)masked_convolution(*[, mask, weights, ...])plot([backend])symmetric_difference(other)to(device)Copy the instance onto a given device.
to_image(*[, dtype, device])to_sparseimage(*[, dtype, device])union(other)Attributes
deviceDevice getter.
dimThe dimension D of the D-dimensional grid.
The indices of the voxels that are included in the mask, expressed as a tensor.
The number of voxels present in the mask.
numelThe total number of voxels in the image.
shapeThe shape of the D-dimensional grid.
The mask expressed as a tensor.
- property indices: Tensor
The indices of the voxels that are included in the mask, expressed as a tensor.
- property n_points: int
The number of voxels present in the mask.
- property values: Tensor
The mask expressed as a tensor.