xs3d: Compute cross sectional area for 3D image objects
import xs3d
binary_image = np.load(...)
vertex = np.array([200,121,78])
normal = np.array([0.01, 0.033, 0.9])
resolution = np.array([32,32,40])
area = xs3d.cross_sectional_area(binary_image, vertex, normal, resolution)
area, contact_warning = xs3d.cross_sectional_area(
binary_image, vertex, normal, resolution,
return_contact=True
)
image = xs3d.cross_section(
binary_image, vertex,
normal, resolution,
)
image2d = xs3d.slice(labels, vertex, normal, anisotropy)
Installation
pip install xs3d
Cross Section Calculation
When using skeletons (one dimensional stick figure representations) to create electrophysiological compartment simulations of neurons, some additional information is required for accuracy. The caliber of the neurite changes over the length of the cell.
Previously, the radius from the current skeleton vertex to the nearest background voxel was used, but this was often an underestimate as it is sensitive to noise and divots in a shape.
A superior measure would be the cross sectional area using a section plane that is orthogonal to the direction of travel along the neurite. This library provides that missing capability.
How Does it Work?
The algorithm roughly works as follows.
- Label voxels that are intercepted by the sectioning plane.
- Label the connected components of those voxels.
- Filter out all components except the region of interest.
- Compute the polygon formed by the intersection of the plane with the 8 corners and 12 edges of each voxel.
- Add up the area contributed by each polygon so formed in the component of interest.