Skip to content

Commit

Permalink
feat: Add a new hanging protocol @ohif/mn (#3305)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wayfarer3130 authored Apr 18, 2023
1 parent 6cf271d commit c508a2b
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 358 deletions.
78 changes: 78 additions & 0 deletions extensions/cornerstone-dicom-seg/src/getHangingProtocolModule.ts
Original file line number Diff line number Diff line change
@@ -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 };
3 changes: 3 additions & 0 deletions extensions/cornerstone-dicom-seg/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -79,6 +80,8 @@ const extension = {
* Examples include the default sop class handler provided by the default extension
*/
getSopClassHandlerModule,

getHangingProtocolModule,
};

export default extension;
9 changes: 5 additions & 4 deletions extensions/cornerstone/src/getHangingProtocolModule.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -303,7 +304,7 @@ const mprAnd3DVolumeViewport = {
function getHangingProtocolModule() {
return [
{
name: 'mpr',
name: mpr.id,
protocol: mpr,
},
{
Expand Down
2 changes: 1 addition & 1 deletion extensions/default/src/commandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
212 changes: 7 additions & 205 deletions extensions/default/src/getHangingProtocolModule.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import hpMNGrid from './hpMNGrid';

const defaultProtocol = {
id: 'default',
locked: true,
Expand Down Expand Up @@ -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',
},
],
},
],
},
],
};

Expand All @@ -306,6 +103,11 @@ function getHangingProtocolModule() {
name: defaultProtocol.id,
protocol: defaultProtocol,
},
// Create a MxN hanging protocol available by default
{
name: hpMNGrid.id,
protocol: hpMNGrid,
},
];
}

Expand Down
Loading

0 comments on commit c508a2b

Please sign in to comment.