Averaging¶
Implementation of several image averaging algorithms.
Available averaging methods are:
mean, compute the mean value for each voxel;
robust-mean, compute the trimmed mean keeping only a fraction of values for each voxel [Truncated_mean];
median, compute the median value for each voxel;
minimum, keep the minimum value for each voxel;
maximum, keep the maximum value for each voxel;
quantile, retain only the given
quantile_value
for each voxel [Quantile];sum, compute the sum for each voxel;
var, compute the variance for each voxel;
stddev, compute the standard deviation for each voxel.
- timagetk.algorithms.averaging.images_averaging(images, method=None, masks=None, **kwargs)[source]¶
Images averaging algorithm.
- Parameters:
images (list(SpatialImage)) – List of
SpatialImage
to average.method ({"mean", "robust-mean", "median", "minimum", "maximum", "quantile", "sum", "var", "stddev"}, optional) – Image averaging method to use, “mean” by default.
masks (list of SpatialImage, optional) – If any, a list of masks to apply to
images
before averaging.window (list) – Window size for processing, default is [1, 1(, 1)].
quantile_value (float) – Quantile of the retained value, should be in the
[0, 1]
range. See notes for detailled explanations.lts_fraction (float in [0, 1]) – Fraction of points to be kept for the computation of the robust mean (trimmed estimation). Should be in the
[0, 1]
range.params (str, optional) – CLI parameter string used by
vt.mean_images
method.
- Returns:
timagetk.SpatialImage – Average image and its metadata.
- Raises:
ValueError – If the image returned by
vt.mean_images
isNone
.
See also
timagetk.third_party.vt_parser.AVERAGING_METHODS
,timagetk.third_party.vt_parser.DEF_AVG_METHOD
,timagetk.third_party.vt_parser.averaging_kwargs
,timagetk.third_party.vt_parser.general_kwargs
,timagetk.third_party.vt_parser.parallel_kwargs
Notes
All images should have the same physical properties:
shape
&voxelsize
.Explanations for
quantile_value
parameters:0
: minimum value, equivalent to “min” method0.5
: median value, equivalent to “median” method1
: maximum value, equivalent to “max” method
References
[Truncated_mean][Quantile]Examples
>>> from timagetk.algorithms.averaging import images_averaging >>> from timagetk.synthetic_data.wall_image import example_layered_sphere_wall_image >>> image = example_layered_sphere_wall_image() >>> list_images = [image, image, image] >>> mean_image = images_averaging(list_images, method='mean') >>> rob_mean_image = images_averaging(list_images, method='robust-mean', lts_fraction=0.8) >>> q_mean_image = images_averaging(list_images, method='quantile', quantile_value=0.8)