Skip to content

cornucopia.fov

This module contains transforms that operate on the field of view (FOV) of the image.

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 spatial axes.

None

RandomFlipTransform

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

Bases: NonFinalTransform

Randomly flip one or more axes.

Parameters:

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

Axes that can be flipped (default: all spatial axes)

None

Other Parameters:

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

Apply the same flip to all channels and/or tensors

Final class-attribute instance-attribute

Final = FlipTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = FlipTransform

The transform type returned by make_final.

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

Final class-attribute instance-attribute

Final = PermuteAxesTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = PermuteAxesTransform

The transform type returned by make_final.

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 [list of] int

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

0
negative [list of] bool

Rotate by -90 deg instead of 90 deg

False
double [list of] 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 [list of] 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 [list of] int

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

None
max_rot Sampler | int

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

Final class-attribute instance-attribute

Final = Rot90Transform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = Rot90Transform

The transform type returned by make_final.

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 [list of]str

Boundary condition in case padding is needed

'zero'

Other Parameters:

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

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = CropPadTransform

The transform type returned by make_final.

RandomPatchTransform

RandomPatchTransform(patch_size, bound='zero', *, shared='channels', **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
patch_size [list of] int

Patch shape

required
bound [list of] str

Boundary condition in case padding is needed

'zero'

Other Parameters:

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

Extract the same patch from all channels and/or tensors

Next class-attribute instance-attribute

Next = PatchTransform

The transform type returned by make_final(..., max_depth=1).

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by make_final(..., max_depth=inf).

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

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by make_final.

Next class-attribute instance-attribute

Next = CropPadTransform

The transform type returned by make_final.

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'

Next class-attribute instance-attribute

Next = PatchTransform

The transform type returned by make_final(..., max_depth=1).

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by make_final(..., max_depth=inf).