Prediction Utils
Package to house various prediction utilies.
convert_outputs(predictions, tiled)
Convert the Lightning trainer outputs to the desired form.
This method allows stitching back together tiled predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
list
|
Predictions that are output from |
required |
tiled
|
bool
|
Whether the predictions are tiled. |
required |
Returns:
| Type | Description |
|---|---|
list of numpy.ndarray or numpy.ndarray
|
list of arrays with the axes SC(Z)YX. If there is only 1 output it will not be in a list. |
convert_outputs_microsplit(predictions, dataset)
Convert microsplit Lightning trainer outputs using eval_utils stitching functions.
This function processes microsplit predictions that return (tile_prediction, tile_std) tuples and stitches them back together using the same logic as get_single_file_mmse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
list of tuple[NDArray, NDArray]
|
Predictions from Lightning trainer for microsplit. Each element is a tuple of (tile_prediction, tile_std) where both are numpy arrays from predict_step. |
required |
dataset
|
Dataset
|
The dataset object used for prediction, needed for stitching function selection and stitching process. |
required |
Returns:
| Type | Description |
|---|---|
tuple[NDArray, NDArray]
|
A tuple of (stitched_predictions, stitched_stds) representing the full stitched predictions and standard deviations. |
convert_outputs_pn2v(predictions, tiled)
Convert the Lightning trainer outputs to the desired form.
This method allows stitching back together tiled predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
list
|
Predictions that are output from |
required |
tiled
|
bool
|
Whether the predictions are tiled. |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[NDArray], list[NDArray]]
|
Tuple of (predictions, mmse) where each is a list of arrays with axes SC(Z)YX. |
stitch_prediction_single(tiles, tile_infos)
Stitch tiles back together to form a full image.
Tiles are of dimensions SC(Z)YX, where C is the number of channels and can be a singleton dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tiles
|
list of numpy.ndarray
|
Cropped tiles and their respective stitching coordinates. |
required |
tile_infos
|
list of TileInformation
|
List of information and coordinates obtained from
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Full image, with dimensions SC(Z)YX. |
stitch_prediction_vae(predictions, dset)
Stitch predictions back together using dataset's index manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
ndarray
|
Array of predictions with shape (n_tiles, channels, height, width). |
required |
dset
|
Dataset
|
Dataset object with idx_manager containing tiling information. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Stitched predictions. |