Saving and retrieval of annotation/measurement data in json format

How can i save annotation/measurements to my backend and and retrieve it (in json preferrably) to be rendered back on the dicom in the viewer? Is there any better or easier way to achieve this?

  • I am able to save the annotation data to my backend from the MeasurementService.ts file. But when i load this json back and pass the params to the annotationToMeasurement() method in MeasurementService, it throws errors like - source undefined and no mappings present. Any pointers or references to make this work would be really appreciated.

  • Version : Viewers-3.8.0-beta.81

  • Below is how the code hydrateAnnotations looks like.

 hydrateAnnotations(): void {
  
    axios
      .get('http://localhost:9191/dicom/get-measurement')
      .then(response => {
        const annotations = response.data;
        log.info('json: ', response.data);

        annotations.measurementList.forEach(annotation => {
          try {
            this.annotationToMeasurement(
              annotation.source,
              // this.createSource(annotation.source.name, annotation.source.version),
              annotation.toolName,
              annotation,
              false
            );
          } catch (error) {
            console.error('Failed to add annotation to viewer:', error);
          }
        });
      })
      .catch(error => {
        console.error('Error fetching data:', error);
      });
  }

This is really highly requested, so will create a faq for it soon

@alireza It is, I mostly went through all the issues in github but did not find any concrete workaround.
Please do create a faq, also pointers on where to look out for your post on this would be helpful.

We have a cornerstone examples to show you basics

https://www.cornerstonejs.org/live-examples/dynamicallyaddannotations

You can see how to do it in OHIF like this