feat: Add a new hanging protocol @ohif/mn (#3305)
* feat: Add a new hanging protocol @ohif/mn * Add @ohif/seg example * PR comments and a couple more fixes to make things cleaner * PR comment * Added an example to cause the PR checks to rerun
This commit is contained in:
1 parent
6cf271d006
commit
c508a2b6bc
17 files changed
+184
-358
No files matched your search
@@ -0,0 +1,78 @@
|
||||
import { Types } from '@ohif/core';
|
||||
|
||||
const segProtocol: Types.HangingProtocol.Protocol = {
|
||||
id: '@ohif/seg',
|
||||
// Don't store this hanging protocol as it applies to the currently active
|
||||
// display set by default
|
||||
// cacheId: null,
|
||||
hasUpdatedPriorsInformation: false,
|
||||
name: 'Segmentations',
|
||||
// Just apply this one when specifically listed
|
||||
protocolMatchingRules: [],
|
||||
toolGroupIds: ['default'],
|
||||
// -1 would be used to indicate active only, whereas other values are
|
||||
// the number of required priors referenced - so 0 means active with
|
||||
// 0 or more priors.
|
||||
numberOfPriorsReferenced: 0,
|
||||
// Default viewport is used to define the viewport when
|
||||
// additional viewports are added using the layout tool
|
||||
defaultViewport: {
|
||||
viewportOptions: {
|
||||
viewportType: 'stack',
|
||||
toolGroupId: 'default',
|
||||
allowUnmatchedView: true,
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'segDisplaySetId',
|
||||
matchedDisplaySetsIndex: -1,
|
||||
},
|
||||
],
|
||||
},
|
||||
displaySetSelectors: {
|
||||
segDisplaySetId: {
|
||||
seriesMatchingRules: [
|
||||
{
|
||||
attribute: 'Modality',
|
||||
constraint: {
|
||||
equals: 'SEG',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
stages: [
|
||||
{
|
||||
name: 'Segmentations',
|
||||
viewportStructure: {
|
||||
layoutType: 'grid',
|
||||
properties: {
|
||||
rows: 1,
|
||||
columns: 1,
|
||||
},
|
||||
},
|
||||
viewports: [
|
||||
{
|
||||
viewportOptions: { allowUnmatchedView: true },
|
||||
displaySets: [
|
||||
{
|
||||
id: 'segDisplaySetId',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function getHangingProtocolModule() {
|
||||
return [
|
||||
{
|
||||
name: segProtocol.id,
|
||||
protocol: segProtocol,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export default getHangingProtocolModule;
|
||||
export { segProtocol };
|
||||
@@ -5,6 +5,7 @@ import { Types } from '@ohif/core';
|
||||
|
||||
import getSopClassHandlerModule from './getSopClassHandlerModule';
|
||||
import PanelSegmentation from './panels/PanelSegmentation';
|
||||
import getHangingProtocolModule from './getHangingProtocolModule';
|
||||
|
||||
const Component = React.lazy(() => {
|
||||
return import(
|
||||
@@ -79,6 +80,8 @@ const extension = {
|
||||
* Examples include the default sop class handler provided by the default extension
|
||||
*/
|
||||
getSopClassHandlerModule,
|
||||
|
||||
getHangingProtocolModule,
|
||||
};
|
||||
|
||||
export default extension;
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Types } from '@ohif/core';
|
||||
|
||||
const mpr: Types.HangingProtocol.Protocol = {
|
||||
id: 'mpr',
|
||||
name: 'Multi-Planar Reconstruction',
|
||||
locked: true,
|
||||
hasUpdatedPriorsInformation: false,
|
||||
name: 'mpr',
|
||||
createdDate: '2021-02-23T19:22:08.894Z',
|
||||
modifiedDate: '2023-02-17',
|
||||
createdDate: '2021-02-23',
|
||||
modifiedDate: '2023-04-03',
|
||||
availableTo: {},
|
||||
editableBy: {},
|
||||
// Unknown number of priors referenced - so just match any study
|
||||
@@ -303,7 +304,7 @@ const mprAnd3DVolumeViewport = {
|
||||
function getHangingProtocolModule() {
|
||||
return [
|
||||
{
|
||||
name: 'mpr',
|
||||
name: mpr.id,
|
||||
protocol: mpr,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -171,7 +171,7 @@ const commandsModule = ({
|
||||
reset = false,
|
||||
}: HangingProtocolParams): boolean => {
|
||||
try {
|
||||
// Stores in the state the reuseID to displaySetUID mapping
|
||||
// Stores in the state the display set selector id to displaySetUID mapping
|
||||
// Pass in viewportId for the active viewport. This item will get set as
|
||||
// the activeViewportId
|
||||
const state = viewportGridService.getState();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import hpMNGrid from './hpMNGrid';
|
||||
|
||||
const defaultProtocol = {
|
||||
id: 'default',
|
||||
locked: true,
|
||||
@@ -92,211 +94,6 @@ const defaultProtocol = {
|
||||
],
|
||||
createdDate: '2021-02-23T18:32:42.850Z',
|
||||
},
|
||||
|
||||
// This is an example of a 2x2 layout that requires at least 2 viewports
|
||||
// filled to be navigatable to
|
||||
{
|
||||
name: '2x2',
|
||||
// Indicate that the number of viewports needed is 2 filled viewports,
|
||||
// but that 4 viewports are preferred.
|
||||
stageActivation: {
|
||||
enabled: {
|
||||
minViewportsMatched: 4,
|
||||
},
|
||||
passive: {
|
||||
minViewportsMatched: 2,
|
||||
},
|
||||
},
|
||||
|
||||
viewportStructure: {
|
||||
layoutType: 'grid',
|
||||
properties: {
|
||||
rows: 2,
|
||||
columns: 2,
|
||||
},
|
||||
},
|
||||
viewports: [
|
||||
{
|
||||
viewportOptions: {
|
||||
toolGroupId: 'default',
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
matchedDisplaySetsIndex: 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
viewportOptions: {
|
||||
toolGroupId: 'default',
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
matchedDisplaySetsIndex: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
viewportOptions: {
|
||||
toolGroupId: 'default',
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
matchedDisplaySetsIndex: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
viewportOptions: {},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
matchedDisplaySetsIndex: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
name: '3x1',
|
||||
// Indicate that the number of viewports needed is 2 filled viewports,
|
||||
// but that 4 viewports are preferred.
|
||||
stageActivation: {
|
||||
enabled: {
|
||||
minViewportsMatched: 3,
|
||||
},
|
||||
},
|
||||
|
||||
viewportStructure: {
|
||||
layoutType: 'grid',
|
||||
properties: {
|
||||
rows: 1,
|
||||
columns: 3,
|
||||
},
|
||||
},
|
||||
viewports: [
|
||||
{
|
||||
viewportOptions: {
|
||||
toolGroupId: 'default',
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
matchedDisplaySetsIndex: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
viewportOptions: {
|
||||
toolGroupId: 'default',
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
matchedDisplaySetsIndex: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
viewportOptions: {},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// This is an example of a layout with more than one element in it
|
||||
// It can be navigated to using , and . (prev/next stage)
|
||||
{
|
||||
name: '2x1',
|
||||
// Indicate that the number of viewports needed is 1 filled viewport,
|
||||
// but that 2 viewports are preferred.
|
||||
stageActivation: {
|
||||
enabled: {
|
||||
minViewportsMatched: 3,
|
||||
},
|
||||
},
|
||||
|
||||
viewportStructure: {
|
||||
layoutType: 'grid',
|
||||
properties: {
|
||||
rows: 1,
|
||||
columns: 2,
|
||||
},
|
||||
},
|
||||
viewports: [
|
||||
{
|
||||
viewportOptions: {
|
||||
toolGroupId: 'default',
|
||||
// initialImageOptions: {
|
||||
// index: 180,
|
||||
// preset: 'middle', // 'first', 'last', 'middle'
|
||||
// },
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
// Shows the second index of this image set
|
||||
matchedDisplaySetsIndex: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
viewportOptions: {},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
name: '2x1',
|
||||
// Indicate that the number of viewports needed is 1 filled viewport,
|
||||
// but that 2 viewports are preferred.
|
||||
stageActivation: {
|
||||
enabled: {
|
||||
minViewportsMatched: 3,
|
||||
},
|
||||
},
|
||||
|
||||
viewportStructure: {
|
||||
layoutType: 'grid',
|
||||
properties: {
|
||||
rows: 2,
|
||||
columns: 1,
|
||||
},
|
||||
},
|
||||
viewports: [
|
||||
{
|
||||
viewportOptions: {},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
// Shows the second index of this image set
|
||||
matchedDisplaySetsIndex: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
viewportOptions: {},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -306,6 +103,11 @@ function getHangingProtocolModule() {
|
||||
name: defaultProtocol.id,
|
||||
protocol: defaultProtocol,
|
||||
},
|
||||
// Create a MxN hanging protocol available by default
|
||||
{
|
||||
name: hpMNGrid.id,
|
||||
protocol: hpMNGrid,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
import { Types } from '@ohif/core';
|
||||
|
||||
/**
|
||||
* This hanging protocol has multiple stages, which are enabled when
|
||||
* there are enough display sets with images to fill the stage, and
|
||||
* are passive when there is at least one display set.
|
||||
* Enabled display sets are navigated to by default, while passive ones
|
||||
* are navigated to manually using the ctrl+end keyboard shortcut.
|
||||
* This hanging protocol can be activated on the primary mode by directly
|
||||
* referencing it in a URL or by directly including it within a mode, e.g.:
|
||||
* `&hangingProtocolId=@ohif/mnGrid` added to the viewer URL
|
||||
* It is not included in the viewer mode by default.
|
||||
*/
|
||||
const hpMN: Types.HangingProtocol.Protocol = {
|
||||
hasUpdatedPriorsInformation: false,
|
||||
id: '@ohif/hp-extension.mn',
|
||||
description: 'Has various hanging protocol layouts for use in testing',
|
||||
id: '@ohif/mnGrid',
|
||||
description: 'Has various hanging protocol grid layouts',
|
||||
name: '2x2',
|
||||
protocolMatchingRules: [
|
||||
{
|
||||
id: 'OneOrMoreSeries',
|
||||
weight: 1,
|
||||
weight: 25,
|
||||
attribute: 'numberOfDisplaySetsWithImages',
|
||||
constraint: {
|
||||
greaterThan: 1,
|
||||
greaterThan: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -32,6 +31,15 @@ const hpMN: Types.HangingProtocol.Protocol = {
|
||||
greaterThan: { value: 0 },
|
||||
},
|
||||
},
|
||||
// This display set will select the specified items by preference
|
||||
// It has no affect if nothing is specified in the URL.
|
||||
{
|
||||
attribute: 'isDisplaySetFromUrl',
|
||||
weight: 10,
|
||||
constraint: {
|
||||
equals: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -142,7 +150,6 @@ const hpMN: Types.HangingProtocol.Protocol = {
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
reuseId: '0-0',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -153,9 +160,8 @@ const hpMN: Types.HangingProtocol.Protocol = {
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
id: 'defaultDisplaySetId',
|
||||
matchedDisplaySetsIndex: 1,
|
||||
id: 'defaultDisplaySetId',
|
||||
reuseId: '1-0',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -166,9 +172,8 @@ const hpMN: Types.HangingProtocol.Protocol = {
|
||||
},
|
||||
displaySets: [
|
||||
{
|
||||
matchedDisplaySetsIndex: 2,
|
||||
id: 'defaultDisplaySetId',
|
||||
reuseId: '0-1',
|
||||
matchedDisplaySetsIndex: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -1,5 +0,0 @@
|
||||
export default (study, extraData) => {
|
||||
const ret = extraData?.displaySets?.filter(ds => ds.numImageFrames>0)?.length;
|
||||
console.log("number of display sets with images", ret);
|
||||
return ret;
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export default (study, extraData) => extraData?.displaySets?.map(ds => ds.SeriesDescription);
|
||||
@@ -38,12 +38,12 @@ const findingsContextMenu = {
|
||||
},
|
||||
|
||||
// The example below shows how to include a delegating sub-menu,
|
||||
// Only available on the @ohif/hp-extension.mn hanging protocol
|
||||
// Only available on the @ohif/mnGrid hanging protocol
|
||||
// To demonstrate, select the 3x1 layout from the protocol menu
|
||||
// and right click on a measurement.
|
||||
{
|
||||
label: 'IncludeSubMenu',
|
||||
selector: ({ protocol }) => protocol?.id === '@ohif/hp-extension.mn',
|
||||
selector: ({ protocol }) => protocol?.id === '@ohif/mnGrid',
|
||||
delegating: true,
|
||||
subMenu: 'orientationSelectionSubMenu',
|
||||
},
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import hpMN from './hpMN';
|
||||
|
||||
const hangingProtocols = [
|
||||
{
|
||||
name: '@ohif/hp-extension.mn',
|
||||
protocol: hpMN,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers a single study hanging protocol which can be referenced as
|
||||
* `@ohif/hp-exgtension.mn`, that has initial layouts which show images
|
||||
* only display sets, up to a 2x2 view.
|
||||
*/
|
||||
export default function getHangingProtocolModule() {
|
||||
return hangingProtocols;
|
||||
}
|
||||
@@ -2,14 +2,11 @@ import { Types } from '@ohif/core';
|
||||
|
||||
import { id } from './id';
|
||||
|
||||
import getHangingProtocolModule from './hp';
|
||||
import getCustomizationModule from './getCustomizationModule';
|
||||
// import {setViewportZoomPan, storeViewportZoomPan } from './custom-viewport/setViewportZoomPan';
|
||||
import sameAs from './custom-attribute/sameAs';
|
||||
import numberOfDisplaySets from './custom-attribute/numberOfDisplaySets';
|
||||
import numberOfDisplaySetsWithImages from './custom-attribute/numberOfDisplaySetsWithImages';
|
||||
import maxNumImageFrames from './custom-attribute/maxNumImageFrames';
|
||||
import seriesDescriptionsFromDisplaySets from './custom-attribute/seriesDescriptionsFromDisplaySets';
|
||||
|
||||
/**
|
||||
* The test extension provides additional behaviour for testing various
|
||||
@@ -31,21 +28,11 @@ const testExtension: Types.Extensions.Extension = {
|
||||
*/
|
||||
preRegistration: ({ servicesManager }: Types.Extensions.ExtensionParams) => {
|
||||
const { hangingProtocolService } = servicesManager.services;
|
||||
hangingProtocolService.addCustomAttribute(
|
||||
'seriesDescriptions',
|
||||
'Series Descriptions',
|
||||
seriesDescriptionsFromDisplaySets
|
||||
);
|
||||
hangingProtocolService.addCustomAttribute(
|
||||
'numberOfDisplaySets',
|
||||
'Number of displays sets',
|
||||
numberOfDisplaySets
|
||||
);
|
||||
hangingProtocolService.addCustomAttribute(
|
||||
'numberOfDisplaySetsWithImages',
|
||||
'Number of displays sets with images',
|
||||
numberOfDisplaySetsWithImages
|
||||
);
|
||||
hangingProtocolService.addCustomAttribute(
|
||||
'maxNumImageFrames',
|
||||
'Maximum of number of image frames',
|
||||
@@ -58,9 +45,6 @@ const testExtension: Types.Extensions.Extension = {
|
||||
);
|
||||
},
|
||||
|
||||
/** Registers some additional hanging protocols. See hp/index.tsx for more details */
|
||||
getHangingProtocolModule,
|
||||
|
||||
/** Registers some customizations */
|
||||
getCustomizationModule,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user