do_periodic_segmentation_rust

go-to Primary periodic segmentation pipeline after Rust dgrid.

rust_fun.do_periodic_segmentation_rust(
    dgrid,
    mat_atoms,
    mask_thickness=0.05,
    h=0.2,
    min_distance=1.5,
    threshold_abs=1.5,
    preserve_threshold=3.0,
    smooth_threshold=6.0,
    max_smooth_radius=2.0,
    return_padded_regions=False,
    spacing=None,
    minimum_window_separation=None,
    wall_thickness=0.05,
    extra_padding=5,
    compactness=0,
    min_region_size=0.001,
    disable_tqdm=False,
    compute_connections=True,
    return_dgrid=False,
    watershed_backend='rust_det',
    watershed_connectivity=2,
    skip_endchannel_pairs=True,
    vdw_radii_set=None,
    vdw_radii_angstrom=None,
    check_plr=True,
)

Perform periodic segmentation on a distance grid to identify pore regions.

This function implements a comprehensive pore segmentation algorithm that: 1. Detects local maxima in the distance field 2. Applies periodic boundary conditions 3. Performs watershed segmentation 4. Identifies connections between regions 5. Returns detailed segmentation results

Parameters

Name Type Description Default
dgrid numpy.ndarray 3D distance grid from dgrid_from_atoms_rust required
mat_atoms ase.Atoms ASE Atoms object of the material required
mask_thickness float Threshold for void space identification 0.05
check_plr bool Run the legacy lattice pore-limiting-radius sanity check on dgrid (warns if mask_thickness exceeds it; never alters mask_thickness). Set False to skip the check, e.g. for large porous carbons where it is slow. True
h float Persistence parameter for maxima detection 0.2
min_distance float Minimum distance of separationg required between distinct local maxima 1.5
threshold_abs float Absolute threshold for maxima detection 1.5
preserve_threshold float Distance cutoff (Å) below which maxima are untouched during smoothing 3.0
smooth_threshold float Distance threshold (Å) above which maxima are always smoothed 6.0
max_smooth_radius float Maximum radius (Å) used when smoothing maxima 2.0
return_padded_regions bool Whether to return padded region arrays False
spacing float | None Grid spacing. If None, estimated from dgrid size and cell lengths. Specify for better accuracy. None
minimum_window_separation float | None Minimum separation for window connections None
wall_thickness float Thickness of wall regions to exclude 0.05
extra_padding float Additional padding for periodic calculations in angstroms. This over and above the standard_padding + 5 A cushion. 5
compactness float Watershed compactness parameter 0
min_region_size float Minimum region size as fraction of total volume, regions smaller than this in comparison with the padded_grid are removed 0.001
disable_tqdm bool Whether to disable progress bars False
compute_connections bool Whether to compute inter-region connections True
return_dgrid bool Whether to include dgrid in output False
watershed_backend str Which watershed backend to use: “rust_det” (default, deterministic Rust heap), “rust_bucket” (parallel bucket flood), “rust_det_parallel” (deterministic parallel), or “skimage”. 'rust_det'
skip_endchannel_pairs If True (default), do not merge tiny wall-touching end-channel slivers into neighbors. Set False only for cosmetic visualization cleanup. True
watershed_connectivity int Connectivity for skimage watershed (2=18-NN, 3=26-NN). Only used when watershed_backend=“skimage”. 2
vdw_radii_set Name of the VDW table used to build dgrid (e.g. bondi_crc_fallback, mendeleev). Recorded in input_params; default bondi_crc_fallback. None
vdw_radii_angstrom Per-atom radii (Å) used for dgrid, if recording a custom array (sets vdw_radii_set to array when omitted). None

Returns

Name Type Description
dict Dictionary containing segmentation results including maxima, regions, connections, etc.