cornerstoneTools v3.0 comes with a new plugin architecture, so that one can easily drop new tools and modules into cornerstoneTools. This comes with the advantage of not having to maintain a fork of the entire codebase should you wish to include one other tool. However, if you think a tool you have developed would be valued by the wider cornerstone community, please consider submitting a pull request and contributing it back.

This documentation is for an unreleased (still in testing) version of Cornerstone Tools. Until it is released, its API may experience frequent breaking changes. The current stable release can be found here.

Store Modules

A store module is a namespaced storage object in the store that contains the following properties:

Property Requirement Description
state Mandatory An object that stores the module's current state. There is no vigorous structure your state must follow, and you may structure it however you wish. We recommend as many top level primitives as possible, however getters can be used for more complicated queries.
getters Optional An object comprised of functions that query state. Getters can be used for more complex queries of the state (e.g. to yield a value that references a specific cornerstone enabled element). Top level primitives that require no calculation should instead by accessed by const property =, as this reduces boilerplate in implementation code.
setters Optional An object comprised of functions that modify state. Setters can be used for more complex input (e.g. push object x to array y). Top level primitives should be set by = value, as this reduces boilerplate in implementation code.
onRegisterCallback (name) Optional This function is called when the module is registered to the cornerstoneTools store. It is used to perform any global initialization the modules requires. The name the module was given upon registration is passed to the callback.
enabledElementCallback (enabledElement) Optional This function is called once for each enabledElement upon registering the module, and again any time a new enabledElement is added to the cornerstoneTools instance. The enabledElement is passed to the callback.

Most modules will have getters and setters, unless they only contain primitives (e.g. the modules state is only comprised of boolean toggles).

Creating a 3rd party module

Here is a simple toy example of a module with state, setters and getters:

// helloWorldModule.js

const state = {
  isPolite: true
  responses: {
    polite: 'Hello World!',
    rude: 'Go away, World.'

const setters = {
  politeResponse: (response) => {
    state.responses.polite = response;
  rudeResponse: (response) => {
    state.responses.rude = response;

const getters = {
  response: () => {
    if (state.isPolite) {
      return state.responses.polite;
    } else {
      return state.response.rude;

function onRegisterCallback () {
  console.log('Hello onRegisterCallback.');

function enabledElementCallback (enabledElement) {
  console.log(`hello element ${enabledElement.uuid}.`)

export default {

A more complete and realistic example of a module including both optional callbacks can be found in src/store/modules/brushModule.js.

Registering a 3rd party module

Once you have built your module you need to register it. For 3rd party modules you can do this after you initialize cornerstoneTools, as follows.

import helloWorldModule from './helloWorldModule.js';

const cTools = cornerstoneTools.init();, 'helloWorld');

The registerModule function takes two arguments, the module itself, and the name for it to be referenced by. Once registered, onRegisterCallback is called once, followed by enabledElementCallback for each enabled element.

The module can then be accessed by

results matching ""

    No results matching ""