Skip to content

Patching

Source

Patching functions.

PatchedOutput dataclass

Dataclass to store patches and statistics.

image_stats instance-attribute

Statistics of the image patches.

patches instance-attribute

Image patches.

target_stats instance-attribute

Statistics of the target patches.

targets instance-attribute

Target patches.

Stats dataclass

Dataclass to store statistics.

means instance-attribute

Mean of the data across channels.

stds instance-attribute

Standard deviation of the data across channels.

get_statistics()

Return the means and standard deviations.

Returns:

Type Description
tuple of two lists of floats

Means and standard deviations.

prepare_patches_supervised(train_files, target_files, axes, patch_size, read_source_func)

Iterate over data source and create an array of patches and corresponding targets.

The lists of Paths should be pre-sorted.

Parameters:

Name Type Description Default
train_files list of pathlib.Path

List of paths to training data.

required
target_files list of pathlib.Path

List of paths to target data.

required
axes str

Axes of the data.

required
patch_size list or tuple of int

Size of the patches.

required
read_source_func Callable

Function to read the data.

required

Returns:

Type Description
ndarray

Array of patches.

prepare_patches_supervised_array(data, axes, data_target, patch_size)

Iterate over data source and create an array of patches.

This method expects an array of shape SC(Z)YX, where S and C can be singleton dimensions.

Patches returned are of shape SC(Z)YX, where S is now the patches dimension.

Parameters:

Name Type Description Default
data ndarray

Input data array.

required
axes str

Axes of the data.

required
data_target ndarray

Target data array.

required
patch_size list or tuple of int

Size of the patches.

required

Returns:

Type Description
PatchedOutput

Dataclass holding the source and target patches, with their statistics.

prepare_patches_unsupervised(train_files, axes, patch_size, read_source_func)

Iterate over data source and create an array of patches.

This method returns the mean and standard deviation of the image.

Parameters:

Name Type Description Default
train_files list of pathlib.Path

List of paths to training data.

required
axes str

Axes of the data.

required
patch_size list or tuple of int

Size of the patches.

required
read_source_func Callable

Function to read the data.

required

Returns:

Type Description
PatchedOutput

Dataclass holding patches and their statistics.

prepare_patches_unsupervised_array(data, axes, patch_size)

Iterate over data source and create an array of patches.

This method expects an array of shape SC(Z)YX, where S and C can be singleton dimensions.

Patches returned are of shape SC(Z)YX, where S is now the patches dimension.

Parameters:

Name Type Description Default
data ndarray

Input data array.

required
axes str

Axes of the data.

required
patch_size list or tuple of int

Size of the patches.

required

Returns:

Type Description
PatchedOutput

Dataclass holding the patches and their statistics.