Basic Patch Constructor
Basic patch constructor implementation.
BasicPatchConstr
Bases: PatchConstr
Construct standard CAREamics input and optional target patches.
This constructor can be used for both training and prediction pipelines.
Parameters:
-
patching_strategy(Patching) –Strategy that maps dataset indices to patch specifications.
-
input_extractor(PatchExtractor) –Extractor for input patches.
-
target_extractor(PatchExtractor or None, default:None) –Extractor for target patches. Can be
Nonefor self-supervised algorithms or prediction pipelines. -
channels(Sequence[int] or None, default:None) –Channel indices to extract. If
None, all channels are extracted.
input_shapes
property
n_patches
property
target_shapes
property
__init__(patching_strategy, input_extractor, target_extractor=None, channels=None)
Initialize the basic patch constructor.
Parameters:
-
patching_strategy(Patching) –Strategy that maps dataset indices to patch specifications.
-
input_extractor(PatchExtractor) –Extractor for input patches.
-
target_extractor(PatchExtractor or None, default:None) –Extractor for target patches. Can be
Nonefor self-supervised algorithms or prediction pipelines. -
channels(Sequence[int] or None, default:None) –Channel indices to extract. If
None, all channels are extracted.
construct_patch(index)
Construct the input and optional target patch for an index.
Parameters:
-
index(int) –Dataset index to map to a patch specification.
Returns:
-
input_patch(NDArray[Any]) –Input patch with axes C(Z)YX.
-
target_patch(NDArray[Any] or None) –Target patch with axes C(Z)YX when a target extractor is available, otherwise
None. -
patch_spec(PatchSpecs) –Patch specification used to extract the patches.
get_input_image_metadata(patch_spec)
Return metadata for the input image described by a patch specification.
Parameters:
-
patch_spec(PatchSpecs) –Patch specification containing the input image index.
Returns:
-
ImageMetadata–Metadata for the input image.
get_patch_indices(data_idx)
Get the patch indices will return patches for a specific image_stack.
The image_stack corresponds to the given data_idx.
Parameters:
-
data_idx(int) –An index that corresponds to a given
image_stack.
Returns:
-
sequence of int–A sequence of patch indices, that when used to index the
CAREamicsDataset will return a patch that comes from theimage_stackcorresponding to the givendata_idx`.
get_principal_input(input_patch)
get_target_image_metadata(patch_spec)
Return metadata for the target image described by a patch specification.
Parameters:
-
patch_spec(PatchSpecs) –Patch specification containing the target image index.
Returns:
-
ImageMetadata | None–Metadata for the target image when targets exist, otherwise
None.