Skip to content

Limit File Extractor

Source

Patch extractor that limits how many file stacks are loaded at once.

LimitFilesPatchExtractor

Bases: PatchExtractor[FileImageStack]

Patch extractor that limits how many file stacks are loaded at once.

This patch extractor should be used when the data residing on disk is too large to be loaded in memory at once.

Parameters:

  • image_stacks (sequence of FileImageStack) –

    Image stacks to extract patches from.

  • patch_constructor (PatchConstructor, default: default_patch_constr ) –

    Callable used to build patches from an image stack.

shapes property

Data shape of each image stack.

Returns:

  • list of Sequence[int]

    Shape of each stack.

__init__(image_stacks, patch_constructor=default_patch_constr)

Constructor.

Parameters:

  • image_stacks (sequence of FileImageStack) –

    Image stacks to extract patches from; only a subset are loaded at a time.

  • patch_constructor (PatchConstructor, default: default_patch_constr ) –

    Callable used to build patches from an image stack.

extract_channel_patch(data_idx, sample_idx, channels, coords, patch_size)

Extract patch, loading the file if not already loaded.

Parameters:

  • data_idx (int) –

    Image stack index.

  • sample_idx (int) –

    Sample index.

  • channels (sequence of int or None) –

    Channel indices; None for all.

  • coords (sequence of int) –

    Patch start coordinates.

  • patch_size (sequence of int) –

    Patch size per spatial dimension.

Returns:

  • NDArray

    Patch data.

extract_patch(data_idx, sample_idx, coords, patch_size)

Extract a patch from the specified image stack across all channels.

Eqauivalent to calling extract_channel_patch with channels=None.

Parameters:

  • data_idx (int) –

    Index of the image stack to extract the patch from.

  • sample_idx (int) –

    Sample index. The first dimension of the image data will be indexed at this value.

  • coords (Sequence of int) –

    The coordinates that define the start of a patch.

  • patch_size (Sequence of int) –

    The size of the patch in each spatial dimension.

Returns:

  • ndarray

    The extracted patch.