All files / extensions/default/src/customizations metadataDisplaySetCustomization.ts

50% Statements 1/2
100% Branches 0/0
50% Functions 1/2
50% Lines 1/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                                                                248x                              
import { displaySetRuleOrder, displaySetRules } from '@cornerstonejs/metadata';
import type { GroupInstancesOptions, InstanceGroup } from '@cornerstonejs/metadata';
import { makeDisplaySetFromInstanceGroup } from '../displaySetSplitting/makeDisplaySetFromInstanceGroup';
import type { ImageSetFactoryContext } from '../displaySetSplitting/makeImageSetDisplaySet';
 
/**
 * The `useMetadataDisplaySet` customization (default OFF).
 *
 * When enabled, DisplaySetService splits series instances into display sets
 * with the `@cornerstonejs/metadata` split-rules engine. A rule with a
 * `handler` name gives its display sets to the SOP class handler of the mode
 * that declares that name in `handlerNames`.
 *
 * Enable per mode, in the `onModeEnter` of the mode. `setCustomizations` uses
 * `CustomizationScope.Mode` by default, and `onModeExit` clears that scope:
 * ```js
 * customizationService.setCustomizations({
 *   useMetadataDisplaySet: { enabled: { $set: true } },
 * });
 * ```
 * or globally via the named module entry
 * `'@ohif/extension-default.customizationModule.metadataDisplaySet'`,
 * or from the URL with `?customization=split/enableNewSplit`.
 *
 * `displaySetRules` (the registry, keyed by rule id) and `displaySetRuleOrder`
 * (the rule ids in evaluation order) are the `@cornerstonejs/metadata`
 * defaults, with no OHIF copy. A customization changes a rule by its id in the
 * registry, and adds, removes or replaces an id of the order with
 * `$spliceById`, which takes a rule id as the position:
 * ```js
 * { displaySetRuleOrder: { $spliceById: [['volume3d', 0, 'dwiByBValue']] } }
 * ```
 * DisplaySetService compiles the rules of the order with
 * `createDisplaySetSplitRules`, with the `metadataContext` customization as
 * the context.
 *
 * A rule error stops display set creation; OHIF does not drop the rule, and
 * does not fall back to the SOP class handlers. See `DisplaySetService`.
 */
export default function getMetadataDisplaySetCustomization(context: ImageSetFactoryContext) {
  return {
    useMetadataDisplaySet: {
      enabled: false,
      displaySetRules,
      displaySetRuleOrder,
      createDisplaySetFromGroup: (
        group: InstanceGroup,
        options: {
          splitNumber: number;
          compareInstances?: GroupInstancesOptions['compareInstances'];
        }
      ) => makeDisplaySetFromInstanceGroup(group, options, context),
    },
  };
}