-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add mode support and customizeable modes trying to get to the ability to customize modes #4877
Open
wayfarer3130
wants to merge
4
commits into
master
Choose a base branch
from
feat/mode-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,300
−1,128
Open
feat: Add mode support and customizeable modes trying to get to the ability to customize modes #4877
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
726e899
feat: Update how modes get defined to make them customizable
wayfarer3130 0c10fbc
Merge remote-tracking branch 'origin/master' into feat/mode-support
wayfarer3130 ef591c6
Fix some customization setup
wayfarer3130 2af08a7
Merge remote-tracking branch 'origin/master' into feat/mode-support
wayfarer3130 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
592 changes: 592 additions & 0 deletions
592
extensions/cornerstone/src/customizations/modeLongitudinalCustomizations.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const path = require('path'); | ||
const webpackCommon = require('./../../../.webpack/webpack.base.js'); | ||
const SRC_DIR = path.join(__dirname, '../src'); | ||
const DIST_DIR = path.join(__dirname, '../dist'); | ||
|
||
const ENTRY = { | ||
app: `${SRC_DIR}/index.ts`, | ||
}; | ||
|
||
module.exports = (env, argv) => { | ||
return webpackCommon(env, argv, { SRC_DIR, DIST_DIR, ENTRY }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const webpack = require('webpack'); | ||
const { merge } = require('webpack-merge'); | ||
const path = require('path'); | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
|
||
const pkg = require('./../package.json'); | ||
const webpackCommon = require('./../../../.webpack/webpack.base.js'); | ||
|
||
const ROOT_DIR = path.join(__dirname, './../'); | ||
const SRC_DIR = path.join(__dirname, '../src'); | ||
const DIST_DIR = path.join(__dirname, '../dist'); | ||
const ENTRY = { | ||
app: `${SRC_DIR}/index.ts`, | ||
}; | ||
|
||
module.exports = (env, argv) => { | ||
const commonConfig = webpackCommon(env, argv, { SRC_DIR, DIST_DIR, ENTRY }); | ||
|
||
return merge(commonConfig, { | ||
stats: { | ||
colors: true, | ||
hash: true, | ||
timings: true, | ||
assets: true, | ||
chunks: false, | ||
chunkModules: false, | ||
modules: false, | ||
children: false, | ||
warnings: true, | ||
}, | ||
optimization: { | ||
minimize: true, | ||
sideEffects: false, | ||
}, | ||
output: { | ||
path: ROOT_DIR, | ||
library: 'ohif-mode-longitudinal', | ||
libraryTarget: 'umd', | ||
libraryExport: 'default', | ||
filename: pkg.main, | ||
}, | ||
externals: [/\b(vtk.js)/, /\b(dcmjs)/, /\b(gl-matrix)/, /^@ohif/, /^@cornerstonejs/], | ||
plugins: [ | ||
new webpack.optimize.LimitChunkCountPlugin({ | ||
maxChunks: 1, | ||
}), | ||
// new MiniCssExtractPlugin({ | ||
// filename: './dist/[name].css', | ||
// chunkFilename: './dist/[id].css', | ||
// }), | ||
], | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Open Health Imaging Foundation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Measurement Tracking Mode | ||
|
||
|
||
|
||
## Introduction | ||
Measurement tracking mode allows you to: | ||
|
||
- Draw annotations and have them shown in the measurement panel | ||
- Create a report from the tracked measurement and export them as DICOM SR | ||
- Use already exported DICOM SR to re-hydrate the measurements in the viewer | ||
|
||
 | ||
|
||
## Workflow | ||
|
||
|
||
### Status Icon | ||
Each viewport has a left icon indicating whether the series within the viewport contains: | ||
|
||
- tracked measurement OR | ||
- untracked measurement OR | ||
- Structured Report OR | ||
- Locked (uneditable) Structured Report | ||
|
||
In the following, we will discuss each category. | ||
|
||
 | ||
|
||
### Tracked vs Untracked Measurements | ||
|
||
OHIF-v3 implements a workflow for measurement tracking that can be seen below. | ||
In summary, when you create an annotation, a prompt will be shown whether to start tracking or not. If you start the tracking, the annotation style will change to a solid line, and annotation details get displayed on the measurement panel. On the other hand, if you decline the tracking prompt, the measurement will be considered "temporary," and annotation style remains as a dashed line and not shown on the right panel, and cannot be exported. | ||
|
||
Below, you can see different icons that appear for a tracked vs. untracked series in OHIF-v3. | ||
|
||
|
||
 | ||
|
||
|
||
### Reading and Writing DICOM SR | ||
OHIF-v3 provides full support for reading, writing and mapping the DICOM Structured Report (SR) to interactable Cornerstone Tools. When you load an already exported DICOM SR into the viewer, you will be prompted whether to track the measurements for the series or not. | ||
|
||
|
||
 | ||
|
||
If you click Yes, DICOM SR measurements gets re-hydrated into the viewer and the series become a tracked series. However, If you say no and later decide to say track the measurements, you can always click on the SR button that will prompt you with the same message again. | ||
|
||
|
||
 | ||
|
||
The full workflow for saving measurements to SR and loading SR into the viewer is shown below. | ||
|
||
 | ||
|
||
|
||
### Loading DICOM SR into an Already Tracked Series | ||
|
||
If you have an already tracked series and try to load a DICOM SR measurements, you will be shown the following lock icon. This means that, you can review the DICOM SR measurement, manipulate image and draw "temporary" measurements; however, you cannot edit the DICOM SR measurement. | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../babel.config.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "@ohif/mode-support", | ||
"version": "3.10.0-beta.133", | ||
"description": "Support Class for Modes", | ||
"author": "OHIF", | ||
"license": "MIT", | ||
"repository": "OHIF/Viewers", | ||
"main": "dist/ohif-mode-longitudinal.js", | ||
"module": "src/index.ts", | ||
"engines": { | ||
"node": ">=14", | ||
"npm": ">=6", | ||
"yarn": ">=1.16.0" | ||
}, | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"clean": "shx rm -rf dist", | ||
"clean:deep": "yarn run clean && shx rm -rf node_modules", | ||
"dev": "cross-env NODE_ENV=development webpack --config .webpack/webpack.dev.js --watch --output-pathinfo", | ||
"dev:cornerstone": "yarn run dev", | ||
"build": "cross-env NODE_ENV=production webpack --config .webpack/webpack.prod.js", | ||
"build:package": "yarn run build", | ||
"start": "yarn run dev", | ||
"test:unit": "jest --watchAll", | ||
"test:unit:ci": "jest --ci --runInBand --collectCoverage --passWithNoTests" | ||
}, | ||
"peerDependencies": { | ||
"@ohif/core": "3.10.0-beta.133", | ||
"@ohif/extension-default": "3.10.0-beta.133" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.20.13", | ||
"i18next": "^17.0.3" | ||
}, | ||
"devDependencies": { | ||
"webpack": "5.94.0", | ||
"webpack-merge": "^5.7.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Allow this mode by excluding non-imaging modalities such as SR, SEG | ||
// Also, SM is not a simple imaging modalities, so exclude it. | ||
export const NON_IMAGE_MODALITIES = ['ECG', 'SEG', 'RTSTRUCT', 'RTPLAN', 'PR']; | ||
|
||
export const ohif = { | ||
layout: '@ohif/extension-default.layoutTemplateModule.viewerLayout', | ||
sopClassHandler: '@ohif/extension-default.sopClassHandlerModule.stack', | ||
thumbnailList: '@ohif/extension-default.panelModule.seriesList', | ||
wsiSopClassHandler: | ||
'@ohif/extension-cornerstone.sopClassHandlerModule.DicomMicroscopySopClassHandler', | ||
}; | ||
|
||
export const cornerstone = { | ||
measurements: '@ohif/extension-cornerstone.panelModule.panelMeasurement', | ||
segmentation: '@ohif/extension-cornerstone.panelModule.panelSegmentation', | ||
}; | ||
|
||
export const tracked = { | ||
measurements: '@ohif/extension-measurement-tracking.panelModule.trackedMeasurements', | ||
thumbnailList: '@ohif/extension-measurement-tracking.panelModule.seriesList', | ||
viewport: '@ohif/extension-measurement-tracking.viewportModule.cornerstone-tracked', | ||
}; | ||
|
||
export const dicomsr = { | ||
sopClassHandler: '@ohif/extension-cornerstone-dicom-sr.sopClassHandlerModule.dicom-sr', | ||
sopClassHandler3D: '@ohif/extension-cornerstone-dicom-sr.sopClassHandlerModule.dicom-sr-3d', | ||
viewport: '@ohif/extension-cornerstone-dicom-sr.viewportModule.dicom-sr', | ||
}; | ||
|
||
export const dicomvideo = { | ||
sopClassHandler: '@ohif/extension-dicom-video.sopClassHandlerModule.dicom-video', | ||
viewport: '@ohif/extension-dicom-video.viewportModule.dicom-video', | ||
}; | ||
|
||
export const dicompdf = { | ||
sopClassHandler: '@ohif/extension-dicom-pdf.sopClassHandlerModule.dicom-pdf', | ||
viewport: '@ohif/extension-dicom-pdf.viewportModule.dicom-pdf', | ||
}; | ||
|
||
export const dicomSeg = { | ||
sopClassHandler: '@ohif/extension-cornerstone-dicom-seg.sopClassHandlerModule.dicom-seg', | ||
viewport: '@ohif/extension-cornerstone-dicom-seg.viewportModule.dicom-seg', | ||
}; | ||
|
||
export const dicomPmap = { | ||
sopClassHandler: '@ohif/extension-cornerstone-dicom-pmap.sopClassHandlerModule.dicom-pmap', | ||
viewport: '@ohif/extension-cornerstone-dicom-pmap.viewportModule.dicom-pmap', | ||
}; | ||
|
||
export const dicomRT = { | ||
viewport: '@ohif/extension-cornerstone-dicom-rt.viewportModule.dicom-rt', | ||
sopClassHandler: '@ohif/extension-cornerstone-dicom-rt.sopClassHandlerModule.dicom-rt', | ||
}; | ||
|
||
export const extensionDependenciesBasic = { | ||
// Can derive the versions at least process.env.from npm_package_version | ||
'@ohif/extension-default': '^3.0.0', | ||
'@ohif/extension-cornerstone': '^3.0.0', | ||
'@ohif/extension-cornerstone-dicom-sr': '^3.0.0', | ||
'@ohif/extension-cornerstone-dicom-seg': '^3.0.0', | ||
'@ohif/extension-cornerstone-dicom-pmap': '^3.0.0', | ||
'@ohif/extension-cornerstone-dicom-rt': '^3.0.0', | ||
'@ohif/extension-dicom-pdf': '^3.0.1', | ||
'@ohif/extension-dicom-video': '^3.0.1', | ||
}; | ||
|
||
export const extensionDependenciesLongitudinal = { | ||
...extensionDependenciesBasic, | ||
'@ohif/extension-measurement-tracking': '^3.0.0', | ||
}; | ||
|
||
export function isValidMode({ modalities }) { | ||
const nonImageModalities = this.nonImageModalities || NON_IMAGE_MODALITIES; | ||
const modalities_list = modalities.split('\\'); | ||
|
||
// Exclude non-image modalities | ||
return { | ||
valid: !!modalities_list.filter(modality => nonImageModalities.indexOf(modality) === -1).length, | ||
description: `The mode does not support studies that ONLY include the following modalities: ${nonImageModalities.join(', ')}`, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedrokohler - to customize the toolbar, you will also need these two lines, and to create a new custom section that extends the default tools/buttons.