Patching
A module to contain type definitions relating to patching strategies.
PatchSpecs
Bases: TypedDict
A dictionary that specifies a single patch in a series of ImageStacks.
Attributes:
-
data_idx(int) –Determines which
ImageStacka patch belongs to, within a series ofImageStacks. -
sample_idx(int) –Determines which sample a patch belongs to, within an
ImageStack. -
coords(sequence of int) –The top-left (and first z-slice for 3D data) of a patch. The sequence will have length 2 or 3, for 2D and 3D data respectively.
-
patch_size(sequence of int) –The size of the patch. The sequence will have length 2 or 3, for 2D and 3D data respectively.
Patching
Bases: Protocol
An interface for patching strategies.
Patching strategies are a component of the CAREamicsDataset; they determine
how patches are extracted from the underlying data.
Attributes:
Methods:
-
get_patch_spec–Get a patch specification for a given patch index.
n_patches
property
The number of patches that the patching strategy will return.
It also determines the maximum index that can be given to get_patch_spec,
and the length of the CAREamicsDataset.
Returns:
-
int–Number of patches.
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_patch_spec(index)
Get a patch specification for a given patch index.
This method is intended to be called from within the
CAREamicsDataset.__getitem__. The index will be passed through from this
method.
Parameters:
-
index(int) –A patch index.
Returns:
-
PatchSpecs–A dictionary that specifies a single patch in a series of
ImageStacks.
TileSpecs
Bases: PatchSpecs
A dictionary that specifies a single patch in a series of ImageStacks.
Attributes:
-
data_idx(int) –Determines which
ImageStacka patch belongs to, within a series ofImageStacks. -
sample_idx(int) –Determines which sample a patch belongs to, within an
ImageStack. -
coords(sequence of int) –The top-left (and first z-slice for 3D data) of a patch. The sequence will have length 2 or 3, for 2D and 3D data respectively.
-
patch_size(sequence of int) –The size of the patch. The sequence will have length 2 or 3, for 2D and 3D data respectively.
-
crop_coords(sequence of int) –The top-left side of where the tile will be cropped, in coordinates relative to the tile.
-
crop_size(sequence of int) –The size of the cropped tile.
-
stitch_coords(sequence of int) –Where the tile will be stitched back into an image, taking into account that the tile will be cropped, in coords relative to the image.
-
total_tiles(int) –Number of tiles belonging to the same data.
is_tile_specs(specs)
Determine whether a given PatchSpecs is a TileSpecs.
Used for type checking.
Parameters:
-
specs(PatchSpecs) –A patch specification.
Returns:
-
bool–Whether the given specs is a TileSpecs.