Provides a simple, extensible framework for creating tools on top of Cornerstone.js. Includes common tool implementations, and leverages DICOM metadata (when available) for advanced functionality.
[**Read The Docs**](https://tools.cornerstonejs.org/) | [Edit the docs](https://github.com/cornerstonejs/cornerstoneTools/edit/master/docs/)Building one or two tools on top of Cornerstone.js is not that difficult. However, as the number of tools grow, you begin to encounter difficult problems:
enabled element
sThis library solves these problems in a highly pluggable and extensible way.
cornerstone-tools
is a light-weight solution for building Tools on top of Cornerstone.js. It's only dependencies are libraries within the Cornerstone family. Instead of trying to "do everything" it aims to be extensible and pluggable to aid in the rapid development of new tools. Ideally, tools created using cornerstone-tools
can be easily shared, allowing for the creation of a broader ecosystem.
Below is a simplified example of creating a tool by extending cornerstone-tool
's BaseTool
class.
import cornerstone from 'cornerstone-core';
import { BaseTool } from 'cornerstone-tools';
import basicLevelingStrategy from '...';
export default class WwwcTool extends BaseTool {
constructor(configuration = {}) {
const defaultConfig = {
name: 'Wwwc',
strategies: { basicLevelingStrategy },
supportedInteractionTypes: ['Mouse', 'Touch'],
configuration: {
orientation: 0,
},
};
const initialConfiguration = Object.assign(defaultConfig, configuration);
super(initialConfiguration);
}
mouseDragCallback(evt) {
this.applyActiveStrategy(evt);
cornerstone.setViewport(evt.detail.element, evt.detail.viewport);
}
touchDragCallback(evt) {
evt.stopImmediatePropagation();
this.applyActiveStrategy(evt);
cornerstone.setViewport(evt.detail.element, evt.detail.viewport);
}
}
This module is distributed via npm which is bundled with node and
should be installed as one of your project's dependencies
:
// To install the newest version
npm install --save cornerstone-tools
// To install the legacy version (2.4.x branch)
npm install --save cornerstone-tools@2
This library has peerDependencies
listings for:
hammerjs
- Better touch supportcornerstone-core
cornerstone-math
- Simplifies and provides shared complex tool math logiccornerstone-web-image-loader
- JPEG/PNG imagescornerstone-wado-image-loader
- DICOM images; also parses tags for tool useIf you need to support the IE11
Browser, you will need to provide polyfills as needed. Our BrowserList target:
"browserslist": [
"> 1%",
"IE 11",
"not dead",
"not IE < 11",
"not op_mini all"
]
Setting up and configuring cornerstone-tools
's depency can be the biggest hurdle to getting started. Be sure to check out our docs for assistance.
The latest major version has just been published. We are still flushing out our examples. If you have anything you would like to see documented, or you want a specific example from version 2 ported, either create an issue or make a pull request ^_^
A huge thanks to tool authors, like @sisobus, for sharing their work with the community!
Thanks goes to these people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Looking to contribute? Look for the Good First Issue label.
Please file an issue for bugs, missing documentation, or unexpected behavior.
Please file an issue to suggest new features. Vote on feature requests by adding a π. This helps maintainers prioritize what to work on.
For questions related to using the library, please visit our support community, or file an issue on GitHub.
MIT