convert_prediction
Module containing functions to convert prediction outputs to desired form.
combine_samples(predictions) #
Combine predictions by data_idx.
Images are first grouped by their data_idx found in their region_spec, then sorted by ascending sample_idx before being stacked along the S dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions | list of ImageRegionData | List of | required |
Returns:
| Type | Description |
|---|---|
list of numpy.ndarray | List of combined predictions, one per unique |
list of str | List of sources, one per unique |
Source code in src/careamics/lightning/dataset_ng/prediction/convert_prediction.py
convert_prediction(predictions, tiled) #
Convert the Lightning trainer outputs to the desired form.
This method allows decollating batches and stitching back together tiled predictions.
If the source of all predictions is "array" (see InMemoryImageStack), then the returned sources list will be empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions | list[ImageRegionData] | Output from | required |
tiled | bool | Whether the predictions are tiled. | required |
Returns:
| Type | Description |
|---|---|
list of numpy.ndarray | List of arrays with the axes SC(Z)YX. |
list of str | List of sources, one per output or empty if all equal to |
Source code in src/careamics/lightning/dataset_ng/prediction/convert_prediction.py
decollate_image_region_data(batch) #
Decollate a batch of ImageRegionData into a list of ImageRegionData.
Input batch has the following structure: - data: (B, C, (Z), Y, X) numpy.ndarray - source: sequence of str, length B - data_shape: sequence of tuple of int, each tuple being of length B - dtype: list of numpy.dtype, length B - axes: list of str, length B - region_spec: dict of {str: sequence}, each sequence being of length B - chunks: either a single tuple (1,) or a sequence of tuples of length B
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch | ImageRegionData | Batch of | required |
Returns:
| Type | Description |
|---|---|
list of ImageRegionData | List of |