code: function addImageIdSpecificToolState(element, toolType, data) {
      const enabledElement = external.cornerstone.getEnabledElement(element);
  
      // If we don't have an image for this element exit early
      if (!enabledElement.image) {
        return;
      }
  
      // If we don't have any tool state for this imageId, add an empty object
      if (toolState.hasOwnProperty(enabledElement.image.imageId) === false) {
        toolState[enabledElement.image.imageId] = {};
      }
  
      const imageIdToolState = toolState[enabledElement.image.imageId];
  
      // If we don't have tool state for this type of tool, add an empty object
      if (imageIdToolState.hasOwnProperty(toolType) === false) {
        imageIdToolState[toolType] = {
          data: [],
        };
      }
  
      const toolData = imageIdToolState[toolType];
  
      // Finally, add this new tool to the state
      toolData.data.push(data);
    }
docs: Here we add tool state, this is done by tools as well As modules that restore saved state