Adjust CCTA

multimodars.ccta.labeling.label_geometry(path_ccta_geometry, path_centerline_aorta, path_centerline_rca, path_centerline_lca, anomalous_rca=False, anomalous_lca=False, n_points_intramural=120, bounding_sphere_radius_mm=3.0, tolerance_float=1e-06, control_plot=True)[source]

Label CCTA mesh vertices as aorta, RCA, or LCA using centerline-based region detection.

Loads a 3-D surface mesh and three centerlines (aorta, RCA, LCA), then assigns each mesh vertex to one of the anatomical regions. For anomalous vessels an additional occlusion-removal step uses ray-triangle intersection to strip intramural segments, followed by adjacency-map reclassification to clean up isolated mis-labelled vertices. Herfore, a ray is cast from every aorta point to the centerline points of the anomalous section and if 3 faces are intersected by the ray the points from the first face must correspond to the intramural section.

Parameters:
  • path_ccta_geometry (Path | str | Trimesh) – Path to the CCTA surface mesh file (any format supported by multimodars.io.read_geometrical.read_mesh()).

  • path_centerline_aorta (Path | str | PyCenterline) – Path to a CSV file containing the aortic centerline (comma-delimited, columns: x, y, z, …).

  • path_centerline_rca (Path | str | PyCenterline) – Path to a CSV file containing the RCA centerline.

  • path_centerline_lca (Path | str | PyCenterline) – Path to a CSV file containing the LCA centerline.

  • anomalous_rca (bool) – When True applies ray-triangle occlusion removal to the RCA region to handle anomalous (intramural) courses. Default is False.

  • anomalous_lca (bool) – When True applies ray-triangle occlusion removal to the LCA region. Default is False.

  • n_points_intramural (int) – Number of coronary centerline points examined during occlusion removal (the intramural segment length). Default is 120.

  • bounding_sphere_radius_mm (float) – Radius in millimetres of the rolling sphere used to collect candidate mesh vertices around each centerline point. Default is 3.0.

  • tolerance_float (float) – Distance tolerance used when matching mesh vertices to points during face lookup. Default is 1e-6.

  • control_plot (bool) – When True opens an interactive 3-D scene showing the labelled mesh after processing. Default is True.

Return type:

tuple[dict, tuple[PyCenterline, PyCenterline, PyCenterline]]

Returns:

  • results (dict) – Dictionary with keys:

    • "mesh" - the original trimesh.Trimesh object.

    • "aorta_points" - list of (x, y, z) tuples for aortic vertices.

    • "rca_points" - list of (x, y, z) tuples for RCA vertices.

    • "lca_points" - list of (x, y, z) tuples for LCA vertices.

    • "rca_removed_points" - RCA vertices removed by occlusion detection.

    • "lca_removed_points" - LCA vertices removed by occlusion detection.

  • centerlines (tuple) – A 3-tuple (cl_rca, cl_lca, cl_aorta) of PyCenterline objects.

Raises:

Exception – Re-raises any error that occurs while reading the mesh or centerline files, after printing a descriptive message.

multimodars.ccta.labeling.label_anomalous_region(centerline, frames, results, results_key='rca_points', debug_plot=False)[source]

Partition a coronary region into proximal, anomalous, and distal sub-regions.

Uses the intravascular imaging frames to determine where along the centerline the anomalous (intramural) segment begins and ends, then tags each mesh vertex accordingly.

Parameters:
  • centerline (PyCenterline) – Centerline of the coronary vessel of interest.

  • frames (list of PyFrame) – Ordered list of intravascular imaging frames for the vessel.

  • results (dict) – Labelled results dictionary (e.g. from label_geometry()). Must contain the key specified by results_key.

  • results_key (str) – Key in results whose point list is partitioned. Default is "rca_points".

  • debug_plot (bool) – When True opens an interactive visualisation of the three sub-regions. Default is False.

Returns:

The input results dictionary extended with three new keys:

  • "proximal_points" - vertices proximal to the anomalous segment.

  • "distal_points" - vertices distal to the anomalous segment.

  • "anomalous_points" - vertices within the anomalous segment.

Return type:

dict

multimodars.ccta.manipulating.scale_region_centerline_morphing(mesh, region_points, centerline, diameter_adjustment_mm)[source]

Scale a mesh region radially around its centerline.

Each vertex in region_points is displaced along the direction from the nearest centerline point outward (positive diameter_adjustment_mm) or inward (negative).

Parameters:
  • mesh (Trimesh) – The original mesh. A copy is returned; the input is not modified.

  • region_points (list) – (x, y, z) coordinates of the vertices to be scaled. Only vertices present in this list are moved.

  • centerline (PyCenterline) – Centerline of the vessel region used as the morphing axis.

  • diameter_adjustment_mm (float) – Diameter change in millimetres. Positive values expand the lumen; negative values contract it.

Returns:

A new mesh with the selected region scaled.

Return type:

Trimesh

Warns:
  • If no vertices matching *region_points* are found in the mesh, a warning

  • is printed and the unmodified copy is returned.

multimodars.ccta.manipulating.find_distal_and_proximal_scaling(frames, centerline, results, dist_range=3, prox_range=2)[source]

Compute the optimal radial scaling factors for the proximal and distal segments.

Collects lumen wall points from the first prox_range and last dist_range imaging frames as reference geometry, then calls the Rust find_proximal_distal_scaling routine to find the scaling factors that best match the anomalous segment endpoints to those references.

Parameters:
  • frames (list of PyFrame) – Ordered intravascular imaging frames for the vessel.

  • centerline (PyCenterline) – Centerline of the vessel region.

  • results (dict) – Labelled results dictionary containing "anomalous_points".

  • dist_range (int) – Number of frames from the distal end used as the distal reference. Default is 3.

  • prox_range (int) – Number of frames from the proximal end used as the proximal reference. Default is 2.

Return type:

tuple[float, float]

Returns:

  • prox_scaling (float) – Optimal radial scaling factor for the proximal segment.

  • dist_scaling (float) – Optimal radial scaling factor for the distal segment.

multimodars.ccta.manipulating.find_aorta_scaling(frames, cl_aorta, results)[source]

Compute the optimal radial scaling factor for the aortic region.

Extracts reconstructed wall points from the intravascular frames (using aortic_thickness and the "Wall" extras) as a reference, then calls the Rust find_aortic_scaling routine to determine the factor that best aligns the removed RCA points to those references.

Parameters:
  • frames (list[PyFrame]) – Intravascular imaging frames containing aortic_thickness and extras["Wall"] data.

  • cl_aorta (PyCenterline) – Centerline of the aortic region.

  • results (dict) – Labelled results dictionary containing "rca_removed_points".

  • debug_plot (bool, optional) – Reserved for future use; currently unused. Default is True.

Returns:

Optimal radial scaling factor for the aortic segment.

Return type:

float

multimodars.ccta.debug_plots.compare_centerline_scaling(original_mesh, scaled_mesh, region_points, centerline=None)[source]

Open three interactive scenes comparing the original and scaled meshes.

  • Scene 1 - original mesh with the scaled region highlighted in red and the centerline in cyan.

  • Scene 2 - scaled mesh with the same overlays.

  • Scene 3 - side-by-side view: original (blue-ish) shifted 150 mm along the x-axis next to the scaled mesh (orange-ish).

Parameters:
  • original_mesh (Trimesh) – Mesh before scaling.

  • scaled_mesh (Trimesh) – Mesh after scaling (e.g. from scale_region_centerline_morphing()).

  • region_points (list) – (x, y, z) coordinates of the scaled region, highlighted in red.

  • centerline (PyCenterline, optional) – Centerline overlaid in cyan; skipped when None.