Skip to main content
Version: 3.14 Beta (Latest)

dcmjs 1.0

OHIF 3.14 moves from dcmjs 0.52 to dcmjs 1.x. The OHIF source keeps import dcmjs from 'dcmjs', and each OHIF package depends on dcmjs 1.1.0. The dcmjs 1.x package is a wrapper of @dcmjs-org/dcmjs, with the same exports.

Runtime plugins​

The host shares dcmjs with runtime plugins, as in OHIF 3.13. The major version of the shared dcmjs changes from 0 to 1.

  • A runtime plugin keeps import dcmjs from 'dcmjs'.
  • Set the peer range of the plugin to "dcmjs": "^1.0.0". Install a dcmjs 1.x release for the plugin build and tests.
  • The plugin build keeps dcmjs external. The host gives its copy on window['dcmjs'].
  • The host shares only the bare dcmjs import. Import dcmjs only as dcmjs. Do not import a dcmjs subpath (for example dcmjs/media) or an @dcmjs-org/* package: the plugin build puts that code in the plugin bundle. The plugin then has a second copy of dcmjs, with its own tag registry and its own logger.
  • A plugin that was built for dcmjs 0.x gets dcmjs 1.x from the host. dcmjs 1.0 changes the API and the shapes of naturalized data. Make the changes in the dcmjs migration guide, and build the plugin again.
  • create-ohif migrate moves a dcmjs dependency to a peer dependency ^1.0.0.
  • The host now also shares @cornerstonejs/utils and @cornerstonejs/metadata (major version 5) on window. A plugin that imports asArray or getPrivateTagValue gets the copy of the host. Set the peer range of the plugin to ^5.0.0.
  • The host now also shares loglevel (major version 1) on window. A plugin that imports loglevel gets the copy of the host, so its loggers follow the same root level as the OHIF, Cornerstone3D and dcmjs loggers.

Logging​

OHIF, Cornerstone3D and dcmjs 1.x now use one loglevel instance. The OHIF loggers have names of the form ohif.<package>.<path>.<file or area>, as the cs3d.* loggers do.

  • @ohif/core exports ohifLog, coreLog and the logging namespace (getLogger, getRootLogger, hpLog, rootLog).
  • @ohif/ui-next exports uiNextLog (ohif.uiNext).
  • Each OHIF extension exports its logger from src/log.ts, for example extensionCornerstoneLog (ohif.extensionCornerstone) from @ohif/extension-cornerstone.
  • The default level of every logger is warn.
  • log of @ohif/core now writes to the ohif logger. log.info and log.debug were console.log and console.debug, and always showed. Now they show only when the level of the logger is info or debug. log.time and log.timeEnd do not change.
  • The hanging protocol service, the protocol engine and the matcher write to hpLog (ohif.core.services.HangingProtocolService), not to console. The messages about the protocol match are at the debug level, and are hidden by default. The warnings stay at the warn level.
  • HangingProtocolService.debugLogging is deprecated and has no effect. Set the level of hpLog instead.

To set a level, use the loglevel interface:

import { logging } from '@ohif/core';

// One logger, for example the hanging protocols.
logging.hpLog.setLevel('debug');

// All the loggers that have no level of their own. loglevel 1.x needs
// rebuild() to pass the root level to the other loggers.
logging.rootLog.setLevel('info');
logging.rootLog.rebuild();

setLevel keeps the level in localStorage under loglevel:<logger name>. To see the hanging protocol messages without a code change, set localStorage['loglevel:ohif.core.services.HangingProtocolService'] = 'DEBUG' in the browser console, and reload the viewer.

Naturalized data shapes​

The instance metadata in DicomMetadataStore has the dcmjs 1.0 shapes. An extension that reads instance metadata must read these shapes:

  • A sequence with one item is the item object, not an array. Use asArray from @cornerstonejs/utils before an array method such as map or find.
  • A VM 1-n value is a list, also for one value. A VM 1 value is a scalar, and the value is null when it is empty.
  • A PN value is an object, for example { Alphabetic: 'Doe^John' }.
  • The private elements of one reserved block are in one key, `${gggg}:${creator}`. Read a private element with getPrivateTagValue(dataset, group, creator, element) from @cornerstonejs/utils.
  • OHIF finds a private element by its private creator, as DICOM PS3.5 section 7.8.1 requires. The Philips PET SUV factors (70531000, 70531009) need the creator 70530010 = 'Philips PET Private Group'. The GE decay time (0009100D) needs the creator GEMS_PETD_01. If a metadata source drops the creator element, OHIF ignores these values and computes the SUV with the standard attributes.
  • dcmjs reads a private element in an Implicit VR file as bytes ([ArrayBuffer]), unless a plugin registers the tag with registerTag. See dcmjs issue 693. OHIF reads the bytes of the GE decay time as text. OHIF ignores a GE decay time with a UTC offset, because calculate-suv does not read the offset.
  • An empty VM 1-n element is [] (before: null). [] is truthy, so a value || fallback expression does not use the fallback. Check for an empty value first, for example with value?.length, and then use ??.
  • The overlay groups (60xx) are items of OverlaySequence. dcmjs also defines the 60xx hex keys of each group as non-enumerable aliases. A spread copy ({ ...instance }) loses these aliases, so read the overlays from OverlaySequence. The Tag Browser shows the overlays in a later change (#6321).

Changes that a user can see​

  • dcmjs converts CIELab colours with the D50 white point, as DICOM PS3.3 C.10.7.1.1 requires. dcmjs 0.52 used D65. A segment colour in a SEG that a viewer with dcmjs 0.52 wrote now shows with a small shift. For example, [255, 87, 34] shows as [250, 87, 35]. Gray values do not change.
  • The Tag Browser does not show ImagePositionPatient, ImageOrientationPatient and PixelSpacing at the root of an enhanced multiframe instance when the instance does not have them there. OHIF reads these values from the functional groups. A saved multiframe SEG also does not get these tags at the root.
  • The Tag Browser shows each name of a PN list, for example OperatorsName and PhysiciansOfRecord. It joins two or more names with \. With dcmjs 0.52, the Tag Browser showed an empty value for a list of two or more names.

The dcmjs migration guide gives all API changes: docs/MIGRATION.md.