Skip to content

Instantly share code, notes, and snippets.

@nicolay-r
Last active March 20, 2026 16:45
Show Gist options
  • Select an option

  • Save nicolay-r/acaa75c183ee47868c3feddbf92433f7 to your computer and use it in GitHub Desktop.

Select an option

Save nicolay-r/acaa75c183ee47868c3feddbf92433f7 to your computer and use it in GitHub Desktop.
Implementation for measurements importing in OHIF
// 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