stentfit.core.rings

Functions

find_rings(→ dict)

Split the stent point cloud into axial rings and label every point.

segment_stent(→ dict)

Split the whole stent into small 3D-connected regions, once for all rings.

detect_rings(→ dict)

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_rings is 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, and r columns.

  • strut_thickness – Strut thickness, used as an upper bound for the 3D connectivity radius.

  • n_rings – Ring count to force. None auto-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. None skips 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 by plot_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_ring equal z-pieces. Within each piece, points closer than conn_radius_3d are grouped into connected regions, and any region smaller than min_region_frac of the median region size is absorbed into its nearest normal-sized neighbour. The result is a per-point region label plus which region pairs are actually adjacent in 3D (region_allowed) — used later by check_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_id column (from detect_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 the conn_radius_3d passed 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. If n_rings is not given, the user is asked to accept the detected count or type a different one to redo the split with a forced count. Saves ring_points.csv, ring_dips.html, and ring_assignment.html into output_dir.

Parameters:
  • stent_df – Stent point cloud, as returned by sample_stent_points().

  • stent_features – Stent features dict; only strut_thickness is 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. None auto-detects it, then still prompts the user to accept or override it.

Returns:

Dict with the point cloud labelled with ring_id (stent_df), the ring_edges (z-boundaries), conn_radius_3d, and the final n_rings.