PyGeometry
- class multimodars.PyGeometry(frames, label)
Bases:
objectPython representation of a full intravascular imaging geometry (sequence of frames).
- label
Human-readable label for this geometry.
- Type:
str
Examples
>>> geom = PyGeometry( ... frames=[frame1, frame2, ...], ... label="Pat00_diastole" ... )
- center_to_contour(contour_type)
Center the entire geometry on a specific contour type.
- Parameters:
contour_type (PyContourType) – Contour type to center on (e.g.
PyContourType.Lumen).- Returns:
New geometry centered on the specified contour type.
- Return type:
- downsample(n_points)
Return a new geometry with
n_pointsper ContourType.- Parameters:
n_points (int) – Number of points remaining per Contour.
- Returns:
New downsampled geometry.
- Return type:
Examples
>>> new_geom = geometry.downsample(100)
- get_contours(contour_type)
Get contours by type string
- get_contours_by_type(contour_type)
Get all contours of a specific type
- get_frame_at_index(index)
Return the frame at position
index.- Parameters:
index (int) – Zero-based index of the frame to retrieve.
- Returns:
Frame at the given index.
- Return type:
- Raises:
IndexError – If
indexis out of range.
Examples
>>> frame = geometry.get_frame_at_index(0)
- get_frame_at_z(z)
Return the frame whose centroid z-coordinate is closest to
z.- Parameters:
z (float) – Target z position in the same units as the geometry.
- Returns:
Frame with centroid z nearest to
z.- Return type:
- Raises:
ValueError – If the geometry contains no frames.
Examples
>>> frame = geometry.get_frame_at_z(34.8)
- get_lumen_contours()
Get lumen contours (convenience method)
- get_summary()
Get a compact summary of lumen properties for this geometry.
When all contours have an elliptic ratio below 1.3 the vessel is treated as elliptic and a lenient threshold of 70 % of the maximum area is used to identify stenotic segments; otherwise a stricter 50 % threshold is applied.
- Returns:
mla (float) – Minimal lumen area in the units of the input data (e.g. mm²).
max_stenosis (float) –
1 - (mla / max_area).stenosis_length_mm (float) – Length in mm of the longest contiguous region where the contour area falls below the threshold.
- replace_frame(index, frame)
Return a new geometry with the frame at
indexreplaced byframe.- Parameters:
index (int) – Zero-based index of the frame to replace.
frame (PyFrame) – Replacement frame.
- Returns:
New geometry with the specified frame replaced.
- Return type:
- Raises:
IndexError – If
indexis out of range.
Examples
>>> new_geom = geometry.replace_frame(5, other_frame)
- rotate(angle_deg)
Rotate the entire geometry around its centroid by an angle in degrees.
All frames (lumen, extras) are rotated around the same centroid.
- Returns:
New geometry rotated around its centroid.
- Return type:
Examples
>>> geometry = geometry.rotate(20)
- smooth_frames()
Apply smoothing to all frames using a three-point moving average.
- Returns:
New geometry with smoothed frames.
- Return type:
Examples
>>> geom.smooth_frames()
- sort_frame_points()
Re-index all frame contour points so the point with the highest Z-value in frame 0’s lumen gets
point_index = 0. The same index offset is applied to every contour in every frame. Physical point positions are unchanged — only thepoint_indexfields are reassigned.- Returns:
New geometry with re-indexed frames.
- Return type:
- translate(dx, dy, dz)
Translate all frames in the geometry by
(dx, dy, dz).- Parameters:
dx (float) – Translation in the x-direction.
dy (float) – Translation in the y-direction.
dz (float) – Translation in the z-direction.
- Returns:
New geometry with all frames translated.
- Return type: