dcnum.feat.feat_contour.volume
Functions
|
Calculate the volume of a polygon revolved around an axis |
|
Calculate the volume of a polygon revolved around the Z-axis |
Module Contents
- dcnum.feat.feat_contour.volume.volume_from_contours(contour: list[numpy.ndarray], pos_x: numpy.ndarray, pos_y: numpy.ndarray, pixel_size: float)[source]
Calculate the volume of a polygon revolved around an axis
The volume estimation assumes rotational symmetry.
- Parameters:
contour (list of ndarrays of shape (N,2)) – One entry is a 2D array that holds the contour of an event
pos_x (float ndarray of length N) – The x coordinate(s) of the centroid of the event(s) [µm]
pos_y (float ndarray of length N) – The y coordinate(s) of the centroid of the event(s) [µm]
pixel_size (float) – The detector pixel size in µm.
- Returns:
volume – volume in um^3
- Return type:
float ndarray
Notes
The computation of the volume is based on a full rotation of the upper and the lower halves of the contour from which the average is then used.
The volume is computed radially from the center position given by (
pos_x,pos_y). For sufficiently smooth contours, such as densely sampled ellipses, the center position does not play an important role. For contours that are given on a coarse grid, as is the case for deformability cytometry, the center position must be given.References
Yields identical results to the Matlab script by Geoff Olynyk <https://de.mathworks.com/matlabcentral/fileexchange/36525-volrevolve>`_
- dcnum.feat.feat_contour.volume.vol_revolve(r, z, point_scale=1.0)[source]
Calculate the volume of a polygon revolved around the Z-axis
This implementation yields the same results as the volRevolve Matlab function by Geoff Olynyk (from 2012-05-03) https://de.mathworks.com/matlabcentral/fileexchange/36525-volrevolve.
The difference here is that the volume is computed using (a much more approachable) implementation using the volume of a truncated cone (https://de.wikipedia.org/wiki/Kegelstumpf).
\[V = \frac{h \cdot \pi}{3} \cdot (R^2 + R \cdot r + r^2)\]Where \(h\) is the height of the cone and \(r\) and
Rare the smaller and larger radii of the truncated cone.Each line segment of the contour resembles one truncated cone. If the z-step is positive (counter-clockwise contour), then the truncated cone volume is added to the total volume. If the z-step is negative (e.g. inclusion), then the truncated cone volume is removed from the total volume.
- Parameters:
r (1d np.ndarray) – radial coordinates (perpendicular to the z axis)
z (1d np.ndarray) – coordinate along the axis of rotation
point_scale (float) – point size in your preferred units; The volume is multiplied by a factor of point_scale**3.
Notes
The coordinates must be given in counter-clockwise order, otherwise the volume will be negative.