zea.data.augmentations¶
Augmentation layers for ultrasound data.
Classes
|
Adds a circular inclusion to the image, optionally at random locations. |
- class zea.data.augmentations.RandomCircleInclusion(radius, fill_value=1.0, circle_axes=(1, 2), with_batch_dim=True, return_centers=False, recovery_threshold=0.1, randomize_location_across_batch=True, seed=None, **kwargs)[source]¶
Bases:
Layer
Adds a circular inclusion to the image, optionally at random locations.
Since this can accept N-dimensional inputs, you’ll need to specify your
circle_axes
– these are the axes onto which a circle will be drawn. This circle will then be broadcast along the remaining dimensions.You can then optionally specify whether there is a batch dim, and whether the circles should be located randomly across that batch.
For example, if you have a batch of videos, e.g. of shape [batch, frame, height, width], then you might want to specify
circle_axes=(2, 3)
, andrandomize_location_across_batch=True
. This would result in a circle that is located in the same place per video, but different locations for different videos.Once your method has recovered the circles, you can evaluate them using the
evaluate_recovered_circle_accuracy()
method, which will expect an input shape matching your inputs tocall()
.- build(input_shape)[source]¶
Build the layer and compute static shape and permutation info.
- Parameters:
input_shape (tuple) – Shape of the input tensor.
- call(x, seed=None)[source]¶
Apply the random circle inclusion augmentation.
- Parameters:
x (Tensor) – Input tensor.
seed (Any, optional) – Optional random seed for reproducibility.
- Returns:
- Augmented images, and optionally the circle
centers if return_centers is True.
- Return type:
Tensor or tuple
- compute_output_shape(input_shape)[source]¶
Compute output shape for the layer.
- Parameters:
input_shape (tuple) – Shape of the input tensor.
- Returns:
The output shape (same as input).
- Return type:
tuple
- evaluate_recovered_circle_accuracy(images, centers, recovery_threshold, fill_value=None)[source]¶
Evaluate the percentage of the true circle that has been recovered in the images.
- Parameters:
images (Tensor) – Tensor of images (any shape, with circle axes as specified).
centers (Tensor) – Tensor of circle centers (matching batch size).
recovery_threshold (float) – Threshold for considering a pixel as recovered.
fill_value (float, optional) – Optionally override fill_value for cases where image range has changed.
- Returns:
Percentage recovered for each circle (shape: [num_circles]).
- Return type:
Tensor