Last active
March 20, 2026 16:45
-
-
Save nicolay-r/acaa75c183ee47868c3feddbf92433f7 to your computer and use it in GitHub Desktop.
Implementation for measurements importing in OHIF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // measurement -- is an item from measurementService.getMeasurements() | |
| export function importMeasurement(measurementService, measurement) { | |
| const CORNERSTONE_3D_TOOLS_SOURCE_NAME = 'Cornerstone3DTools'; | |
| const CORNERSTONE_3D_TOOLS_SOURCE_VERSION = '0.1'; | |
| const source = measurementService.getSource( | |
| CORNERSTONE_3D_TOOLS_SOURCE_NAME, | |
| CORNERSTONE_3D_TOOLS_SOURCE_VERSION | |
| ); | |
| const mappings = measurementService.getSourceMappings( | |
| CORNERSTONE_3D_TOOLS_SOURCE_NAME, | |
| CORNERSTONE_3D_TOOLS_SOURCE_VERSION | |
| ); | |
| const annotationType = measurement.metadata.toolName; | |
| const annotation = { | |
| annotationUID: measurement.uid, | |
| metadata: measurement.metadata, | |
| data: { | |
| cachedStats: measurement.data, | |
| handles: { | |
| activeHandleIndex: null, | |
| points: measurement.points, | |
| }, | |
| }, | |
| }; | |
| const matchingMapping = mappings.find(m => m.annotationType === annotationType); | |
| measurementService.addRawMeasurement( | |
| source, | |
| annotationType, | |
| { annotation }, | |
| matchingMapping.toMeasurementSchema | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment