Image feature extraction and manipulation (medpy.features
)#
This package contains various functions for feature extraction and manipulation in medical images.
Intensity medpy.features.intensity
#
Functions to extracts intensity based features. Ready to be
manipulated with medpy.features.utilities
and used in
scikit-learn.
|
Takes a simple or multi-spectral image and returns its voxel-wise intensities. |
|
Takes a simple or multi-spectral image and returns its voxel-wise center distance in mm. |
|
Implementation of |
|
Takes an image and returns the voxels ndim-indices as voxel-wise feature. |
|
The approximate mean over a small region at an offset from each voxel. |
|
Computes the distance of each point under the mask to the mask border taking the voxel-spacing into account. |
|
Takes a simple or multi-spectral image and returns the approximate mean over a small region around each voxel. |
|
Computes the gradient magnitude (edge-detection) of the supplied image using gaussian derivates and returns the intensity values. |
|
Computes the multi-dimensional median filter and returns the resulting values per voxel. |
|
Computes multi-dimensional histograms over a region around each voxel. |
|
Computes the hemispheric intensity difference between the brain hemispheres of an brain image. |
Feature representation#
Features can be one or more dimensional and are kept in the following structures:
===== | == == =====
s1 | s2 s3 [...]
f1.1 |
f1.2 |
f2.1 |
f3.1 |
f3.2 |
[...] |
===== | == == =====
, where each column sX denotes a single sample (voxel) and each row a features element e.g. f1 is constitutes a 2-dimensional features and occupies therefore two rows, while f2 is a single element features with a single row. Entries of this array are of type float. These feature representation forms are processable by the scikit-learn methods.
Multi-spectral images#
This package was originally designed for MR images and is therefore suited to handle multi-spectral data such as RGB and MR images. Each feature extraction function can be supplied with list/tuple of images instead of an image. in which case they are considered co-registered and the feature is extracted from all of them independently.
Utilities medpy.feature.utilities
#
A number of utilities to manipulate feature vectors created with medpy.features.intensity
.
|
Returns a feature-wise normalized version of the supplied vector. |
|
Normalize as with |
|
Takes an arbitrary number of vectors containing features and append them (horizontally). |
|
Takes an arbitrary number of aligned vectors of the same length and combines them into a single vector (vertically). |
Histogram medy.features.histogram
#
Functions to create various kinds of fuzzy histograms with the fuzzy_histogram function.
|
Compute a fuzzy histogram. |
|
Create a triangular membership function for a fuzzy histogram bin. |
|
Create a trapezium membership function for a fuzzy histogram bin. |
|
Create a gaussian membership function for a fuzzy histogram bin. |
|
Create the difference of two sigmoids as membership function for a fuzzy histogram bin. |
Available membership functions#
function (string to pass to membership argument of fuzzy_histogram)
triangular_membership (triangular)
trapezoid_membership (trapezoid)
gaussian_membership (gaussian)
sigmoidal_difference_membership (sigmoid)
The smoothness term#
The smoothness term determines the affected neighbourhood, e.g., when set to 2, all values in the range (2 * bin_width + 1/2 bin_wdith) to the left and right of this bin (center) contribute to this bin. Therefore it determines the smoothing factor of this fuzzy membership function. More clearly the smoothness term determines how much the function reaches into the adjunct bins.
An example of the smoothness parameter:
____________ ________ ____________ ________ ____________
/ / \ / \ / \ / \ \
/ / \ / \ / \ / \ \
/ / \ / \ / \ / \ \
---|----------|----------|----------|----------|----------|----------|----------|----
x-3 x-2 x-1 x x+1 x+2 x+3
|-nbh | |crisp bin | | +nbh|
The considered value v is associated with the bin x using crisp (i.e. standard) histograms. For fuzzy histograms with a smoothness of 2, its membership value for the bins x-smoothness (x-2) until x+smoothness (x+2) is computed. While it also might have a membership values for bins further away from x, these are considered to be only marginal and are therefore nor computed. This leads to a speed-up that is especially important when a great number of fuzzy histograms have to be computed.
Boundary effect / the guarantee parameter#
Values near the left and right border of the histogram might not contribute with a full value of 1 to the histogram, as part of their contribution lies outside of the histogram range. To avoid this affect (which can be quite strong for histograms with few bins and a height smoothness term), set ‘guarantee’ to True. The histogram size is then selected to be (left_side - smoothness * bin_width till right_side + smoothness * bin_width) and therefore neglect all boundary effects.
Plots of the membership functions can e.g. be found at http://www.atp.ruhr-uni-bochum.de/rt1/syscontrol/node117.html .