dasf.transforms.operations

Basic transform operations module.

Classes

Reshape

Get a slice of a cube. An inline slice is a section over the x-axis.

SliceArray

Class representing a Transform operation of the pipeline.

SliceArrayByPercent

Class representing a Transform operation of the pipeline.

SliceArrayByPercentile

Class representing a Transform operation of the pipeline.

ApplyPatchesBase

Base Class for ApplyPatches Functionalities

ApplyPatchesWeightedAvg

ApplyPatches with Weighted Average combination function.

ApplyPatchesVoting

ApplyPatches with Voting combination function.

Module Contents

class dasf.transforms.operations.Reshape(shape=None)[source]

Bases: dasf.transforms.base.Fit

Get a slice of a cube. An inline slice is a section over the x-axis.

Parameters

iline_indexint

The index of the inline to get.

shape
fit(X, y=None)[source]

Generic fit funtion according executor.

Parameters:

shape (tuple)

class dasf.transforms.operations.SliceArray(output_size)[source]

Bases: dasf.transforms.base.Transform

Class representing a Transform operation of the pipeline.

x
transform(X)[source]

Generic transform funtion according executor.

class dasf.transforms.operations.SliceArrayByPercent(x=100.0, y=100.0, z=100.0)[source]

Bases: dasf.transforms.base.Transform

Class representing a Transform operation of the pipeline.

x
y
z
transform(X)[source]

Generic transform funtion according executor.

class dasf.transforms.operations.SliceArrayByPercentile(percentile)[source]

Bases: dasf.transforms.base.Transform

Class representing a Transform operation of the pipeline.

p
_internal_chunk_array_positive(block, axis=None, keepdims=False, xp=np)[source]
_internal_aggregate_array_positive(block, axis=None, keepdims=False, xp=np)[source]
_internal_chunk_array_negative(block, axis=None, keepdims=False, xp=np)[source]
_internal_aggregate_array_negative(block, axis=None, keepdims=False, xp=np)[source]
_lazy_transform_cpu(X)[source]

Respective lazy transform mocked function for CPUs.

_lazy_transform_gpu(X)[source]

Respective lazy transform mocked function for GPUs.

_transform_cpu(X)[source]

Respective immediate transform mocked function for local CPU(s).

_transform_gpu(X)[source]

Respective immediate transform mocked function for local GPU(s).

class dasf.transforms.operations.ApplyPatchesBase(function, weight_function, input_size, overlap, offsets)[source]

Bases: dasf.transforms.base.Transform

Base Class for ApplyPatches Functionalities

function: function to be applied to each patch, can be eiter a Python Function or a ModelLoader weight_function: weight attribution function, must receive a shape and produce a NDArray with the respective weights for each array position input_size: size of input to the function to be applied, overlap: dictionary containing overlapping/padding configurations to use with np.pad or dask.overlap.overlap. Its important that for the base patch set the whole “chunk core” is covered by the patches. offsets: list of offsets for overlapping patches extraction

_function
_weight_function
_input_size
_offsets
overlap
_overlap_config
_apply_patches(patch_set)[source]

Applies function to each patch in a patch set

_reconstruct_patches(patches, index, weights, inner_dim=None)[source]

Rearranges patches to reconstruct area of interest from patches and weights

_adjust_patches(arrays, ref_shape, offset, pad_value=0)[source]

Pads reconstructed_patches with 0s to have same shape as the reference shape from the base patch set

abstract _combine_patches(results, offsets, indexes)[source]

How results are combined is dependent on what is being combined. ApplyPatchesWeightedAvg uses Weighted Average ApplyPatchesVoting uses Voting (hard or soft)

_extract_patches(data, patch_shape)[source]

Patch extraction method. It will be called once for the base patch set and also for the requested offsets (overlapping patch sets)

_operation(chunk)[source]

Operation to be performed on each chunk

_transform(X)[source]
_lazy_transform(X)[source]
_lazy_transform_cpu(X, **kwargs)[source]

Respective lazy transform mocked function for CPUs.

_lazy_transform_gpu(X, **kwargs)[source]

Respective lazy transform mocked function for GPUs.

_transform_cpu(X, **kwargs)[source]

Respective immediate transform mocked function for local CPU(s).

_transform_gpu(X, **kwargs)[source]

Respective immediate transform mocked function for local GPU(s).

class dasf.transforms.operations.ApplyPatchesWeightedAvg(function, weight_function, input_size, overlap, offsets)[source]

Bases: ApplyPatchesBase

ApplyPatches with Weighted Average combination function.

function: function to be applied to each patch, can be eiter a Python Function or a ModelLoader weight_function: weight attribution function, must receive a shape and produce a NDArray with the respective weights for each array position input_size: size of input to the function to be applied, overlap: dictionary containing overlapping/padding configurations to use with np.pad or dask.overlap.overlap. Its important that for the base patch set the whole “chunk core” is covered by the patches. offsets: list of offsets for overlapping patches extraction

_combine_patches(results, offsets, indexes)[source]

How results are combined is dependent on what is being combined. ApplyPatchesWeightedAvg uses Weighted Average ApplyPatchesVoting uses Voting (hard or soft)

class dasf.transforms.operations.ApplyPatchesVoting(function, weight_function, input_size, overlap, offsets, voting, num_classes)[source]

Bases: ApplyPatchesBase

ApplyPatches with Voting combination function.

function: function to be applied to each patch, can be eiter a Python Function or a ModelLoader weight_function: weight attribution function, must receive a shape and produce a NDArray with the respective weights for each array position input_size: size of input to the function to be applied, overlap: dictionary containing overlapping/padding configurations to use with np.pad or dask.overlap.overlap. Its important that for the base patch set the whole “chunk core” is covered by the patches. offsets: list of offsets for overlapping patches extraction voting: voting method. “hard” or “soft” num_classes: number of classes possible

_voting
_num_classes
_combine_patches(results, offsets, indexes)[source]

How results are combined is dependent on what is being combined. ApplyPatchesWeightedAvg uses Weighted Average ApplyPatchesVoting uses Voting (hard or soft)

_hard_voting(results, offsets, indexes)[source]

Hard voting combination function

_soft_voting(results, offsets, indexes)[source]

Soft voting combination function