aidsorb.transforms.voxels#

Helper functions and classes for transforming voxels.

Note

All geometric transforms expect an input Tensor of shape (C, D, H, W).

class aidsorb.transforms.voxels.AddChannelDim[source]#

Bases: object

Prepend a dimension to the input tensor.

Examples

>>> x = torch.randn(32, 32, 32)
>>> AddChannelDim()(x).shape
torch.Size([1, 32, 32, 32])
class aidsorb.transforms.voxels.BoltzmannFactor(temperature=298.0)[source]#

Bases: object

Fill voxels with the Boltzmann factor.

Parameters:

temperature (float)

Examples

>>> x = torch.tensor([0., torch.inf])
>>> BoltzmannFactor()(x)
tensor([1., 0.])
class aidsorb.transforms.voxels.ClipScaleVoxels(value=5000.0)[source]#

Bases: object

Clip and then normalize voxels within [-1, 1].

First clips voxels within [-value, value], then divides the result by value, producing voxels with values in [-1, 1].

Parameters:

value (float)

Examples

>>> x = torch.tensor([-12., 11.])
>>> ClipScaleVoxels(10)(x)
tensor([-1.,  1.])
class aidsorb.transforms.voxels.ClipVoxels(vmin, vmax)[source]#

Bases: object

Clip voxels within [vmin, vmax].

Parameters:

Examples

>>> x = torch.tensor([-20., 22.])
>>> out = ClipVoxels(-1, 1)(x)
>>> out
tensor([-1.,  1.])
class aidsorb.transforms.voxels.RandomFlip[source]#

Bases: object

Flip voxels along a randomly chosen axis.

Examples

>>> x = torch.randn(2, 3, 3, 3)
>>> out = RandomFlip()(x)
>>> out.shape
torch.Size([2, 3, 3, 3])
>>> torch.equal(x, out)
False
class aidsorb.transforms.voxels.RandomNoise(std)[source]#

Bases: object

Add normal noise to voxels.

Parameters:

std (float) – Standard deviation of the normal noise.

Examples

>>> x = torch.randn(3, 3)
>>> out = RandomNoise(0.1)(x)
>>> out.shape
torch.Size([3, 3])
>>> torch.equal(x, out)
False
class aidsorb.transforms.voxels.RandomReflect[source]#

Bases: object

Reflect voxels along a randomly chosen plane.

Examples

>>> x = torch.randn(2, 3, 3, 3)
>>> out = RandomReflect()(x)
>>> out.shape
torch.Size([2, 3, 3, 3])
>>> torch.equal(x, out)
False
class aidsorb.transforms.voxels.RandomRotation90[source]#

Bases: object

Rotate voxels around a randomly chosen axis by 90 degrees.

Examples

>>> x = torch.randn(2, 3, 3, 3)
>>> out = RandomRotation90()(x)
>>> out.shape
torch.Size([2, 3, 3, 3])
>>> torch.equal(x, out)
False