Feature Accumulators¶
The main work of compute_features()
is performed by “accumulator” classes.
There are three types of acccumulators: sp
, edge
, and flatedge
.
sp
features process the dense volume of labels and values.edge
accumulators process tables of edge pixels (and corresponding values).flatedge
accumulators process edges between flat superpixels.flatedge
accumulators can only be used if yourRag
is constructed withflat_superpixels=True
.
Built-in¶
Base classes¶
You can write your own accumulator classes and pass them in an accumulator_set
to compute_features()
.
All accumulators must inherit from one of these two base classes:
Reference¶
Standard Accumulators¶
- class ilastikrag.accumulators.standard.StandardEdgeAccumulator(rag, feature_names)[source]¶
Accumulator for features of the edge pixels (only) between superpixels. Uses vigra’s RegionFeatureAccumulator library to compute the features.
Supported feature names:
standard_edge_count
standard_edge_sum
standard_edge_minimum
standard_edge_maximum
standard_edge_mean
standard_edge_variance
standard_edge_kurtosis
standard_edge_skewness
standard_edge_quantiles (short for “all edge quantiles”)
standard_edge_quantiles_0
standard_edge_quantiles_10
standard_edge_quantiles_25
standard_edge_quantiles_50
standard_edge_quantiles_75
standard_edge_quantiles_90
standard_edge_quantiles_100
- ACCUMULATOR_TYPE = 'edge'¶
Accumulator type
- ACCUMULATOR_ID = 'standard'¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘edge’). All feature names supported by this accumulator must begin with the prefix<id>_edge_
Methods: See
BaseEdgeAccumulator
- class ilastikrag.accumulators.standard.StandardSpAccumulator(rag, feature_names)[source]¶
Accumulator for features of the superpixels contents. Uses vigra’s RegionFeatureAccumulator library to compute the features.
Supported feature names:
standard_sp_count
standard_sp_sum
standard_sp_minimum
standard_sp_maximum
standard_sp_mean
standard_sp_variance
standard_sp_kurtosis
standard_sp_skewness
standard_sp_quantiles (short for “all sp quantiles”)
standard_sp_quantiles_0
standard_sp_quantiles_10
standard_sp_quantiles_25
standard_sp_quantiles_50
standard_sp_quantiles_75
standard_sp_quantiles_90
standard_sp_quantiles_100
standard_sp_regionradii (all of the below)
standard_sp_regionradii_0
standard_sp_regionradii_1
standard_sp_regionradii_2
standard_sp_regionaxes (all of the below)
standard_sp_regionaxes_0x
standard_sp_regionaxes_0y
standard_sp_regionaxes_0z
standard_sp_regionaxes_1x
standard_sp_regionaxes_1y
standard_sp_regionaxes_1z
standard_sp_regionaxes_2x
standard_sp_regionaxes_2y
standard_sp_regionaxes_2z
All input feature names result in two output columns, for the
_sum
and_difference
between the two superpixels adjacent to the edge.As a special case, the output columns for the
sp_count
feature are reduced via cube-root (or square-root), as specified in the multicut paper.- ACCUMULATOR_TYPE = 'sp'¶
Accumulator type
- ACCUMULATOR_ID = 'standard'¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘sp’). All feature names supported by this accumulator must begin with the prefix<id>_sp_
Methods: See
BaseSpAccumulator
- class ilastikrag.accumulators.standard.StandardFlatEdgeAccumulator(rag, feature_names)[source]¶
Accumulator for basic features of ‘flat edges’, i.e. the edges in the Z-direction when
Rag.flat_superpixels == True
.Supported feature names:
standard_flatedge_count
standard_flatedge_sum
standard_flatedge_minimum
standard_flatedge_maximum
standard_flatedge_mean
standard_flatedge_variance
standard_flatedge_kurtosis
standard_flatedge_skewness
standard_flatedge_quantiles (short for “all sp quantiles”)
standard_flatedge_quantiles_0
standard_flatedge_quantiles_10
standard_flatedge_quantiles_25
standard_flatedge_quantiles_50
standard_flatedge_quantiles_75
standard_flatedge_quantiles_90
standard_flatedge_quantiles_100
standard_flatedge_regionradii (both of the below)
standard_flatedge_regionradii_0
standard_flatedge_regionradii_1
standard_flatedge_regionaxes (all of the below)
standard_flatedge_regionaxes_0x
standard_flatedge_regionaxes_0y
standard_flatedge_regionaxes_1x
standard_flatedge_regionaxes_1y
standard_flatedge_correlation
- ACCUMULATOR_TYPE = 'flatedge'¶
Accumulator type
- ACCUMULATOR_ID = 'standard'¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘sp’). All feature names supported by this accumulator must begin with the prefix<id>_sp_
Methods: See
BaseFlatEdgeAccumulator
EdgeRegion Accumulator¶
- class ilastikrag.accumulators.edgeregion.EdgeRegionEdgeAccumulator(rag, feature_names)[source]¶
Accumulator for computing region axes and region radii over edge coordinates. (The
StandardEdgeAccumulator
class does not provide region features.)We don’t use vigra’s RegionFeatureAccumulators because we only have access to the sparse lists of edge pixels (along each axis). Instead, we manually compute the region axes/radii directly from the edge coordinate columns.
Supported feature names:
edgeregion_edge_area (radii_0 * radii_1)
edgeregion_edge_volume (radii_0 * radii_1 * radii_2)
edgeregion_edge_regionradii (all of the below)
edgeregion_edge_regionradii_0
edgeregion_edge_regionradii_1
edgeregion_edge_regionradii_2
edgeregion_edge_regionaxes (all of the below)
edgeregion_edge_regionaxes_0x
edgeregion_edge_regionaxes_0y
edgeregion_edge_regionaxes_0z
edgeregion_edge_regionaxes_1x
edgeregion_edge_regionaxes_1y
edgeregion_edge_regionaxes_1z
edgeregion_edge_regionaxes_2x
edgeregion_edge_regionaxes_2y
edgeregion_edge_regionaxes_2z
- ACCUMULATOR_TYPE = 'edge'¶
Accumulator type
- ACCUMULATOR_ID = 'edgeregion'¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘edge’). All feature names supported by this accumulator must begin with the prefix<id>_edge_
Methods: See
BaseEdgeAccumulator
Similarity FlatEdge Accumulator¶
- class ilastikrag.accumulators.similarity.SimilarityFlatEdgeAccumulator(rag, feature_names)[source]¶
Accumulator for computing various similarity metrics between pixel values adjacent to ‘flat edges’, i.e. the edges in the Z-direction when
Rag.flat_superpixels == True
.Supported feature names:
similarity_flatedge_correlation
- ACCUMULATOR_TYPE = 'flatedge'¶
Accumulator type
- ACCUMULATOR_ID = 'similarity'¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘sp’). All feature names supported by this accumulator must begin with the prefix<id>_sp_
Methods: See
BaseFlatEdgeAccumulator
Base Accumulators¶
- class ilastikrag.accumulators.base.BaseEdgeAccumulator(rag, feature_names)[source]¶
Base class for all edge accumulators, i.e. accumulators that compute features from the edge values between superpixels (not superpixel contents).
- ACCUMULATOR_TYPE = 'edge'¶
Accumulator type
- ACCUMULATOR_ID = ''¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘edge’). All feature names supported by this accumulator must begin with the prefix<id>_edge_
- __init__(rag, feature_names)[source]¶
- Parameters:
rag – The rag.
feature_names – A list of feature names to compute with this accumulator.
- cleanup()[source]¶
Called by the Rag to indicate that processing has completed, and the accumulator should discard all cached data and intermediate results. Subclasses must reimplement this function.
- ingest_edges(rag, edge_values)[source]¶
Ingests the given edge values using the given Rag.
- Parameters:
rag – Rag
edge_values – OrderedDict of 1D ndarray. Each ndarray
edge_values[k]
is in the same order asrag.dense_edges[k]
- class ilastikrag.accumulators.base.BaseSpAccumulator(rag, feature_names)[source]¶
Base class for all superpixel accumulators, i.e. accumulators that compute features from the contents of superpixels (not their edges).
- ACCUMULATOR_TYPE = 'sp'¶
Accumulator type
- ACCUMULATOR_ID = ''¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘sp’). All feature names supported by this accumulator must begin with the prefix<id>_sp_
- __init__(rag, feature_names)[source]¶
- Parameters:
rag – The rag.
feature_names – A list of feature names to compute with this accumulator.
- cleanup()[source]¶
Called by the Rag to indicate that processing has completed, and the accumulator should discard all cached data and intermediate results. Subclasses must reimplement this function.
- ingest_values(rag, value_img)[source]¶
Ingest the given (single-channel) pixel values, using the superpixels stored in
rag.label_img
.- Parameters:
rag – Rag
value_img – VigraArray, same shape as
rag.label_img
- append_edge_features_to_df(edge_df)[source]¶
Called by the Rag after
ingest_values()
.Merges the features of ingested data into a final set of edge feature columns, and appends those columns to the given
pandas.DataFrame
object.This involves converting pairs superpixel features into edge features, typically by taking the sum and/or difference between the features of each superpixel in an adjacent pair.
- class ilastikrag.accumulators.base.BaseFlatEdgeAccumulator(rag, feature_names)[source]¶
Base class for all flatedge accumulators, i.e. accumulators that compute features over the edges in the Z direction when
Rag.flat_superpixels == True
- ACCUMULATOR_TYPE = 'flatedge'¶
Accumulator type
- ACCUMULATOR_ID = ''¶
An id string for this accumulator. Must not contain an underscore (
_
). Must not conflict with any other accumulators of the same type (‘sp’). All feature names supported by this accumulator must begin with the prefix<id>_sp_
- __init__(rag, feature_names)[source]¶
- Parameters:
rag – The rag.
feature_names – A list of feature names to compute with this accumulator.
- cleanup()[source]¶
Called by the Rag to indicate that processing has completed, and the accumulator should discard all cached data and intermediate results. Subclasses must reimplement this function.
- ingest_values(rag, value_img)[source]¶
Ingest the given (single-channel) pixel values, using the (flat) superpixels stored in
rag.label_img
.- Parameters:
rag – Rag
value_img – VigraArray, same shape as
rag.label_img