Skip to content

v2.0.0

Choose a tag to compare

@carluri carluri released this 11 Nov 21:01
· 61 commits to main since this release
bd4ffdd

A major release. Nothing is removed and no signature changes, but the contours rt-utils writes by default, and the masks it reads back, both change.

The default contour placement was wrong

A treatment planning system reads the contour, not our mask. Until now contours were traced through voxel centres, which understates the structure by half a voxel on every side. Measured against the true extent of a square mask at 0.488 mm spacing:

size true mm² 1.x error
3×3 2.15 0.95 −55.6%
5×5 5.96 3.81 −36.0%
10×10 23.84 19.31 −19.0%
50×50 596.05 572.44 −4.0%
100×100 2384.18 2336.74 −2.0%

The error is a fixed half voxel per side, so it is negligible for large structures and severe for small ones — fiducials, seeds, small nodes. contour_mode now defaults to "voxel_edge", which traces voxel boundaries and is exact at every size.

This is why it never showed up in testing: reading a contour back inflated it by exactly the amount writing it had lost. Two errors cancelling.

Contours are now rasterised by voxel centre

Fixing the default alone would have made things worse. cv2.fillPoly fills vertex to vertex inclusive, so a contour tracing voxel boundaries gained a row and a column when read back — a single voxel returned as four.

A voxel is now set when its centre lies inside the contour. That is correct for contours traced on boundaries and for contours traced through centres, so masks written by other software are read more accurately too, whichever convention they used.

Every conformance shape now round trips exactly in both modes.

Migration

Pass contour_mode="voxel_center" to reproduce the previous contours exactly:

rtstruct.add_roi(mask=mask, name="roi", contour_mode="voxel_center")

Also added

add_roi_from_coordinates takes contours as patient-space points instead of a mask, attaching each to the slice nearest its own position:

rtstruct.add_roi_from_coordinates(
    coordinates=[[[-20.0, -170.0, -559.0], [30.0, -170.0, -559.0], ...]],
    name="from-coordinates",
)

Based on #107 by @gacou54.

Note

2.0.0 supersedes 1.5.0, which was never published to PyPI.


What's Changed

  • Add RTStruct.add_roi_from_coordinates in #158
  • Make voxel_edge the default, and rasterise by voxel centre in #159
  • Prepare release 2.0.0 in #160

Full Changelog: v1.5.0...v2.0.0