Skip to content

Validators

Source

Validator utilities.

check_axes_validity(axes)

Sanity check on axes.

The constraints on the axes are the following: - must be a combination of 'STCZYX' - must not contain duplicates - must contain at least 2 contiguous axes: X and Y

Axes do not need to be in the order 'STCZYX', as this depends on the user data.

Parameters:

Name Type Description Default
axes str

Axes to validate.

required

check_czi_axes_validity(axes)

Check if the provided axes string is valid for CZI files.

CZI axes is always in the "SC(Z/T)YX" format, where Z or T are optional, and S and C can be singleton dimensions, but must be provided.

Parameters:

Name Type Description Default
axes str

The axes string to validate.

required

Returns:

Type Description
bool

True if the axes string is valid, False otherwise.

model_matching_in_out_channels(model)

Validate that the UNet model has the same number of channel inputs and outputs.

Parameters:

Name Type Description Default
model UNetModel

Model to validate.

required

Returns:

Type Description
UNetModel

Validated model.

Raises:

Type Description
ValueError

If the model has different number of input and output channels.

model_without_final_activation(model)

Validate that the UNet model does not have the final_activation.

Parameters:

Name Type Description Default
model UNetModel

Model to validate.

required

Returns:

Type Description
UNetModel

The validated model.

Raises:

Type Description
ValueError

If the model has the final_activation attribute set.

model_without_n2v2(model)

Validate that the Unet model does not have the n2v2 attribute.

Parameters:

Name Type Description Default
model UNetModel

Model to validate.

required

Returns:

Type Description
UNetModel

The validated model.

Raises:

Type Description
ValueError

If the model has the n2v2 attribute set to True.

patch_size_ge_than_8_power_of_2(patch_list)

Validate that each entry is greater or equal than 8 and a power of 2.

Parameters:

Name Type Description Default
patch_list Sequence of int, or None

Patch size.

required

Raises:

Type Description
ValueError

If the patch size if smaller than 8.

ValueError

If the patch size is not a power of 2.