linumpy.geometry.interface#
Tissue interface detection and fitting.
Functions#
|
Detect the tissue interface depth in given volume. |
Compute the interface depths from a 3D tissue mask. |
|
|
Detect the tissue interface. |
|
Find the cutting plane using agarose segmentation. |
|
Remove outlier interface depths from the z0 map using median absolute deviation. |
Fit a model on the given interface. |
|
|
Evaluate a quadratic surface model for the tissue interface. |
|
Compute the tissue interface map from quadratic fit parameters. |
|
Intensity profile based on a single homogeneous tissue Beer-Lambert model (covered by some amount of water). |
|
Estimates the linear-homogeneous intensity profile parameters. |
|
Detect water/tissue interface along Z using gradient-based method. |
Module Contents#
- linumpy.geometry.interface.find_tissue_depth(vol, zmin=15, zmax=100, agarose_intensity=5000)[source]#
Detect the tissue interface depth in given volume.
This algorithm first segments the volume into tissue vs background(agarose) using the Li thresholding method and user-defined agarose intensity value. It then computes the XZ mean projection of the tissue mask, and detects the main edge position of the tissue/water interface using morphological operations and relative maximum detection. Other operations are done on the data to reduce the effect of intensity noise and artefacts on the water/tissue interface depth detection.
- Parameters:
- Returns:
Tissue interface depth
- Return type:
Notes
The default depth is 40 px
- linumpy.geometry.interface.get_interface_depth_from_mask(vol)[source]#
Compute the interface depths from a 3D tissue mask.
- Parameters:
vol ((NxMxK) ndarray) – Tissue mask
- Returns:
ndarray – Interface depth (in pixel)
- Return type:
(NxM)
- linumpy.geometry.interface.find_tissue_interface(vol, s_xy=15, s_z=2, use_log=True, mask=None, order=1, detect_cutting_errors=False)[source]#
Detect the tissue interface.
- Parameters:
vol (ndarray) – Containing the volume to analyze
s_xy (int) – Uniform filter kernel size (xy)
s_z (int) – 1st order gaussian kernel size (z)
use_log (bool) – If True, apply log transform before filtering.
mask (ndarray, optional) – Optional mask restricting the analysis region.
order (int) – Gaussian filter order.
detect_cutting_errors (bool) – If True, detect and correct cutting artefacts.
- Returns:
Tissue interface depth
- Return type:
ndarray
- linumpy.geometry.interface.find_cutting_plane(vol, z0map, agarose_mean, agarose_std)[source]#
Find the cutting plane using agarose segmentation.
- Parameters:
- Returns:
popt
detected_interface (ndarray)
z0 (int)
- Return type:
- linumpy.geometry.interface.remove_z0_outliers(z0map)[source]#
Remove outlier interface depths from the z0 map using median absolute deviation.
- Parameters:
z0map (numpy.ndarray)
- Return type:
- linumpy.geometry.interface.fit_interface(interface: numpy.ndarray, method: str = ..., return_center: Literal[False] = ...) numpy.ndarray[source]#
- linumpy.geometry.interface.fit_interface(interface: numpy.ndarray, method: str = ..., return_center: Literal[True] = ...) tuple[numpy.ndarray, tuple[float, float]]
Fit a model on the given interface.
- linumpy.geometry.interface.quadratic_interface(pos, a, b, c, d, e, f, g, h)[source]#
Evaluate a quadratic surface model for the tissue interface.
- Parameters:
- Return type:
- linumpy.geometry.interface.get_quadratic_interface(popt, volshape=(512, 512, 120))[source]#
Compute the tissue interface map from quadratic fit parameters.
- Parameters:
popt (numpy.ndarray)
- Return type:
- linumpy.geometry.interface.linear_homogeneous_profile(z, z0, dz, I0, Ib, sigma)[source]#
Intensity profile based on a single homogeneous tissue Beer-Lambert model (covered by some amount of water).
This will return the log(I).
- Parameters:
- Returns:
Log(I) evaluated at each position z.
- Return type:
ndarray
- linumpy.geometry.interface.estimate_lh_profile_parameters(vol, s=25)[source]#
Estimates the linear-homogeneous intensity profile parameters.
- Parameters:
vol (ndarray) – Volume for which the LHP parameters are evaluated
s (int) – Neighborhood used to average intensities at each depth
- Returns:
float – z0 : Water-tissue interface depth
float – dz : Interface Transition width
float – I0 : Top tissue slice intensity
float – Ib : water intensity
float – sigma : Tissue Attenuation coefficient
- Return type:
tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray]
Note
This first version loops over all intensity profiles (x, y)
- linumpy.geometry.interface.detect_interface_z(vol, sigma_xy=3.0, sigma_z=2.0, use_log=False)[source]#
Detect water/tissue interface along Z using gradient-based method.
Applies Gaussian smoothing then finds the peak of the first-order Z-derivative to locate the tissue surface.
- Parameters:
- Returns:
Estimated interface depth in Z voxels.
- Return type: