Skip to content
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

Add & toggle shapes/drawings programmatically #1363

Closed
beckmarc opened this issue May 9, 2023 · 10 comments
Closed

Add & toggle shapes/drawings programmatically #1363

beckmarc opened this issue May 9, 2023 · 10 comments
Labels
question Further information is requested
Milestone

Comments

@beckmarc
Copy link

beckmarc commented May 9, 2023

I'm currently developing an application to view brain scans and need to show areas where a stroke is suspected to be. I have multiple AI models that produce different results so I need to be able to programmatically toggle them on or off. I'm using angular-dwv to be more specific.

My first approach would be to create a custom shape that connects some points to enclose a specific area of interest. However, I have to say that I really struggle with understanding the documentation. My main issue is that I don't know what all methods and classes do and how they are interconnected since there is no linking with parameters and return types. The examples also hardly scratch the surface about what's possible.

Can someone give me some advice how I can better understand the library? Also if anybody could simply show me how to create a simple shape like a Line and how to add this to a dwv.App object it would be really great.

@ivmartel ivmartel added the question Further information is requested label May 11, 2023
@ivmartel ivmartel added this to the 0.32.0 milestone May 11, 2023
@ivmartel
Copy link
Owner

Draw shapes come from Konva, check out their doc to understand how to create one (for example the line tutorial). dwv can then load the shape from a state.json file.

Regarding types, I'm working on it! See #669

Related (?): #1366

@beckmarc
Copy link
Author

@ivmartel Yes, I think that #1366 and me are trying to accomplish the same task which is adding annotated regions to the dicom viewer. Maybe that is an idea for a new feature? Would be really handy to highlight certain regions on the dicom viewer and modify them programmatically.

@ivmartel
Copy link
Owner

I'm not sure I understand you... What do you mean by highlight? What type of modifications?

@beckmarc
Copy link
Author

I have serval AI models that predict wether a stroke is present based on a NCCT image or not. In addition, my team has created explainable AI models that show the important regions for the AI to make this decision. These results we want to present to the user by overlaying them on the original image. Like here e.g.

1CanonMedicalAutoStrokeAPNoncontrastCTASPECTS

The representation of the highlighted areas is not fixed though. The backend just returns a mask which I can use to calculate the highlighted regions on the dicom viewer.

@ivmartel
Copy link
Owner

Ok, so the green drawings are standard brain regions that have been adapted to the image and according to activations in that image (pink zones), you want to highlight the corresponding regions by making them red. Is that it?

@beckmarc01
Copy link

That's just an example image I searched to illustrate what I mean but yes in essence that's it. So showing the activated regions (with different levels of importance maybe) and the possibility to load them and toggle them on or off.

@ivmartel
Copy link
Owner

Konva shapes then seem more appropriate. Check out this demo viewer, you can draw shapes on the image and then change some of their properties from the draw list page (pencil icon in the top tool bar).

@ivmartel
Copy link
Owner

ivmartel commented Jun 2, 2023

I hope I answered your question. Feel free to comment if you found limitations with the current implementation. Closing for now.

@MehmetStead
Copy link

we would like to draw programmatically, using the API? any examples for this?

@ivmartel
Copy link
Owner

Check out the state tests, they contain example states: https://github.com/ivmartel/dwv/tree/develop/tests/state

@ivmartel ivmartel reopened this Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants