-
Notifications
You must be signed in to change notification settings - Fork 448
fix(cornerstone-dicom-sr): Freehand SR hydration support #1160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
15e15df
eb51a04
0beaf01
cd6a4c9
1b408ab
ba80aa2
835d614
c2bbfc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,31 @@ const { pointCanProjectOnLine } = polyline; | |
| const { EPSILON } = CONSTANTS; | ||
|
|
||
| const PARALLEL_THRESHOLD = 1 - EPSILON; | ||
|
|
||
| function calculatePerimeter(polyline, closed) { | ||
| let perimeter = 0; | ||
|
|
||
| for (let i = 0; i < polyline.length - 1; i++) { | ||
| const point1 = polyline[i]; | ||
| const point2 = polyline[i + 1]; | ||
|
|
||
| perimeter += Math.sqrt( | ||
| Math.pow(point2[0] - point1[0], 2) + Math.pow(point2[1] - point1[1], 2) | ||
| ); | ||
| } | ||
|
|
||
| if (closed) { | ||
| const firstPoint = polyline[0]; | ||
| const lastPoint = polyline[polyline.length - 1]; | ||
| perimeter += Math.sqrt( | ||
| Math.pow(lastPoint[0] - firstPoint[0], 2) + | ||
| Math.pow(lastPoint[1] - firstPoint[1], 2) | ||
| ); | ||
| } | ||
|
|
||
| return perimeter; | ||
| } | ||
|
|
||
| /** | ||
| * PlanarFreehandROITool lets you draw annotations that define an arbitrarily drawn region. | ||
| * You can use the PlanarFreehandROITool in all perpendicular views (axial, sagittal, coronal), | ||
|
|
@@ -243,7 +268,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool { | |
| */ | ||
| epsilon: 0.1, | ||
| }, | ||
| calculateStats: false, | ||
| calculateStats: true, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we set it back to false, it is brutal to calculate stats on each frame
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The stats were not being calculated / displayed. Maybe the problem is the tool implementation or when the stats are calculated? |
||
| getTextLines: defaultGetTextLines, | ||
| statsCalculator: BasicStatsCalculator, | ||
| }, | ||
|
|
@@ -294,7 +319,9 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool { | |
| ); | ||
|
|
||
| this.activateDraw(evt, annotation, viewportIdsToRender); | ||
|
|
||
| evt.preventDefault(); | ||
|
|
||
| triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender); | ||
|
|
||
| return annotation; | ||
|
|
@@ -350,6 +377,8 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool { | |
| } else { | ||
| this.activateOpenContourEdit(evt, annotation, viewportIdsToRender); | ||
| } | ||
|
|
||
| evt.preventDefault(); | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -536,16 +565,21 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool { | |
| annotation.data.handles.points.length = 0; | ||
| }; | ||
|
|
||
| return <PlanarFreehandROIAnnotation>csUtils.deepMerge(contourAnnotation, { | ||
| data: { | ||
| contour: { | ||
| polyline: [<Types.Point3>[...worldPos]], | ||
| const annotation = <PlanarFreehandROIAnnotation>csUtils.deepMerge( | ||
| contourAnnotation, | ||
| { | ||
| data: { | ||
| contour: { | ||
| polyline: [<Types.Point3>[...worldPos]], | ||
| }, | ||
| label: '', | ||
| cachedStats: {}, | ||
| }, | ||
| label: '', | ||
| cachedStats: {}, | ||
| }, | ||
| onInterpolationComplete, | ||
| }); | ||
| onInterpolationComplete, | ||
| } | ||
| ); | ||
|
|
||
| return annotation; | ||
| } | ||
|
|
||
| protected getAnnotationStyle(context) { | ||
|
|
@@ -682,7 +716,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool { | |
| ) => { | ||
| const { data } = annotation; | ||
| const { cachedStats } = data; | ||
| const { polyline: points } = data.contour; | ||
| const { polyline: points, closed } = data.contour; | ||
|
|
||
| const targetIds = Object.keys(cachedStats); | ||
|
|
||
|
|
@@ -835,6 +869,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool { | |
| cachedStats[targetId] = { | ||
| Modality: metadata.Modality, | ||
| area, | ||
| perimeter: calculatePerimeter(canvasCoordinates, closed), | ||
| mean: stats.mean?.value, | ||
| max: stats.max?.value, | ||
| stdDev: stats.stdDev?.value, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.