code: function setToolModeForElement(mode, changeEvent, element, toolName, options) {
    const tool = getToolForElement(element, toolName);
  
    if (!tool) {
      logger.warn('Unable to find tool "%s" for enabledElement', toolName);
  
      return;
    }
  
    options = _getNormalizedOptions(options);
  
    // Keep the same if not an array (undefined)
    // Reset if empty array
    // Merge if array contains any bindings
    if (
      Array.isArray(options.mouseButtonMask) &&
      options.mouseButtonMask.length !== 0 &&
      Array.isArray(tool.options.mouseButtonMask)
    ) {
      options.mouseButtonMask = options.mouseButtonMask
        .concat(tool.options.mouseButtonMask)
        .reduce((acc, m) => {
          if (acc.indexOf(m) === -1) {
            acc.push(m);
          }
  
          return acc;
        }, []);
    }
  
    // Set mode & options
    tool.mode = mode;
    tool.mergeOptions(options);
  
    // Call tool's hook for this event, if one exists
    if (tool[`${mode}Callback`]) {
      tool[`${mode}Callback`](element, options);
    }
  
    // Emit event indicating tool state change
    if (changeEvent) {
      const statusChangeEventData = {
        options,
        toolName,
        type: changeEvent,
      };
  
      triggerEvent(element, changeEvent, statusChangeEventData);
    }
  
    // Trigger Update
    // Todo: don't error out if image hasn't been loaded...
    // Cornerstone.updateImage(element);
  }
docs: An internal method that helps make sure we change tool mode in a consistent
  way
  @private
  @function setToolModeForElement
  
  @param {string} mode
  @param {string} changeEvent
  @param {HTMLElement} element
  @param {string} toolName
  @param {(Object|number[]|number)} options
  @returns {undefined}