linumpy.geometry.crop#
Volume cropping and interface-based masking.
Functions#
|
Crops the given volume according to the range given as input. |
|
Crop whole slice in the z direction. |
|
Create a boolean mask for all voxels at or below the interface depth. |
|
Apply interface depth correction using linear interpolation. |
|
Crop an OME-Zarr volume to a specified depth below the tissue interface. |
Module Contents#
- linumpy.geometry.crop.crop_volume(vol, xlim=None, ylim=None, zlim=None)[source]#
Crops the given volume according to the range given as input.
- Parameters:
- Returns:
Cropped volume
- Return type:
ndarray
Notes
xlim=[0,-1] means that the whole volume in the x dimension will be returned.
- linumpy.geometry.crop.crop_z0_whole_slice(vol, dz=20.0, nz=200.0, voxdim=(1, 1, 1), z0=None, verbose=False, mask=None, return_z0=False)[source]#
Crop whole slice in the z direction.
- Parameters:
vol (ndarray) – Input volume to crop.
dz (float) – Margin in microns under the interface to crop (to remove cutting deformations).
nz (float) – Size of the slice to crop in microns.
voxdim (tuple of int) – Dimension of each voxel in micron/pixel.
z0 (float, optional) – Interface position in microns. If None, it is detected automatically.
verbose (bool) – If True, print debug information.
mask (ndarray, optional) – Tissue mask. If provided, used to compute the tissue interface.
return_z0 (bool) – If True, also return the interface position z0.
- Returns:
Cropped array
- Return type:
ndarray
- linumpy.geometry.crop.mask_under_interface(vol, interface, return_mask=False)[source]#
Create a boolean mask for all voxels at or below the interface depth.
- Parameters:
vol (numpy.ndarray)
interface (numpy.ndarray)
return_mask (bool)
- Return type:
- linumpy.geometry.crop.apply_interface_correction(vol, interface)[source]#
Apply interface depth correction using linear interpolation.
- Parameters:
vol (ndarray) – Volume to fix.
interface (ndarray) – Tissue interface depth.
- Returns:
Fixed volume.
- Return type:
ndarray
- linumpy.geometry.crop.crop_below_interface(vol_zxy, depth_um, resolution_um, sigma_xy=3.0, sigma_z=2.0, crop_before_interface=False, percentile_clip=None)[source]#
Crop an OME-Zarr volume to a specified depth below the tissue interface.
Detects the water/tissue interface using gradient analysis, then crops the volume to retain only
depth_ummicrons below the interface.- Parameters:
vol_zxy (np.ndarray) – Volume with shape (Z, X, Y) as returned by read_omezarr.
depth_um (float) – Target depth below interface in microns.
resolution_um (float) – Z resolution in microns per voxel.
sigma_xy (float) – XY smoothing sigma for interface detection.
sigma_z (float) – Z smoothing sigma for interface detection.
crop_before_interface (bool) – If True, also crop the volume above the detected interface.
percentile_clip (float or None) – If provided, clip values above this percentile before interface detection.
- Returns:
np.ndarray – Cropped volume (Z’, X, Y).
int – Detected interface depth in Z voxels.
- Return type: