ivmartel / dwv

DICOM Web Viewer: open source zero footprint medical image library.
https://ivmartel.github.io/dwv/
GNU General Public License v3.0
1.63k stars 588 forks source link

create JSON in dwv state.json format from user coordinates #1366

Closed roshtha closed 1 year ago

roshtha commented 1 year ago

Hello all,

I have an AI service through which I get annotation coordinates for medical images. Now I want to create dwv JSON format (state.json) out of these annotation coordinates for rendering the annotation rectangular boxes on images. I know about JSON-java libraries through which I can create the required JSON format, store it in the database, and render annotation on images by loading state.json in the dwv image viewer. But I would like to know if any other approach or libraries dwv provides for creating the state.json format from user data.

Thanks.

ivmartel commented 1 year ago

If you are looking for a utility that takes, for example, a point list and creates the state file, dwv does not provide such a tool. As a side note, not sure if it can interest you, dwv supports loading DICOM Seg files (image representation of a segmentation).

beckmarc commented 1 year ago

@ivmartel DICOM segmentation files would be also suited for this case. For example, we could first use pydicom-seg to create the regions of interest that are outputted by the AI on the backend. Then on the frontend we could load the dicom seg files into the dwv viewer as well. However, I couldn't find any example or any method in the documentation on how to load segmentation files into the DWV.

Would be very kind if you could show us how to load DICOM seg files and display them. Is there also the possibility to toggle the segmentation file on and off ?

ivmartel commented 1 year ago

Segmentation files are loaded like any other DICOM file. The code will switch according to modality and load the SEG into an Image. The difference being that pixels with intensity 0 are transparent. Just load a base image file and then a SEG one, it should show up in a new layer as an overlay. You can then adjust the transparency of the overlay.

You can find some example data at dicom4qi datasets. The demo viewer allows you to change the transparency of data.

ivmartel commented 1 year ago

Closing for now, feel free to comment if you need.