stentfit.core.rings
Functions
|
Split the stent point cloud into axial rings and label every point. |
|
Split the whole stent into small 3D-connected regions, once for all rings. |
|
Split the stent point cloud into rings and let the user confirm the count. |
Module Contents
- stentfit.core.rings.find_rings(stent_df: pandas.DataFrame, strut_thickness: float, n_rings: int | None = None, show_plots: bool = False, out_path: str | None = None) dict[source]
Split the stent point cloud into axial rings and label every point.
Builds a smoothed point-count profile along z; the profile dips where struts converge, marking candidate ring boundaries. When
n_ringsis not forced, the ring pitch is read from the profile’s autocorrelation (falling back to the raw dip count if no clear period exists). An even grid of boundaries is then laid down and only snapped onto a nearby dip when it sits close, so the rings stay even overall.- Parameters:
stent_df – Stent point cloud with
x,y,z,z_cylindrical, andrcolumns.strut_thickness – Strut thickness, used as an upper bound for the 3D connectivity radius.
n_rings – Ring count to force.
Noneauto-detects it from the z-profile.show_plots – Show the dip-detection diagnostic plot inline (matplotlib).
out_path – File path to save the dip-detection plot as a PNG.
Noneskips saving.
- Returns:
Dict with the point cloud labelled with
ring_id(stent_df), the ring z-boundaries (ring_edges), the ring count (n_rings), the 3D connectivity radius (conn_radius_3d), and the dip-detection diagnostics (dip_z_centers,dip_counts_smoothed,dip_indices,dip_depth_thresh,boundary_z,n_bands) used byplot_ring_dips_html().
- stentfit.core.rings.segment_stent(stent_df: pandas.DataFrame, strut_thickness: float, conn_radius_3d: float, n_sub_per_ring: int = 3, min_region_frac: float = 0.2) dict[source]
Split the whole stent into small 3D-connected regions, once for all rings.
Each ring is first cut into
n_sub_per_ringequal z-pieces. Within each piece, points closer thanconn_radius_3dare grouped into connected regions, and any region smaller thanmin_region_fracof the median region size is absorbed into its nearest normal-sized neighbour. The result is a per-pointregionlabel plus which region pairs are actually adjacent in 3D (region_allowed) — used later bycheck_skeleton_quality()to tell a real strut connection from a false one bridging two unrelated regions.- Parameters:
stent_df – Stent point cloud with a
ring_idcolumn (fromdetect_rings()).strut_thickness – Strut thickness, used indirectly via
conn_radius_3d.conn_radius_3d – 3D connectivity radius; points closer than this are grouped into the same region.
n_sub_per_ring – Number of equal z-pieces each ring is cut into before segmenting, so a single ring’s points still split into several regions.
min_region_frac – Regions smaller than this fraction of the median region point-count are absorbed into their nearest normal region.
- Returns:
Dict with the point cloud labelled with
region(stent_df), the region-adjacency matrix (region_allowed), the region count (n_regions), and theconn_radius_3dpassed through unchanged.
- stentfit.core.rings.detect_rings(stent_df: pandas.DataFrame, stent_features: dict, stent_name: str, output_dir: str, max_display: int = 500000, n_rings: int | None = None) dict[source]
Split the stent point cloud into rings and let the user confirm the count.
Runs
find_rings()to locate the point-count dips where struts converge, then draws the dip profile and the ring-colored point cloud so the user can check the split. Ifn_ringsis not given, the user is asked to accept the detected count or type a different one to redo the split with a forced count. Savesring_points.csv,ring_dips.html, andring_assignment.htmlintooutput_dir.- Parameters:
stent_df – Stent point cloud, as returned by
sample_stent_points().stent_features – Stent features dict; only
strut_thicknessis used.stent_name – Name used to label outputs and plots.
output_dir – Folder the CSV and HTML views are written into.
max_display – Maximum number of points drawn in the ring-assignment view.
n_rings – Ring count to force.
Noneauto-detects it, then still prompts the user to accept or override it.
- Returns:
Dict with the point cloud labelled with
ring_id(stent_df), thering_edges(z-boundaries),conn_radius_3d, and the finaln_rings.