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

StandardFeatureGenerator([kernel_widths, ...])

Standard Feature Generator

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

class aydin.features.standard_features.StandardFeatureGenerator(kernel_widths=None, kernel_scales=None, kernel_shapes=None, min_level: int = 0, max_level: int = 13, scale_one_width: int = 3, include_scale_one: bool = False, include_fine_features: bool = True, include_corner_features: bool = False, include_line_features: bool = False, decimate_large_scale_features: bool = True, extend_large_scale_features: bool = False, include_spatial_features: bool = False, spatial_features_coarsening: int = 2, num_sinusoidal_features: int = 0, include_median_features: bool = False, include_dct_features: bool = False, dct_max_freq: float = 0.5, include_random_conv_features: bool = False, dtype: numpy.dtype = <class 'numpy.float32'>)[source]

Standard Feature Generator

Methods

add_feature_group(feature_group, *args, **kwargs)

Adds a feature to this feature generator.

clear_features()

Clears the features group list

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

Computes the features given an image.

create_feature_array(image, nb_features)

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

get_num_features(ndim)

Returns the number of features when considering translations

get_receptive_field_radius()

Returns the receptive field radius in pixels

load(path)

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

save(path)

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

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

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()

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)

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

Returns the number of features when considering translations

Parameters
ndimint

number of dimensions

Returns
nb_featuresint
get_receptive_field_radius() int

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

ExtensibleFeatureGenerator

class aydin.features.extensible_features.ExtensibleFeatureGenerator[source]

Extensible Feature Generator class

Methods

add_feature_group(feature_group, *args, **kwargs)

Adds a feature to this feature generator.

clear_features()

Clears the features group list

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

Computes the features given an image.

create_feature_array(image, nb_features)

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

get_num_features(ndim)

Returns the number of features when considering translations

get_receptive_field_radius()

Returns the receptive field radius in pixels

load(path)

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

save(path)

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

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

Methods

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

Computes the features given an image.

create_feature_array(image, nb_features)

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

get_receptive_field_radius()

Returns the receptive field radius in pixels

load(path)

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

save(path)

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

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