SegmentationMetrics =================== Segmentation quality metrics computation. Computes Dice coefficient, Hausdorff distance, and other metrics for comparing test segmentations against reference (gold standard) segmentations. Classes ------- .. py:class:: MetricsResult Result of comparing two segmentations. **Methods:** .. py:method:: to_dict() Convert to dictionary for JSON serialization. .. py:class:: SegmentationMetrics Compute comparison metrics between segmentations. Uses SimpleITK for Dice, Hausdorff, and overlap metrics. Usage: metrics = SegmentationMetrics.compute( test_seg_node, test_segment_id, ref_seg_node, ref_segment_id, volume_node ) print(f"Dice: {metrics.dice:.3f}") print(f"Hausdorff 95%: {metrics.hausdorff_95:.1f}mm") **Methods:** .. py:method:: compute() Compute Dice and Hausdorff between test and reference segmentations. .. py:method:: compute_dice_only() Compute Dice coefficient only (faster than full metrics). .. py:class:: StrokeRecord Record of a single stroke's metrics. **Methods:** .. py:method:: to_dict() Convert to dictionary for JSON serialization. .. py:class:: StrokeMetricsTracker Track how metrics improve with each stroke. Usage: tracker = StrokeMetricsTracker(gold_seg, gold_id, volume) for stroke_params in stroke_list: # Apply stroke to test_seg... record = tracker.record_stroke(test_seg, test_id, stroke_params) print(f"Stroke {record.stroke}: Dice={record.dice:.3f}") summary = tracker.get_summary() print(f"Strokes to 90% Dice: {summary['strokes_to_90pct']}") **Methods:** .. py:method:: __init__() Initialize tracker. .. py:method:: record_stroke() Record metrics after a stroke. .. py:method:: get_summary() Summarize stroke progression. .. py:method:: reset() Clear stroke history for a new trial. Functions --------- .. py:function:: to_dict() Convert to dictionary for JSON serialization. .. py:function:: compute() Compute Dice and Hausdorff between test and reference segmentations. Args: test_seg_node: Test segmentation MRML node. test_segment_id: Segment ID within test segmentation. reference_seg_node: Reference (gold) segmentation MRML node. reference_segment_id: Segment ID within reference segmentation. volume_node: Volume node providing geometry (spacing). Returns: MetricsResult with all computed metrics. .. py:function:: compute_dice_only() Compute Dice coefficient only (faster than full metrics). Args: test_seg_node: Test segmentation MRML node. test_segment_id: Segment ID within test segmentation. reference_seg_node: Reference (gold) segmentation MRML node. reference_segment_id: Segment ID within reference segmentation. volume_node: Volume node providing geometry. Returns: Dice coefficient (0-1). .. py:function:: to_dict() Convert to dictionary for JSON serialization. .. py:function:: record_stroke() Record metrics after a stroke. Args: test_seg_node: Test segmentation MRML node. test_segment_id: Segment ID within test segmentation. stroke_params: Parameters used for this stroke. Returns: StrokeRecord with computed metrics. .. py:function:: get_summary() Summarize stroke progression. Returns: Dictionary with summary statistics. .. py:function:: reset() Clear stroke history for a new trial.