Feature Generator

Aydin use a set of well-engineered feature generators to implement image translators internally. Aydin also provides a public API on feature generators to enable developers who might want to use same feature:

StandardFeatureGenerator
ExtensibleFeatureGenerator

ExtensibleFeatureGenerator()

Extensible Feature Generator class

ExtensibleFeatureGenerator.add_feature_group(...)

Adds a feature to this feature generator.

ExtensibleFeatureGenerator.compute(image[, ...])

Computes the features given an image.

ExtensibleFeatureGenerator.create_feature_array(...)

Creates a feature array of the right size and possibly in a 'lazy' way using memory mapping.

ExtensibleFeatureGenerator.clear_features()

Clears the features group list

ExtensibleFeatureGenerator.get_num_features(ndim)

Returns the number of features when considering translations

ExtensibleFeatureGenerator.get_receptive_field_radius()

Returns the receptive field radius in pixels

ExtensibleFeatureGenerator.load(path)

Returns a 'all-batteries-inlcuded' feature generator from a given path (folder)

ExtensibleFeatureGenerator.save(path)

Saves a 'all-batteries-inlcuded' feature generator at a given path (folder)

FeatureGeneratorBase

FeatureGeneratorBase()

Feature Generator base class

FeatureGeneratorBase.compute(image[, ...])

Computes the features given an image.

FeatureGeneratorBase.create_feature_array(...)

Creates a feature array of the right size and possibly in a 'lazy' way using memory mapping.

FeatureGeneratorBase.get_receptive_field_radius()

Returns the receptive field radius in pixels

FeatureGeneratorBase.load(path)

Returns a 'all-batteries-inlcuded' feature generator from a given path (folder)

FeatureGeneratorBase.save(path)

Saves a 'all-batteries-inlcuded' feature generator at a given path (folder)

StandardFeatureGenerator

ExtensibleFeatureGenerator

class aydin.features.extensible_features.ExtensibleFeatureGenerator[source]

Extensible Feature Generator class

add_feature_group(feature_group: aydin.features.groups.base.FeatureGroupBase, *args, **kwargs)[source]

Adds a feature to this feature generator.

Parameters
feature_groupFeatureGroupBase

feature group

args

additional arguments for function

kwargs

additional keyword arguments for function

clear_features()[source]

Clears the features group list

compute(image, exclude_center_feature=False, exclude_center_value=False, features=None, feature_last_dim=True, passthrough_channels=None, num_reserved_features=0, excluded_voxels=None, spatial_feature_offset=None, spatial_feature_scale=None)[source]

Computes the features given an image. If the input image is of shape (d,h,w), resulting features are of shape (n,d,h,w) where n is the number of features.

Parameters
imagenumpy.ndarray
image for which features are computed
exclude_center_featurebool
exclude_center_valuebool
features
feature_last_dimbool
passthrough_channels
num_reserved_featuresint
excluded_voxels
spatial_feature_offset
spatial_feature_scale
Returns
feature arraynumpy.ndarray
create_feature_array(image, nb_features)

Creates a feature array of the right size and possibly in a ‘lazy’ way using memory mapping.

Parameters
imagenumpy.ndarray

image for which features are created

nb_featuresint
Returns
feature arraynumpy.ndarray
get_num_features(ndim: int) int[source]

Returns the number of features when considering translations

Parameters
ndimint

number of dimensions

Returns
nb_featuresint
get_receptive_field_radius() int[source]

Returns the receptive field radius in pixels

Returns
resultint

receptive field radius in pixels

static load(path: str)

Returns a ‘all-batteries-inlcuded’ feature generator from a given path (folder)

Parameters
pathstr

path to load from

Returns
thawed
save(path: str)

Saves a ‘all-batteries-inlcuded’ feature generator at a given path (folder)

Parameters
pathstr

path to save to

Returns
frozen

FeatureGeneratorBase

class aydin.features.base.FeatureGeneratorBase[source]

Feature Generator base class

abstract compute(image, exclude_center_feature=False, exclude_center_value=False, features=None, feature_last_dim=True, passthrough_channels=None, num_reserved_features=0, excluded_voxels=None, spatial_feature_offset=None, spatial_feature_scale=None)[source]

Computes the features given an image. If the input image is of shape (d,h,w), resulting features are of shape (n,d,h,w) where n is the number of features.

Parameters
imagenumpy.ndarray

image for which features are computed

exclude_center_featurebool
exclude_center_valuebool
features
feature_last_dimbool
passthrough_channels
num_reserved_featuresint
excluded_voxels
spatial_feature_offset
spatial_feature_scale
Returns
feature arraynumpy.ndarray
create_feature_array(image, nb_features)[source]

Creates a feature array of the right size and possibly in a ‘lazy’ way using memory mapping.

Parameters
imagenumpy.ndarray

image for which features are created

nb_featuresint
Returns
feature arraynumpy.ndarray
abstract get_receptive_field_radius()[source]

Returns the receptive field radius in pixels

static load(path: str)[source]

Returns a ‘all-batteries-inlcuded’ feature generator from a given path (folder)

Parameters
pathstr

path to load from

Returns
thawed
save(path: str)[source]

Saves a ‘all-batteries-inlcuded’ feature generator at a given path (folder)

Parameters
pathstr

path to save to

Returns
frozen