Using cornerstone-tools, After I load a image, I start to draw some annotations such as angle, rectangle, arrow.
I´d like to know a method to clear all annotations. I try the next but no look
removeAll(element) {
cornerstoneTools.state.tools.forEach(function (tool) {
const toolState = cornerstoneTools.getToolState(element, tool.name)
if (toolState) {
// Modifying in a foreach? Probably not ideal
cornerstoneTools.toolState.data.forEach(function (data) {
cornerstoneTools.removeToolState(element, tool.name, data)
})
}
})
cornerstone.updateImage(element)
},
To solve this issue, you can use the
clearToolStatefunction. You have several examples and issues concerning this problem, that you may follow. However, it seems a good option to use theclearToolStatefunction in your case. TheclearToolStatefunction will remove all states from the state manager corresponding to the name and element of that tool.Indeed, the documentation describes the
clearToolStatefunction as:It is also important to understand how does [1, 2] the
cornerstoneToolstore its values. Additionally, you can also follow similar answers when using a new tool or function.References
[1] Francisco Maria Calisto, Carlos Santiago, Nuno Nunes, and Jacinto C. Nascimento. 2021. Introduction of human-centric AI assistant to aid radiologists for multimodal breast image classification. International Journal of Human-Computer Studies 150, 102607. https://doi.org/10.1016/j.ijhcs.2021.102607
[2] Francisco Maria Calisto, Nuno Nunes, and Jacinto C. Nascimento. 2020. BreastScreening. Proceedings of the International Conference on Advanced Visual Interfaces. https://doi.org/10.1145/3399715.3399744