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

Other Parameters:

Name Type Description
returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

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 bool

See NonFinalTransform for details.

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

Final class-attribute instance-attribute

Final = FlipTransform

The transform type returned by unroll, next and final.

Next class-attribute instance-attribute

Next = FlipTransform

The transform type returned by unroll, next and 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

Other Parameters:

Name Type Description
returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

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 bool

See NonFinalTransform for details.

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

Final class-attribute instance-attribute

Final = PermuteAxesTransform

The transform type returned by unroll, next and final.

Next class-attribute instance-attribute

Next = PermuteAxesTransform

The transform type returned by unroll, next and 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

Other Parameters:

Name Type Description
returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

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

Other Parameters:

Name Type Description
returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

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 SharedT

See NonFinalTransform for details.

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

Final class-attribute instance-attribute

Final = Rot90Transform

The transform type returned by unroll, next and final.

Next class-attribute instance-attribute

Next = Rot90Transform

The transform type returned by unroll, next and 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.

()
pad list[int]

Left and right padding per dimensions

()
bound [list of] str

Boundary condition for padding

'zero'
value number

Padding value in case bound='constant

0

Other Parameters:

Name Type Description
returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

PatchTransform

PatchTransform(shape=64, center=0, bound='zero', *, shared=True, **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 SharedT

See NonFinalTransform for details.

v0.5 Default for shared changed from "channels" to True

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by unroll, next and final.

Next class-attribute instance-attribute

Next = CropPadTransform

The transform type returned by unroll, next and final.

RandomPatchTransform

RandomPatchTransform(shape, 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 [list of] str

Boundary condition in case padding is needed

'zero'

Other Parameters:

Name Type Description
shared SharedT

See NonFinalTransform for details.

v0.5 Default for shared changed from "channels" to True

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

Next class-attribute instance-attribute

Next = PatchTransform

The transform type returned by next.

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by final.

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'

Other Parameters:

Name Type Description
shared

See NonFinalTransform for details.

v0.5 Default for shared changed from "channels" to True

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

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

Other Parameters:

Name Type Description
shared

See NonFinalTransform for details.

v0.5 Default for shared changed from "channels" to True

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by unroll, next and final.

Next class-attribute instance-attribute

Next = CropPadTransform

The transform type returned by unroll, next and 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'

Other Parameters:

Name Type Description
shared

See NonFinalTransform for details.

v0.5 Default for shared changed from "channels" to True

returns

See Transform for details.

append

See Transform for details.

prefix

See Transform for details.

include

See Transform for details.

exclude

See Transform for details.

consume

See Transform for details.

Next class-attribute instance-attribute

Next = PatchTransform

The transform type returned by next.

Final class-attribute instance-attribute

Final = CropPadTransform

The transform type returned by final.