utils

Image

class airlab.utils.image.Displacement(*args, **kwargs)[source]
itk()[source]

Returns a SimpleITK image

Note: the order of axis is flipped back to the convention of SimpleITK

magnitude()[source]
numpy()[source]

Returns a numpy array

static read(filename, dtype=torch.float32, device='cpu')[source]

Static method to directly read a displacement field through the Image class

filename (str): filename of the displacement field dtype: specific dtype for representing the tensor device: on which device the displacement field has to be allocated return (Displacement): an airlab displacement field

class airlab.utils.image.Image(*args, **kwargs)[source]

Class representing an image in airlab

initializeForImages(sitk_image, dtype=None, device='cpu')[source]

Constructor for SimpleITK image

Note: the order of axis are flipped in order to follow the convention of numpy and torch

sitk_image (sitk.SimpleITK.Image): SimpleITK image dtype: pixel type device (‘cpu’|’cuda’): on which device the image should be allocated return (Image): an airlab image object

initializeForTensors(tensor_image, image_size, image_spacing, image_origin)[source]

Constructor for torch tensors and numpy ndarrays

Args: tensor_image (np.ndarray | th.Tensor): n-dimensional tensor, where the last dimensions are the image dimensions while the preceeding dimensions need to empty image_size (array | list | tuple): number of pixels in each space dimension image_spacing (array | list | tuple): pixel size for each space dimension image_origin (array | list | tuple): physical coordinate of the first pixel :return (Image): an airlab image object

itk()[source]

Returns a SimpleITK image

Note: the order of axis is flipped back to the convention of SimpleITK

numpy()[source]

Returns a numpy array

static read(filename, dtype=torch.float32, device='cpu')[source]

Static method to directly read an image through the Image class

filename (str): filename of the image dtype: specific dtype for representing the tensor device: on which device the image has to be allocated return (Image): an airlab image

to(dtype=None, device='cpu')[source]

Converts the image tensor to a specified dtype and moves it to the specified device

write(filename)[source]

Write an image to hard drive

Note: order of axis are flipped to have the representation of SimpleITK again

filename (str): filename where the image is written

airlab.utils.image.create_displacement_image_from_image(tensor_displacement, image)[source]
airlab.utils.image.create_image_from_image(tensor_image, image)[source]
airlab.utils.image.create_image_pyramid(image, down_sample_factor)[source]
airlab.utils.image.create_tensor_image_from_itk_image(itk_image, dtype=torch.float32, device='cpu')[source]
airlab.utils.image.flip(x, dim)[source]

Flip order of a specific dimension dim

x (Tensor): input tensor dim (int): axis which should be flipped return (Tensor): returns the tensor with the specified axis flipped

airlab.utils.image.image_from_numpy(image, pixel_spacing, image_origin, dtype=torch.float32, device='cpu')[source]
airlab.utils.image.read_image_as_tensor(filename, dtype=torch.float32, device='cpu')[source]

Kernel Function

airlab.utils.kernelFunction.bspline_kernel(sigma, order=2, dim=1, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.bspline_kernel_1d(sigma, order=2, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.bspline_kernel_2d(sigma=[1, 1], order=2, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.bspline_kernel_3d(sigma=[1, 1, 1], order=2, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.gaussian_kernel(sigma, dim=1, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.gaussian_kernel_1d(sigma, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.gaussian_kernel_2d(sigma, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.gaussian_kernel_3d(sigma, asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.wendland_kernel(sigma, dim=1, type='C4', asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.wendland_kernel_1d(sigma, type='C4', asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.wendland_kernel_2d(sigma, type='C4', asTensor=False, dtype=torch.float32, device='cpu')[source]
airlab.utils.kernelFunction.wendland_kernel_3d(sigma, type='C4', asTensor=False, dtype=torch.float32, device='cpu')[source]

Graph

class airlab.utils.graph.Graph(graph_size, dtype=torch.float32, device='cpu')[source]

Matrix

class airlab.utils.matrix.LaplaceMatrix(number_of_nodes, diag_elements, dtype=torch.float32, device='cpu')[source]
full()[source]
update()[source]
class airlab.utils.matrix.MatrixDiagonalElement(edge_index, edge_values, offset, dtype=torch.float32, device='cpu')[source]
airlab.utils.matrix.band_mv(A, x)[source]
airlab.utils.matrix.expm_eig(A)[source]
airlab.utils.matrix.expm_krylov(A, x, phi=1, krylov_dim=30, inplace=True)[source]