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 adcmjs1.x release for the plugin build and tests. - The plugin build keeps
dcmjsexternal. The host gives its copy onwindow['dcmjs']. - The host shares only the bare
dcmjsimport. Import dcmjs only asdcmjs. Do not import a dcmjs subpath (for exampledcmjs/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 migratemoves adcmjsdependency to a peer dependency^1.0.0.- The host now also shares
@cornerstonejs/utilsand@cornerstonejs/metadata(major version 5) onwindow. A plugin that importsasArrayorgetPrivateTagValuegets 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) onwindow. A plugin that importsloglevelgets 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/coreexportsohifLog,coreLogand theloggingnamespace (getLogger,getRootLogger,hpLog,rootLog).@ohif/ui-nextexportsuiNextLog(ohif.uiNext).- Each OHIF extension exports its logger from
src/log.ts, for exampleextensionCornerstoneLog(ohif.extensionCornerstone) from@ohif/extension-cornerstone. - The default level of every logger is
warn. logof@ohif/corenow writes to theohiflogger.log.infoandlog.debugwereconsole.logandconsole.debug, and always showed. Now they show only when the level of the logger isinfoordebug.log.timeandlog.timeEnddo not change.- The hanging protocol service, the protocol engine and the matcher write to
hpLog(ohif.core.services.HangingProtocolService), not toconsole. The messages about the protocol match are at thedebuglevel, and are hidden by default. The warnings stay at thewarnlevel. HangingProtocolService.debugLoggingis deprecated and has no effect. Set the level ofhpLoginstead.
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
asArrayfrom@cornerstonejs/utilsbefore an array method such asmaporfind. - A VM
1-nvalue is a list, also for one value. A VM 1 value is a scalar, and the value isnullwhen 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 withgetPrivateTagValue(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 creator70530010 = 'Philips PET Private Group'. The GE decay time (0009100D) needs the creatorGEMS_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 withregisterTag. 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-nelement is[](before:null).[]is truthy, so avalue || fallbackexpression does not use the fallback. Check for an empty value first, for example withvalue?.length, and then use??. - The overlay groups (
60xx) are items ofOverlaySequence. dcmjs also defines the60xxhex keys of each group as non-enumerable aliases. A spread copy ({ ...instance }) loses these aliases, so read the overlays fromOverlaySequence. 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,ImageOrientationPatientandPixelSpacingat 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
OperatorsNameandPhysiciansOfRecord. 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.