Skip to content

cornucopia.fov

FlipTransform

FlipTransform(axis=None, **kwargs)

Bases: FinalTransform

Flip one or more axes

Parameters:

Name Type Description Default
axis [list of] int

Axes to flip. By default, flip all axes.

None

RandomFlipTransform

RandomFlipTransform(axes=None, *, shared=True, **kwargs)

Bases: NonFinalTransform

Randomly flip one or more axes

Parameters:

Name Type Description Default
axes Sampler or [list of] int

Axes that can be flipped (default: all)

None

Other Parameters:

Name Type Description
shared (channels, tensors, channels + tensors, '')

Apply the same flip to all channels and/or tensors

PermuteAxesTransform

PermuteAxesTransform(permutation=None, **kwargs)

Bases: FinalTransform

Permute axes

Parameters:

Name Type Description Default
permutation [list of] int

Axes permutation. By default, reverse axes. Only applies to spatial axes, so axes are numbered [C, 0, 1, 2]

None

RandomPermuteAxesTransform

RandomPermuteAxesTransform(axes=None, *, shared=True, **kwargs)

Bases: NonFinalTransform

Randomly permute axes

Parameters:

Name Type Description Default
axes [list of] int

Axes that can be permuted (default: all)

None

Other Parameters:

Name Type Description
shared (channels, tensors, channels + tensors, '')

Apply the same permutation to all channels and/or tensors

Rot90Transform

Rot90Transform(axis=0, negative=False, double=False, **kwargs)

Bases: FinalTransform

Apply a 90 (or 180) rotation along one or several axes

Parameters:

Name Type Description Default
axis int or list[int]

Rotation axis (indexing does not account for the channel axis)

0
negative bool or list[bool]

Rotate by -90 deg instead of 90 deg

False
double bool or list[bool]

Rotate be 180 instead of 90 (negative is then unused)

False

Rot180Transform

Rot180Transform(axis=0, **kwargs)

Bases: Rot90Transform

Apply a 180 deg rotation along one or several axes

Parameters:

Name Type Description Default
axis int or list[int]

Rotation axis (indexing does not account for the channel axis)

0

RandomRot90Transform

RandomRot90Transform(axes=None, max_rot=2, negative=True, *, shared=True, **kwargs)

Bases: NonFinalTransform

Random set of 90 transforms

Parameters:

Name Type Description Default
axes int or list[int]

Axes along which rotations can happen. If None, all axes.

None
max_rot int or Sampler

Maximum number of consecutive rotations.

2
negative bool

Whether to authorize negative rotations.

True

Other Parameters:

Name Type Description
shared (channels, tensors, channels + tensors, '')

Apply the same permutation to all channels and/or tensors

CropPadTransform

CropPadTransform(crop, pad, bound='zero', value=0, **kwargs)

Bases: FinalTransform

Crop and/or pad a tensor

Parameters:

Name Type Description Default
crop list[slice]

Slicing operator per dimension.

required
pad list[int]

Left and right padding per dimensions

required
bound [list of] str

Boundary condition for padding

'zero'
value number

Padding value in case bound='constant

0

PatchTransform

PatchTransform(shape=64, center=0, bound='zero', *, shared='channels', **kwargs)

Bases: NonFinalTransform

Extract a patch from the volume

Parameters:

Name Type Description Default
shape [list of] int

Patch shape

64
center [list of] float

Patch center, in relative coordinates -1..1

0
bound str

Boundary condition in case padding is needed

'zero'

Other Parameters:

Name Type Description
shared (channels, tensors, channels + tensor, '')

RandomPatchTransform

RandomPatchTransform(patch_size, bound='zero', *, shared=True, **kwargs)

Bases: NonFinalTransform

Extract a (randomly located) patch from the volume.

This transform ensures that the patch is fully contained within the original field of view (unless the patch size is larger than the input shape).

Parameters:

Name Type Description Default
shape [list of] int

Patch shape

required
bound str

Boundary condition in case padding is needed

'zero'

Other Parameters:

Name Type Description
shared (channels, tensors, channels + tensors, None)

Extract the same patch from all channels and/or tensors

CropTransform

CropTransform(cropping, unit='vox', side='both', **kwargs)

Bases: NonFinalTransform

Crop a tensor by some amount

Parameters:

Name Type Description Default
cropping [list of] int or float

Amount of cropping. If side is None, pre and post cropping must be provided in turn.

required
unit (vox, pct)

Padding unit

'vox'
side (pre, post, both, None)

Side to crop

'pre'

PadTransform

PadTransform(padding, unit='vox', side='both', bound='zero', value=0, **kwargs)

Bases: NonFinalTransform

Pad a tensor by some amount

Parameters:

Name Type Description Default
padding [list of] int or float

Amount of padding. If side is None, pre and post padding must be provided in turn.

required
unit (vox, pct)

Padding unit

'vox'
side (pre, post, both, None)

Side to pad

'pre'
bound str

Boundary condition

'zero'
value float

Value for case bound='constant'

0

PowerTwoTransform

PowerTwoTransform(exponent=1, bound='zero', **kwargs)

Bases: NonFinalTransform

Pad the volume such that the tensor shape can be divided by 2**x

Parameters:

Name Type Description Default
exponent [list of] int

Ensure that the shape can be divided by 2 ** exponent

1
bound [list of] str

Boundary condition for padding

'zero'