Repository navigation
feat: @dcmjs-org/video and @dcmjs-org/imaging - #585
Merged
Merged
Conversation
The package shell for the video wave: name, entry point, MIT license, repository directory, and the @dcmjs-org/core workspace dependency. The image-module index exports only the header parsers for now; the dataset builder joins it in the next slice. Co-Authored-By: Claude Fable 5 <[email protected]>
Verbatim from v2.0-development: src/image/jpegInfo.js (SOF geometry and the JPEG transfer syntax mapping), src/image/mp4Info.js (the ISO BMFF box walk over a random-access reader), the makeTinyMp4 synthesized-fixture helper, and the ported mp4Info suite. Only the test import paths moved with the files; no behavior changed in this commit — review findings 9 and 15 are fixed on top, each with its regression observed red first. Co-Authored-By: Claude Fable 5 <[email protected]>
Review finding 9 (HIGH): the marker-walk guard only required four readable bytes, but the SOF fields span bytes[offset+4 .. offset+9]. Out-of-range reads coerce to 0 in the bitwise math, so the review map's vector — a 480x640 JPEG cut one byte into the width field — returned columns 512 instead of throwing, and a file cut right after the length field returned rows 0, columns 0. The reader now validates that the declared SOF segment fits inside the input (and is at least 8 bytes) before reading any field. The new jpegInfo suite is hand-written (v2 carried no suite for this file): the exact review vector, the cut-after-length shape, and valid SOF0/SOF1/SOF2/SOF3 paths. Both finding tests were observed red against the ported-unfixed reader before this fix. Co-Authored-By: Claude Fable 5 <[email protected]>
Review finding 15 (MED): the stts fallback loop trusted the raw uint32 entry_count. With stsz sample_count 0 and stts entry_count 0x00FFFFFF the parser spun 16.7 million iterations over zero-coerced reads past the box and fabricated numberOfFrames/frameRate from unrelated moov bytes; at 0xFFFFFFFF that is roughly 40 seconds of blocked thread. The loop now requires 16 + entryCount * 8 to fit inside the stts box and throws on the mismatch. The regression corrupts a synthesized MP4 exactly that way and asserts the parse rejects in under two seconds — observed red (the unfixed parser resolved with fabricated values) before this fix. Co-Authored-By: Claude Fable 5 <[email protected]>
feat(video): scaffold @dcmjs-org/video with the JPEG and MP4 header parsers
Verbatim from v2.0-development src/image/buildImageDataset.js and its 21-test suite, with two mechanical adjustments for the package boundary: DicomMetaDictionary and validationLog now come from @dcmjs-org/core, and the test imports the builder from the package's image index (which now exports it alongside the header parsers). No behavior changed in this commit — review finding 10 is fixed on top with its regressions observed red first. Co-Authored-By: Claude Fable 5 <[email protected]>
Review finding 10 (HIGH): numberOfFrames came only from decodedImage.numberOfFrames || 1 and was never derived from or checked against options.encapsulated.frames.length, and the attribute was only written when above 1. Three encapsulated fragments therefore produced an instance with no NumberOfFrames — a conformant reader showed frame 1 and the rest were unreachable — while an explicit numberOfFrames 7 over 2 fragments emitted the bogus claim unchecked. In encapsulated mode the fragment list is now the ground truth: the count defaults to frames.length and an explicit mismatch throws. Both regressions were observed red against the ported-unfixed builder before this fix; two companion tests pin that a matching explicit count is accepted and that a single fragment still omits the attribute. Co-Authored-By: Claude Fable 5 <[email protected]>
feat(video): port buildImageDataset with the encapsulated frame-count fix
Verbatim from v2.0-development src/encapsulated/encapsulatedVideo.js and its 8-test suite, with one mechanical adjustment for the package boundary: DicomMetaDictionary and isVideoTransferSyntax now come from @dcmjs-org/core instead of relative paths. buildVideoDataset shapes the Supplement 225 Video Photographic Image shell (XC modality, cine timing, the (7FE0,0003) uint64 total length as a BigInt), encapsulateVideo splits the MP4 into fragment-sized exact ArrayBuffer slices, and extractEncapsulatedVideo concatenates fragments and truncates to the declared length so the odd-fragment pad byte drops on extraction. Co-Authored-By: Claude Fable 5 <[email protected]>
The video half of v2's encapsulated index only — the PDF half (encapsulatedPdf) belongs to the media wave. Co-Authored-By: Claude Fable 5 <[email protected]>
feat(video): port the buffered video encapsulation layer
@dcmjs-org/parser joins the dependencies — the video event source imports fromDataSet and EVENT_STREAM_VOCABULARY — and @dcmjs-org/generator the devDependencies (StreamingPart10Writer, tests only). Deliberately NOT @dcmjs-org/legacy: this package stays off the legacy surface. Co-Authored-By: Claude Fable 5 <[email protected]>
createVideoEventSource — MP4 → contract events with the Supplement 225
dataset shell replayed first and the stream emitted as encapsulated
PixelData fragments, one in memory at a time, backpressure between
fragments via awaitDrain().
The run loop, exactFragment, withoutEndDataSet and sortDict are verbatim
from v2.0-development src/eventStream/fromVideo.js. One seam is reworked
and hand-written: v2 imported datasetToDict from what is now
@dcmjs-org/legacy, which this package must not depend on, so a local
datasetToMetaDict helper mints the same file meta group (element list and
implementation UID copied from legacy's datasetToDict) and denaturalizes
both halves via core's DicomMetaDictionary — returning the plain
{ meta, dict } shape, which is all parser's fromDataSet reads.
The suite is the v2 fromVideo suite reworked off the DicomEventStream
facade (media wave): the source drives StreamingPart10Writer directly
and reads back through fromPart10/fromPart10Stream + NaturalizedListener
+ extractEncapsulatedVideo. All load-bearing assertions carried over:
byte-identical round trips (buffered and streaming reader), the
(7FE0,0003) UV uint64 pinned on the wire, the Sup 225 fragment layout,
single-endDataSet ordering, per-fragment backpressure, and the ffmpeg
corrective error. The facade-specific toVideo/fromPdf case stays with
the media wave, as does fromImage.test.js.
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
feat(video): port the video event source, legacy-free
…ented GHSA-vfj7-8cjw-p6xm was published 2026-10-02 with a claimed fix range of >=3.0.4, but no such braces release exists on the registry, so there is nothing to override to. Every path is dev tooling; braces never reaches the published packages. Same entry the fhir staging branch already carries (#589) — remove it the moment a patched braces ships. Co-Authored-By: Claude Fable 5 <[email protected]> (cherry picked from commit 7261970)
Merged
Per review on #542: the guide existed to hold the staged-landing PR descriptions to one standard, and every description is now written. Removed rather than kept stale; git history preserves it if the team wants it back later. The PR template keeps the one-line spirit of it. Co-Authored-By: Claude Fable 5 <[email protected]> (cherry picked from commit 2a5935e)
…video # Conflicts: # pnpm-lock.yaml # pnpm-workspace.yaml
awatson1978
marked this pull request as ready for review
October 19, 2026 06:50
PR #588 review (conversation with Bill): split the lightweight, codec-free image building out of video so a consumer that only needs to build image instances doesn't pull the heavy MP4/video machinery, and SOP-specific image info stays out of core. New @dcmjs-org/imaging (depends on core only): - buildImageDataset + SECONDARY_CAPTURE_SOP_CLASS_UID (moved from video/src/image) - parseJpegInfo (moved) - h264TransferSyntaxUID (extracted from video/src/image/mp4Info.js into src/h264.js) @dcmjs-org/video now depends on @dcmjs-org/imaging: - parseMp4Info stays (MP4 container parsing is video-domain) and imports h264TransferSyntaxUID from imaging - src/image/ and the public surface trimmed to parseMp4Info + the video encapsulation/streaming; descriptions/comments updated Tests moved with their code (buildImageDataset, jpegInfo); the h264TransferSyntaxUID describe block moved to packages/imaging/test/h264.test.js. RELEASE_PLAN gains an imaging row and notes the landing order (imaging with/before video). Full suite 954 passed / 11 skipped / 0 failed. Follow-ons (separate branches): media exports an imaging namespace and sources the image builders from imaging; fhir->imaging deferred until fhir builds images. Co-Authored-By: Claude Fable 5 <[email protected]>
…video # Conflicts: # RELEASE_PLAN.md
buildImageDataset and buildVideoDataset now use createInstance from @dcmjs-org/core, the same creator pattern as @dcmjs-org/encapsulated: - New base blocks: imageBase / secondaryCaptureImageBase and videoBase / videoPhotographicBase, each with predecessorBase. - The instance, dataLevel, levels, predecessor and baseDicom options pass through to createInstance. Payload attributes (geometry, stream values, transfer syntax) are set after it. - createInstance writes only DICOM attributes (keywords, tags, _meta/_vrMap) from the overrides; other keys are dropped with a warning. Each builder removes its own control keys first. - The video base no longer sets StudyID 1; a new study gets the Type 2 empty StudyID from studyBase. - buildImageDataset reuses the core EXPLICIT_LITTLE_ENDIAN and merges _vrMap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The attribute filter now accepts a keyword that lookupRegisteredTagByName finds, as denaturalizeDataset does. Before this fix, such an override was dropped with a warning. Co-Authored-By: Claude Opus 5.5 <[email protected]>
All builders (encapsulate, buildVideoDataset, buildImageDataset) take the same options: createInstance options, attribute overrides, and their own payload control keys. packages/core/README.md documents the shared model (CORE-USR/CORE-IMP); the package READMEs refer to it. core createInstance: - never copies the identity of `instance` (SOPInstanceUID, SOPClassUID, InstanceNumber, media storage UIDs), also with a custom `levels` - InstanceNumber at series level is the largest prior number + 1 - Type 2 empty StudyDate/StudyTime/SeriesNumber for an inherited level - skips undefined overrides; rejects a DICOM JSON `instance` - nextSeriesNumberBase counts only IS integers imaging: - remove the `metadata` option and the old `derivedFrom` shapes - new derivedImageAttributes / derivedImageBase: derivation from one or more naturalized instances, as a base block; lossy history is kept - ImageType ORIGINAL\PRIMARY is a base value video: README with VID requirements; control keys removed before the call. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cess All builders take one option shape: the createInstance controls (baseDicom, instance, dataLevel, levels, predecessor, postProcess), their own control keys, and `overrides`. `overrides` is a naturalized DICOM provider with the same forms as baseDicom; its attributes go only into the result. An extra option key has no effect. core createInstance: - baseDicom resolves, then overrides; merge base < inherited < overrides, with a key merge of _meta; then postProcess (default removeUndefinedAttributes, top level only), so an undefined override removes the attribute - `instance` gives the attributes that `levels` lists; at dataLevel series the new InstanceNumber is the sample (first) instance's + 1 - Modality warning uses a presence check of the override - validation is part of the usage flow (CORE-IMP-11); pure type checks removed encapsulated: export PDF_MIME_TYPE; a builder sets only _meta.TransferSyntaxUID on a copy of _meta. imaging: geometry, HighBit and PixelRepresentation are written only when the decoded image gives them; ConversionType is a base value; a float pixel array throws. video: no attribute for a missing mp4Info field; createVideoEventSource keeps the returned _meta and the caller's file meta keys; normalizeFragmentBytes is no longer exported. eslint: no-unused-vars ignoreRestSiblings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
predecessorBase is an optional base block in core, one more way to add default attributes. The encapsulated document bases include it. imageBase and videoBase no longer include it, so `predecessor: true` has no effect with those default bases. A caller can add the block, for example combineBases(imageBase, predecessorBase). Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
approved these changes
Oct 21, 2026
wayfarer3130
added a commit
that referenced
this pull request
Oct 21, 2026
…media 1.0-beta now has #577 (@dcmjs-org/encapsulated) and #585 (@dcmjs-org/video and @dcmjs-org/imaging, built on createInstance). The merge takes the video package from 1.0-beta and moves the media wave onto the new packages: - remove packages/pdfs; @dcmjs-org/encapsulated replaces it - the media bundle and the DicomEventStream factories import from @dcmjs-org/encapsulated, @dcmjs-org/imaging, and @dcmjs-org/video - the bundle re-exports the base blocks and the generic encapsulate, and drops normalizeFragmentBytes, which the video package no longer exports - the factories pass the createInstance options to the builders; the DICOM attributes go in `overrides`, and the tests use that form - a new test checks that fromPdf passes instance and dataLevel through Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130
added a commit
that referenced
this pull request
Oct 21, 2026
Take the 1.0-beta design for every package that the assemblies #577, #585, #588 and #584 merged: @dcmjs-org/encapsulated replaces @dcmjs-org/pdfs, @dcmjs-org/imaging holds buildImageDataset and parseJpegInfo, and @dcmjs-org/media and @dcmjs-org/fhir come from 1.0-beta unchanged. Keep only the wrapper on top: the @dcmjs-org/dcmjs rename without "private", the media/encapsulated/image/fhir namespaces in src/index.js, the root dependency on @dcmjs-org/media, test/bundle-size.test.js, and the pnpm 12.9.1 pin. The dcmjs.fhir namespace tests move from packages/fhir/test to test/fhirNamespace.test.js, so the package tests stay off the root wrapper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🎉 This PR is included in version 1.0.0-beta.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the assembly PR for the video package: it brings
release/1.0-beta-videointo1.0-beta, carrying PRs #576, #578, #581 and #583 on top of the core engine branch, each individually reviewed with its own plain-English description. Like the other assemblies (#542, #543, #575, #577, #584), it's open as a draft on purpose — please don't merge it yet; the landing order and the trunk overlap (details below) mean the assemblies should go in deliberately, not as soon as they're green.What this is in plain terms.
@dcmjs-org/videogets video and camera imagery into DICOM without re-encoding. Its header parsers (parseJpegInfo,parseMp4Info) read the geometry and timing DICOM needs — rows, columns, frame count, frame rate, codec profile — straight from the JPEG or MP4 bytes, without decoding a single pixel, so the compressed stream can travel verbatim into encapsulated PixelData.encapsulateVideowraps an MP4's H.264 stream into a Video Photographic Image instance andextractEncapsulatedVideorecovers it byte-identically.buildImageDatasetgoes the other way for already-decoded pixels, producing a conformant image instance. AndcreateVideoEventSourceis the streaming path: MP4 to contract events, one fragment in memory at a time, feeding any event-stream sink. The package imports only@dcmjs-org/coreand@dcmjs-org/parser— never legacy.A worked example, both directions — run on this branch, output verbatim.
Creating: an MP4 becomes a complete Part 10 file, streamed one fragment at a time (the header parsers recover the geometry; nothing is re-encoded):
Reading: the Part 10 file comes back through the engine, and the original MP4 comes out byte-identical:
The buffered pair works the same way without the event stream:
encapsulateVideo(mp4, attrs)gives the naturalized dataset directly, andextractEncapsulatedVideorecovers the stream from any dataset however it was read.What's in it. Four PRs, in the order they landed:
@dcmjs-org/videopackage (publishable, MIT, 0.0.0 like its siblings),jpegInfo.jsandmp4Info.jswith the synthetic-MP4 test factory (makeTinyMp4), the ported mp4Info suite, and a brand-new jpegInfo suite — v2 never had one.encapsulateVideo/extractEncapsulatedVideoand the fragment helpers, with their 8-test suite.createVideoEventSource, reworked legacy-free: v2'sdatasetToDict(a legacy import) is replaced by a ~29-line local helper producing the plain{meta, dict}shape the parser'sfromDataSetaccepts.The three review findings fixed here, from the PR #512 review map — each regression was written against the ported-but-unfixed code and observed failing first:
parseJpegInfo's scan guard checked only 4 bytes of headroom while the SOF parse reads 10, so a truncated JPEG silently returned wrong geometry (the review's exact vector —FF D8 FF C0 00 11 08 01 E0 02— came back as columns 512 instead of failing). Truncation now throws.buildImageDatasetnever derivedNumberOfFramesfrom the encapsulated fragment list — a three-frame encapsulation produced a dataset with noNumberOfFramesat all. The frame list is now the ground truth: it fills the default and an explicit mismatch throws.parseMp4Info'ssttsfallback trusted the box's raw entry count, so a malformed file claiming 0xFFFFFF entries blocked the thread for tens of seconds and fabricated a frame count. The entry count is now bounded by the box's own size; the regression asserts the malformed file is rejected fast.One open question for maintainers, raised in #576 and deliberately not fixed: 12-bit extended-sequential JPEG currently yields
BitsAllocated 12, but PS3.5 allows only 8 or 16 (correct would beBitsAllocated 16withBitsStored 12). It's a ~5-line fix inbuildImageDatasetif you agree.Test evidence. 913 tests across 75 suites on this branch — 901 passing, 12 skipped (the pre-existing skips), zero failures, on Node 22 and 24. The package itself is 57 tests in 5 suites, including the new jpegInfo suite and the finding regressions. CI is green at the branch tip
58dba59: tests, lint/format, audit. One honest gap, declared in #576: every MP4 in the suite is synthetic (makeTinyMp4) — no real-world camera file exercises the box parser yet. Adding one later means a DATACITATION row and a license check, like every committed fixture.Test usage. From the repo root:
Expected: 5 suites, 57 tests, all passing in a few seconds.
GitHub issues. None map directly — the historical backlog has no video-area issues (video support itself arrived with the 1.0 rewrite). The three fixes above trace to the #512 review map rather than filed issues.
The numbers. The package is +2,100 lines under
packages/video/(about two-thirds verbatim v2 port, declared per-PR; the hand-written remainder is the three fixes, their regressions, the new jpegInfo suite, and the legacy-free rework of the event source) across 4 PRs and their conventional commits, merged (not squashed) so the release tooling sees each one. The raw diff against1.0-betais much larger because this branch is cut from the core engine tip (e5f46e4) — it carries the whole core trunk that draft #542 also carries. Whichever assembly merges first absorbs that trunk, and this diff shrinks to just the video package.Breaking changes. None — this is a new package; nothing under the existing
src/surface changes here. Within the port itself: truncated JPEGs and malformed MP4s that previously produced silently-wrong values now throw, and encapsulated multi-frame datasets gain theNumberOfFramesattribute they were always supposed to carry.Still to come: the
DicomEventStreamfacade factories (fromVideo,fromVideoStream,toVideo,fromImage) land with the media wave, which also carries the review's finding 14 (the lazy source-promise fix) — that wave touches the shared facade file, so it sequences after the three bulk-data packages rather than inside any one of them.Update: one instance-creation model for all builders
This update has six commits on top of the assembly branch.
c9634a6mergesorigin/1.0-betainto this branch. The merge brings@dcmjs-org/encapsulated(feat: @dcmjs-org/encapsulated — encapsulated PDF wrap and unwrap #577) andcreateInstancein@dcmjs-org/core. The package table and step 6 ofRELEASE_PLAN.mdnow name@dcmjs-org/encapsulated,@dcmjs-org/imagingand@dcmjs-org/video, and not@dcmjs-org/pdfs.f875187changesbuildImageDatasetandbuildVideoDatasetto usecreateInstance.7c9e118keeps the keywords that a caller adds withregisterTag.64992a8makes one model for all builders, and documents the model.c8aa8a7moves the attributes into anoverridesprovider, addspostProcess, and simplifies the model.5b7dc92keepspredecessorBaseonly in the encapsulated bases. Ten review rounds checked this work.The model
packages/core/README.mddocuments the shared model (CORE-USR-1 to 15 and CORE-IMP-1 to 11). The READMEs of@dcmjs-org/encapsulated,@dcmjs-org/imagingand@dcmjs-org/videorefer to the CORE identifiers. Each README keeps user requirements and implementation requirements in separate sections, and states the change rule.encapsulate/encapsulatePdfbuildVideoDataset/encapsulateVideo/createVideoEventSourcebuildImageDatasetbaseDicom(encapsulatedBase)baseDicom(videoBase)baseDicom(imageBase)instance,dataLevel,levels,predecessor,postProcessoverridesmimeTypefragmentBytesderivedFrom,lossy,encapsulatedoverridesholds the DICOM attributes. It is a naturalized DICOM provider with the same forms asbaseDicom: a naturalized object, a function of the context, an array, or acombineBasesblock.createInstanceresolvesbaseDicom, thenoverrides. The merge order is: base blocks < attributes frominstance(copied by level) <overrides. An_metaoverride merges key by key.postProcess(dataset, context)runs once on the merged result. The defaultremoveUndefinedAttributesdeletes the top-levelundefinedvalues, so anundefinedoverride removes the attribute.nulland""give a Type 2 empty value.instancesays where the new object goes. It gives the attributes thatlevelslists. The default levels do not hold the identity ofinstance.predecessorBaseis an optional base block in core (CORE-USR-9). Withpredecessor: true, it lists eachinstanceinPredecessorDocumentsSequence. Only the encapsulated bases (encapsulatedBase,encapsulatedPdfBase) include it now. With the defaultimageBaseandvideoBase,predecessor: truehas no effect. A caller can add the block, for examplecombineBases(imageBase, predecessorBase).dataLevel: "series",instanceis the sample instance. The newInstanceNumberis itsInstanceNumberplus 1. Wheninstanceis an array, the first item is the sample. In each other case the value is 1. An override wins.createInstance, and only when the payload gives them. Examples are the decoded image geometry,HighBitfrom a decodedbitsStored, and the video stream values. A builder writes no default for a payload attribute that the payload does not give._meta.TransferSyntaxUID, on a copy of_meta.dataLevel, anextract*call on the wrong type, and pixel data that does not match the geometry. A function does not check a JS type that the JSDoc declares. A user requirement names each error.derivedFrom(one naturalized instance or an array) is separate frominstance. The base blockderivedImageBaseand the functionderivedImageAttributesmake the derived attributes.These changes also change the API of #577 on
1.0-beta. In #577, the attributes were top-level options, for exampleencapsulatePdf(bytes, { instance, DocumentTitle: "v1" }). Now the attributes go inoverrides.Changes needed in PRs 588, 584 and 595 when they merge this branch
These PRs are based on a
1.0-betafrom before #577. When they merge this branch, these call sites must change:packages/media/src/index.js:normalizeFragmentBytesfrom@dcmjs-org/video. That export is removed. Remove it from lines 22 and 48, and frompackages/media/test/bundle.test.jslines 38–40.@dcmjs-org/pdfs. That package does not exist on1.0-beta. Import from@dcmjs-org/encapsulated.buildImageDataset,SECONDARY_CAPTURE_SOP_CLASS_UID,parseJpegInfoandh264TransferSyntaxUIDfrom@dcmjs-org/video. These are now in@dcmjs-org/imaging.undefined, and the identity test comparesundefinedwithundefined.src/eventStream/fromFhir.jslines 166 and 187 (PRs 584 and 595): the demographics andDocumentTitleare top-level options. After the merge, these keys have no effect, and the PDF and JPEG instances lose the patient name, the patient ID and the title, with no warning. Move them intooverrides.Tests
npx jest packages/core packages/encapsulated packages/imaging packages/videogives 10 suites and 100 tests. All tests pass.streamEquivalence, has 3 failures:test_multiframe_1,test_oneslice_segandtest_deflatedintest/data.test.js. These tests also fail without this update, because the downloaded test data was missing on the test machine.Changes to user requirements (compared with
origin/1.0-beta, with7c9e118, with64992a8, and withc8aa8a7)Changes to user requirements
The base of the comparison is
origin/1.0-beta(the encapsulated READMEof #577). The README of
@dcmjs-org/encapsulatedwas the only README withuser requirements. The shared requirements of
createInstancemoved fromthat README to
packages/core/README.md(CORE-USR-n). The ENC identifiersof the moved requirements stay reserved, and each one refers to its CORE
identifier.
@dcmjs-org/imaging(IMG-USR-n) and@dcmjs-org/video(VID-USR-n) are newpackages. Their user requirements are new, and are not changes.
Changes of behaviour
InstanceNumber)series: the same series (its UID, number, and description), asa new SOP instance." The
InstanceNumberwas always 1.dataLevel: "series",instanceis the sample instancein the series. The new
InstanceNumberis theInstanceNumberofthe sample instance, plus 1. When
instanceis an array, the firstitem is the sample instance. The value is 1 when the sample instance
has no usable value (not an integer, less than 0, or 2147483647 or
more), or when
dataLeveldoes not inherit the series. AnInstanceNumberoverride replaces the value.must follow the sample instance, and must not repeat its number.
StudyDateorStudyTime, thevalue is
"". When an inherited series has noSeriesNumber, thevalue is
"".and the result must have them.
ModalityorSOPClassUIDdiffers from thebase, the builder logs a warning and keeps the inherited value."
Modalitydiffers from the baseModality(DOCfor PDF), the builder logs a warning and keeps theinherited value (CORE-USR-10)."
the
SOPInstanceUID,SOPClassUID,InstanceNumber,MediaStorageSOPInstanceUID, orMediaStorageSOPClassUIDofinstance(CORE-USR-4). A customlevelscopies each of thesekeywords that it lists. The base blocks set the identity: a new
SOPInstanceUID, theSOPClassUIDof the document class, and theInstanceNumberof CORE-USR-5. A copied value and an overridereplace a base value (CORE-USR-6)."
CONSISTENCY_KEYSis["Modality"]. Atorigin/1.0-beta, itwas
["Modality", "SOPClassUID"].createInstancecopies exactlycopyAttributesByLevel(instance, dataLevel, { levels }), as atorigin/1.0-beta. No code removes an identity keyword.SOPClassUIDwarning is removed. A customlevelsthat listsSOPClassUIDcopies the value ofinstance,and the builder logs no warning. The default levels do not list
SOPClassUID, so with the default levels the warning neveroccurred. The copy of the identity with a custom
levelsdoes notchange against
origin/1.0-beta.the result copies, and a custom
levelsis the choice of thecaller. The old ID also held two different rules (the
Modalitywarning and the identity), so the new text splits them.
overrides)createInstancewrote each option that was not acreateInstanceoption into the dataset.overrides(CORE-USR-1). Each key of theresolved
overridesgoes into the merge, also a key with anundefinedvalue (CORE-USR-8). An extra top-level option key hasno effect. The JSDoc of each function states the input types. A user
requirement names each error that a function throws for a wrong
input value. CORE-IMP-11 gives the rule for these checks.
must not go into the dataset.
undefined,null,""overrides)undefinedoverride wroteundefinedinto thedataset.
undefinedoverride replaces the base or inherited value.The default
postProcess(CORE-USR-15) then deletes the key, so theresult does not have the attribute. An
undefinedvalue from a baseblock or from
instancealso gives no attribute.nulland""give a Type 2 empty value. The builders do not invent a value.
attribute of the base or of
instancewith anundefinedoverride, and the dataset holds no
undefinedvalue.postProcess)postProcessoption.postProcessis acreateInstancecontrol (CORE-USR-1), afunction
(dataset, context) => dataset.createInstancecalls itonce on the merged result, and returns its return value. The
default is
removeUndefinedAttributes, a new export of@dcmjs-org/core. This function deletes each top-level key with anundefinedvalue, and does not change the items of a sequence. Acustom
postProcessreplaces the default. A builder passespostProcesstocreateInstance, and does not call it again afterit sets its payload attributes (CORE-USR-13).
merged result in one step, before the builder sets the payload.
Changes of text only (no change of behaviour)
instanceis a naturalized dataset. The texttells the caller to use
DicomMetaDictionary.naturalizeDataseton DICOMJSON first.
createInstancedoes not detect DICOM JSON, as in feat: @dcmjs-org/encapsulated — encapsulated PDF wrap and unwrap #577.The type check of
instanceis removed (see "Removed checks" below).time".
text adds the example of an override
SOPInstanceUID. The text alsonames the exception for the payload attributes of a builder
(CORE-USR-13).
encapsulatereplaced an override of its payload infeat: @dcmjs-org/encapsulated — encapsulated PDF wrap and unwrap #577 also, so the behaviour does not change.
mimeTypereplaces an override ofMIMETypeOfEncapsulatedDocument.predecessorBase, and that aninstancewithout the four reference UIDsthrows an error.
encapsulate. The textdescribes the behaviour of feat: @dcmjs-org/encapsulated — encapsulated PDF wrap and unwrap #577.
payload rule of each builder. The text describes the current behaviour.
Changes since 7c9e118
The base of this comparison is the pushed branch (HEAD 7c9e118, the PR
body of #585). The comparison with
origin/1.0-betaabove stays valid.At 7c9e118, the imaging and video packages had no README requirements.
The "Old" text below therefore comes from the PR body and from the code
of 7c9e118.
buildImageDataset(IMG-USR-n)metadataoption removedmetadatawas a control key. It took a naturalized or a DICOMJSON document. When the caller gave no
instance, the strippedmetadatawas the instance, at the deepest level that its UIDsidentified.
metadatais not an option. A top-levelmetadatakey hasno effect (CORE-USR-7). Without
instance, the image goes into a new study (CORE-USR-2). Thebuilder does not naturalize DICOM JSON. Give a naturalized
instance, and givederivedFromfor a derivation.options (CORE-USR-1).
instancesays where the image goes, andderivedFromsays what the image comes from (IMG-USR-1).derivedFromremoved (IMG-USR-4)derivedFrom: trueused the identity ofmetadata.derivedFrom: { sopClassUID, sopInstanceUID }named the source. Ametadatawith aSOPInstanceUIDalso made a derived image.derivedFromis a naturalized instance, or an array of them.Each item needs
SOPClassUIDandSOPInstanceUID. The old shapesthrow an error that names the absent keyword.
SourceImageSequencehas one item for each source, in order.instance, and more than one source.
SOPClassUIDwithderivedFrom(IMG-USR-3)SOPClassUIDof themetadataor of thesource, when the metadata had one.
SOPClassUIDstays the value of the base: Secondary Capturefor
imageBase.new pixels, and the source SOP class does not describe it.
ImageTypeis a base value (IMG-USR-5)ORIGINAL\PRIMARYorDERIVED\SECONDARYafter
createInstance. Only an override replaced the value.secondaryCaptureImageBasesetsORIGINAL\PRIMARY, andderivedImageBasesetsDERIVED\SECONDARY. A custom base, aninherited value, and an override each replace the value, in the
order of CORE-USR-6. A custom base without
secondaryCaptureImageBasehas noImageType.attribute is a base block (CORE-IMP-4).
lossy: falsealways gave"00". Aratioof 0 was dropped.Only the
lossyobject gave the method and the ratio."01"keeps"01", also forlossy: false. Aratioof 0 stays. The method and the ratio of each lossy sourcecome first, then the values of the
lossyobject. The ratios pairwith the methods by position. When the count of ratios is not the
count of methods, the result has no ratio, and the builder logs a
warning.
lossy image stays lossy, and keeps the values of all lossy steps.
lossywithoutderivedFrom(IMG-USR-8): text only.lossyhasno effect without
derivedFrom, with no warning, as at 7c9e118.derivedImageAttributesandderivedImageBase(IMG-USR-7)
derivedImageBase(derivedFrom, { lossy })is a base block, andderivedImageAttributesis the plain function under the block. Acustom
baseDicomwithderivedImageBasegives the same result asthe
derivedFromoption. Both functions throw an error for anempty
derivedFrom. ThederivedFromoption ofbuildImageDatasettakes an empty array as noderivedFrom.All builders (CORE-USR-n)
InstanceNumber(CORE-USR-5)InstanceNumberwas always 1, forencapsulate,buildImageDataset, andbuildVideoDataset.dataLevel: "series", theInstanceNumberis theInstanceNumberof the sample instance, plus 1. The sample instanceis
instance, or the first item wheninstanceis an array. Theother items have no effect on
InstanceNumber. The value is 1 whenthe sample instance has no usable value (not an integer, less than
0, or 2147483647 or more), or when
dataLeveldoes not inherit theseries. An
InstanceNumberoverride replaces the value.must follow the sample instance, and must not repeat its number.
SeriesNumberofnextSeriesNumberBase(CORE-USR-12)nextSeriesNumberBaseread each value withNumber(...). Anyfinite number counted. A series number 7.5 gave
SeriesNumber8.5,and a negative or a very large value also counted.
this range, or a value that is not an integer, does not count, and
the other series still count. For example,
[7.5, 2]gives 3, and[3e9, 4]gives 5. When the largest series number is 2147483647(the IS maximum), the next
SeriesNumberis 1. This is the integerrule of CORE-USR-5.
SeriesNumberis IS, and a valueoutside the IS range is not a valid series number.
without
StudyDate,StudyTime, orSeriesNumbergave a datasetwithout these attributes.
""(Type 2 empty),and a source value replaces the empty value.
undefinedoverrides (CORE-USR-8)undefinedoverride wroteundefinedinto the dataset.undefinedoverride replaces the base or inherited value,and the default
postProcessdeletes the key. The result does nothave the attribute.
nulland""give a Type 2 empty value.postProcessoption andremoveUndefinedAttributesexport(CORE-USR-1, CORE-USR-15)
postProcess(dataset, context)runs on the merged resultinside
createInstance. The default isremoveUndefinedAttributes,which deletes each top-level key with an
undefinedvalue. Eachbuilder passes
postProcessthrough tocreateInstance.instance(CORE-USR-4)levelsthat listedSOPInstanceUID,SOPClassUID, orInstanceNumbercopied the identity ofinstanceinto the result. An inheritedSOPClassUIDthatdiffered from the base gave a warning.
identity, so the result does not get it. A custom
levelscopieseach identity keyword that it lists. The
SOPClassUIDwarning isremoved:
CONSISTENCY_KEYSis["Modality"]. CORE-USR-4 is newtext, and states this rule.
after
createInstance.except for the payload attributes that a builder sets after
createInstance. Each builder README lists these attributes. Videokeeps an override of the pixel attributes that the H.264 transfer
syntaxes mandate (VID-USR-3).
instance): text only. The first itemgives the inherited attributes and the sample
InstanceNumber(CORE-USR-5). The predecessor rule uses all of the items, when the base
includes
predecessorBase.Changes since the pushed HEAD 64992a8
The base of this comparison is the pushed branch (HEAD 64992a8). This change
is also a user-facing API change against
origin/1.0-beta, because #577merged the old option shape. Each caller of
createInstance,encapsulate,or
encapsulatePdfthat passes attributes at the top level must change.All builders (CORE-USR-1, CORE-USR-6 to 8, CORE-USR-12, CORE-USR-15)
overrides(CORE-USR-1, CORE-USR-6)attributes together.
createInstancetook each option that was notbaseDicom,instance,dataLevel,levels, orpredecessorasan override, for example
encapsulatePdf(bytes, { instance, DocumentTitle: "v1" }). Thebuilders
encapsulate,encapsulatePdf,buildImageDataset,buildVideoDataset,encapsulateVideo, andcreateVideoEventSourcepassed the rest of their options through in the same way.
separate
overridesobject, for exampleencapsulatePdf(bytes, { instance, overrides: { DocumentTitle: "v1" } }).These rules of the old top-level overrides now apply to
overrides: the precedence,nulland"", and theModalitywarning. An
undefinedoverride now removes the attribute (see thepostProcessentry below). The attribute-key filter is removed (see thenext entry).
controls and attributes lets a misspelled control key become an
attribute, or lets an attribute keyword hide a control key.
createInstancedropped each top-level key that wasnot a DICOM attribute, and logged the warning "is not a DICOM
attribute". An attribute key was a dictionary keyword, a
registerTagkeyword, a tag of 8 hexadecimal digits, or an_key.createInstancewrote each attribute key into the dataset.key that is not a control of
createInstance(baseDicom,instance,dataLevel,levels,predecessor,postProcess,overrides) has no effect, and gives no warning and no error. Eachkey of the resolved
overridesgoes into the merge, also a key withan
undefinedvalue (CORE-USR-8). No key ofoverridesgives a warning.that
createInstanceuses, so it gives no error (CORE-IMP-11). TheJSDoc gives the correct inputs.
metadataentry above: a top-levelmetadatakey hasno effect.
overridesis a naturalized DICOM provider (CORE-USR-1, CORE-IMP-2)overridesoption. The attributes were top-level options.overrideshas the same forms asbaseDicom: a naturalizedobject, a function that gets the context and returns a naturalized
object, an array of these (a later entry wins), or a block from
combineBases.createInstanceresolvesoverridesonce withresolveBase(overrides, context), and keeps theundefinedvalues(CORE-USR-8). The resolved attributes have the highest precedence.
overridesholds only DICOM attributes. The control keys ofcreateInstanceand of each builder are options, and never go inoverrides. Anoverridesthat isundefinedornullgives no overrides, the same as a
baseDicomofnull.resolveBasedoes not check the type of its input, as at 64992a8(CORE-IMP-11).
overridesis a source ofattributes, the same as
baseDicom, so it takes the same forms.undefinedoverride removes the attribute; newpostProcess(CORE-USR-1, CORE-USR-8, CORE-USR-15, CORE-IMP-1)
createInstanceskipped anundefinedoverride, andthe base or inherited value stayed. No
postProcessoption.undefinedoverride replaces the base or inherited value.postProcess(dataset, context)is a newcreateInstancecontrol.createInstancecalls it once on the merged result, and returns itsreturn value. The default is
removeUndefinedAttributes, a newexport of
@dcmjs-org/core. This function deletes each top-levelkey with an
undefinedvalue, and does not change the items of asequence. Thus with the default, an
undefinedoverride removes theattribute. A caller who wants a Type 2 empty value gives
""ornull. A custompostProcessreplaces the default. Each builderpasses
postProcessthrough tocreateInstance, and does not callit again after it sets its payload attributes.
attribute of the base or of
instance, and the dataset holds noundefinedvalue. A caller can also change the merged result in onestep.
instance(CORE-USR-12, CORE-IMP-10)instancethrew an error. The error toldthe caller to use
DicomMetaDictionary.naturalizeDatasetfirst.createInstancedoes not detect DICOM JSON, as in feat: @dcmjs-org/encapsulated — encapsulated PDF wrap and unwrap #577 and at7c9e118. CORE-USR-12 tells the caller to naturalize DICOM JSON
first. CORE-IMP-10 described the detection of DICOM JSON, and is
marked as removed.
instanceis atype, and the JSDoc gives the type (CORE-IMP-11).
context.optionsof a function block (CORE-IMP-4, CORE-USR-11)context.optionsheld the controls and the attributestogether. A custom block read an attribute as
context.options.SeriesDescription.context.optionsis the options object thatcreateInstancegets. The attributes are in
context.options.overrides, in the formthat the caller gave. The context has no resolved overrides.
createInstanceresolvesbaseDicomfirst, thenoverrides, withthe same context (CORE-IMP-1). A custom block that reads
context.options.<keyword>now getsundefined, and no erroroccurs.
(CORE-USR-11). The shape follows the new option shape.
InstanceNumber(CORE-USR-5, CORE-USR-14)dataLevel: "series", theInstanceNumberwasthe largest
InstanceNumberof theinstanceitems in the targetseries, plus 1. The target series was the top-level
SeriesInstanceUIDoption, else the series of the first item. Anitem counted when its
SeriesInstanceUIDwas the target series.InstanceNumberis theInstanceNumberof the sampleinstance, plus 1. The sample instance is
instance, or the firstitem when
instanceis an array. The other items and aSeriesInstanceUIDoverride have no effect onInstanceNumber. Thevalue is 1 when the sample instance has no usable value, or when
dataLeveldoes not inherit the series. AnInstanceNumberoverride replaces the value.
simple rule, and the rule does not depend on the overrides.
_metaoverride merges into the base_meta(CORE-USR-6,CORE-IMP-1)
_metaoverride replaced the whole_metaof the base. For example,overrides: { _meta: { ImplementationVersionName: "x" } }gave aresult without
TransferSyntaxUID._metaoverride that is an object merges into the base_metakey by key. A key of the override wins, and the other keysof the base stay.
buildImageDatasetsets Explicit VR Little Endianwhen the merged
_metahas noTransferSyntaxUID(IMG-USR-2). Thevideo builders now also keep the other
_metakeys (see "One_metarule for each builder" below)._metakey must not lose the transfer syntax._metais a copy (encapsulate,encapsulatePdf,buildImageDataset)_metaof the result was the same object as the_metaoverride of the caller. A change to the result_metaalsochanged the object of the caller.
_metais a new object. The_metaoverride of thecaller does not change.
mutable object with the caller.
IMG-USR-6, VID-USR-1)
createInstanceremovedSOPInstanceUID,SOPClassUID,InstanceNumber,MediaStorageSOPInstanceUID, andMediaStorageSOPClassUID(INSTANCE_IDENTITY_KEYS) from theinherited attributes. A custom
levelsthat listed these keywordsdid not copy them. CORE-USR-4 said "The result never gets the
identity of
instance".copyAttributesByLevel(instance, dataLevel, { levels }). Thedefault levels do not hold the identity, so the result does not get
it. A custom
levelscopies each identity keyword that it lists.An override still wins (CORE-USR-6). With
predecessor: trueand abase that includes
predecessorBase(the encapsulated bases, seethe last section),
PredecessorDocumentsSequencestill holds theidentity of
instance. TheInstanceNumberrule (CORE-USR-5) doesnot change.
CONSISTENCY_KEYSstays["Modality"], so an inheritedSOPClassUIDgives no warning.copyAttributesByLevelcopies what the level list says, and gives the correct value. An
extra removal only makes the code more complex. The behaviour is
the same as at
origin/1.0-betaand at 7c9e118.encapsulatePdf(ENC-USR-n)baseDicom: undefinedkeeps the PDF baseencapsulatePdf(bytes, { baseDicom: undefined })usedencapsulatedBase. The result had noSOPClassUIDand no MIMEtype.
baseDicomofundefinedusesencapsulatedPdfBase, thesame as no
baseDicom.undefinedoption means "thedefault".
buildImageDataset(IMG-USR-2, IMG-USR-8)overrides(IMG-USR-2)threw the error "comes from the decoded image and cannot be
overridden".
createInstance. The value from the decoded image replaces ageometry keyword in
overrides, with no error and no warning. Thisrule applies to each form of
overrides. This is the payload ruleof CORE-USR-13, the same as VID-USR-2. A geometry keyword at the top
level has no effect (CORE-USR-7). The builder does not check the
8-hex tag form of a geometry keyword, for example
"00280010". TheJSDoc names the keyword form only.
value that the builder replaces, and does not use, so it gives no
error (CORE-IMP-11).
lossywithoutderivedFrom(IMG-USR-8)with derivedFrom, and is ignored".
lossywithoutderivedFromhas no effect, and the builderlogs no warning.
derivedFrom, thebuilder does not use
lossy, solossygives no warning(CORE-IMP-11).
base, of
instance, and of the overrides. Then the builder wroteevery geometry attribute, with a default for each value that the
decoded image did not give:
SamplesPerPixel1,PhotometricInterpretationMONOCHROME2(orRGBfor 3 samples),BitsStored=BitsAllocated,HighBit=BitsStored- 1,PixelRepresentation0, andPlanarConfiguration0. Forencapsulated,BitsAllocatedwas 8 andNumberOfFrameswas 1.decodedImage.rowsanddecodedImage.columnswere required.image gives it: a
decodedImagefield,BitsAllocatedfrom thetyped array,
PixelRepresentation1 from a signed typed array, orNumberOfFramesfromencapsulated.frames.length. The decoded valuereplaces the value from the base, from
instance, or fromoverrides. For an attribute that the decoded image does not give,the builder writes nothing, and the value from the base, from
instance, or fromoverridesstays. The builder removes nogeometry attribute, and writes no default.
HighBitis a decoded value when the decoded image determinesit. The builder writes
decodedImage.highBitwhen it is given.Otherwise, when
decodedImagegivesbitsStored, the builder writesHighBit=bitsStored- 1. Otherwise, the builder writes noHighBit, and the value from the base, frominstance, or fromoverridesstays. The builder does not calculateHighBitfromBitsAllocated, or from aBitsStoredof the base, ofinstance,or of
overrides.the merged value).
RowsandColumnscan come from the mergeddataset, and must be positive integers. For the pixel-length check
only, an absent
SamplesPerPixelorNumberOfFramesis 1. Thebuilder does not write these values.
decodedImage.numberOfFramesof 1 is written. A count of 1from
encapsulated.frames.lengthalone is not written, except toreplace an existing
NumberOfFrames.PlanarConfigurationuses the effectiveSamplesPerPixel. At64992a8, the builder wrote
PlanarConfigurationwhen the decodedsamplesPerPixelwas more than 1. Now the builder writes a decodedplanarConfigurationwhen the effectiveSamplesPerPixel(thedecoded value, else the merged value) is more than 1. Thus
overrides: { SamplesPerPixel: 3 }with a decodedplanarConfigurationwritesPlanarConfiguration. A decodedsamplesPerPixelof 1 with a decodedplanarConfigurationwritesno
PlanarConfiguration, as at 64992a8.photometric attributes in
overrides, or inherit them, when thedecoder does not give them, for example
MONOCHROME1withBitsStored12 over 16-bit pixels.ConversionTypeis a base value (IMG-USR-5, IMG-IMP-3)createInstance, the builder setConversionTypeto"WSD"when the result was Secondary Captureand had no
ConversionType. Thusoverrides: { ConversionType: undefined }andoverrides: { ConversionType: "" }both gave"WSD".secondaryCaptureImageBasesetsConversionType: "WSD". Thebuilder writes no default after
createInstance. An overridereplaces the value, an
undefinedoverride removes it, and""gives a Type 2 empty value (CORE-USR-6, CORE-USR-8). A custom base
without
secondaryCaptureImageBasegives noConversionType, thesame as for
ImageType. A Secondary CaptureSOPClassUIDoverrideon another base no longer adds
"WSD".ConversionTypeis not a payloadattribute, so an override must win (CORE-USR-6).
@dcmjs-org/encapsulatedalready hadConversionTypeas a basevalue (
encapsulatedDocumentBase).pixelsthrows (IMG-USR-9)Float32ArraygaveBitsAllocated32, and aFloat64Arraygave
BitsAllocated64. The writer wrote the float bytes as integerpixels, with no error.
Float32Arrayor aFloat64Arrayaspixelsthrows theerror "buildImageDataset: decodedImage.pixels is a Float32Array;
DICOM integer pixel data needs an integer typed array" (the name of
the array class is in the message). The check is in
decodedGeometry, where the builder uses the typed array forBitsAllocatedandPixelRepresentation.(CORE-IMP-11): a wrong value gave a wrong file.
PixelRepresentation1 for anInt32Array(IMG-USR-2)Int8Arrayor anInt16ArraygavePixelRepresentation1. AnInt32Arraygave noPixelRepresentation.Int32Arrayalso givesPixelRepresentation1, whendecodedImagehas nopixelRepresentation. AUint32ArraygivesBitsAllocated32, as before.pixels.
Validation rule (CORE-USR-7, CORE-IMP-11, all four packages)
do not check their inputs, except for the errors that a requirement
names. The result of an input that is not correct is not defined."
Six errors had no requirement.
key has no effect, and a user requirement names each error that a
function throws for a wrong input value.
checks a value where it uses the value, when a wrong value gives a
wrong result. A function does not check the JS type of an input
that the JSDoc declares, because the JSDoc gives the type, and a
type check blocks a future input form (a stream, an async result,
another source).
protect the user from a wrong file, and are user guarantees.
dataLevel: CORE-USR-3 (new text).hierarchicalReferenceserror is new text in CORE-USR-9.encapsulatePdfwithout the%PDF-magic, andextractEncapsulatedPdfon a dataset that is not an EncapsulatedPDF: ENC-USR-11 (new).
buildImageDataset: pixels andencapsulatedtogether, anencapsulatedwithouttransferSyntaxUIDor frames,RowsandColumns, the photometric interpretation againstSamplesPerPixel,bitsAllocatedagainst the typed array,numberOfFramesagainst the frames, and the pixel byte length:IMG-USR-9 (new; the list moved from IMG-USR-2).
parseJpegInfo(no SOI, no SOF, truncated SOF): IMG-USR-9.derivedFromkeywords and an emptyderivedFrom: IMG-USR-4 andIMG-USR-7, no change.
fragmentBytesrange:VID-USR-5, no change.
extractEncapsulatedVideoon a dataset that is not a video:VID-USR-6 (new text).
parseMp4Infoerrors (noftyp, a malformed box, nomoov, novideo track, no
mdhd, no sample description, a malformedstts,no frame rate): VID-USR-7 (new).
check below threw an error.
copyAttributesByLevel(and thuscreateInstance): "instance mustbe a naturalized dataset". A string
instancenow gives noinherited attributes. An empty array
instancenow fails with aTypeErrorincopyAttributesByLevel, where the code reads thefirst item. An
instancethat is not naturalized (for example DICOMJSON,
{}, or a string) gives no inherited attributes, and theinherited levels get no new UID. The result then has no
StudyInstanceUID, and withdataLevel: "series"also noSeriesInstanceUID. No error occurs. CORE-USR-12 now states thisbehaviour. The user decided to keep the behaviour (review 10, N1).
toExactArrayBufferof@dcmjs-org/encapsulated: "encapsulateexpects an ArrayBuffer or Uint8Array". A value that is not a view
now goes through as it is.
encapsulatePdfthen throws the%PDF-error for most wrong values, and aTypeErrorforundefined.encapsulategives no error for a wrong value.buildImageDataset: "decodedImage.pixels must be a typed array",and the "expected an ArrayBuffer or typed array" error of its
toExactArrayBuffer(pixels and frames). Withoutpixelsandwithout
encapsulated, the builder now fails with aTypeErrorwhere it reads
pixels.BYTES_PER_ELEMENT. AnArrayBufferaspixelsgives aBitsAllocatedofNaN, and the pixel-lengtherror of IMG-USR-9.
buildImageDataset: theArray.isArray(encapsulated.frames)partof the
encapsulatedcheck. The check now tests thatframeshasa length.
of the JSDoc (CORE-IMP-11).
_metaand the other builder results (CORE-USR-10, CORE-USR-13)(CORE-USR-10, ENC-USR-5)
!overrides[key]. An overrideModalityofundefined,null, or""gave the warning, but the result had no inheritedModality.At 64992a8,
createInstanceskipped anundefinedoverride, sothe warning was correct for
undefined.Object.hasOwn(overrides, "Modality"). Anoverride with each value, also
undefined,null, or"",decides the result, and gives no warning. CORE-USR-10 adds "and
overridesdoes not giveModality".builder keeps the inherited value, but the override replaced it.
_metarule for each builder (CORE-USR-13, CORE-IMP-7,ENC-USR-10, IMG-USR-2, VID-USR-2)
encapsulatecopied_meta,and changed no key.
buildImageDatasetcopied_meta, and setonly the transfer syntax.
buildVideoDatasetreplaced all of_meta, so anImplementationVersionNameoverride did not stay._metais a new object. A builder changes only_meta.TransferSyntaxUID, in the shape{ Value: [uid] }, andkeeps each other key of the merged
_meta.buildVideoDatasetnow gives
{ ...dataset._meta, TransferSyntaxUID: { Value: [ts] } }.caller that adds one
_metakey keeps the others.createVideoEventSourcekeeps the_metaof its dataset (VID-USR-2,CORE-IMP-7)
datasetToMetaDictassignedthe file meta group to the
_metaof the returneddataset, in aflat shape (
TransferSyntaxUID: "1.2.840.10008.1.2.4.104.1", plusMediaStorageSOPClassUID,FileMetaInformationVersion, and theothers). A writer that read
_meta.TransferSyntaxUID.Value[0]foundno value.
datasetToMetaDictmakes the file meta group in a localobject. The returned
dataset._metais the_metaofbuildVideoDataset. The fallback transfer syntax usesEXPLICIT_LITTLE_ENDIANfrom@dcmjs-org/core.same as the shape of
buildVideoDataset.createVideoEventSourcekeeps the other_metakeys (VID-USR-2)the fixed keys. An
ImplementationVersionNameoverride ofXstayedon the returned
dataset._meta, but the file haddcmjs-0.0._meta(itsValue[0]).createVideoEventSourcealways setsTransferSyntaxUID,MediaStorageSOPClassUID, andMediaStorageSOPInstanceUIDfrom the dataset. It setsFileMetaInformationVersion,ImplementationClassUID, andImplementationVersionNameonly when the dataset_metahas novalue. Thus a caller can set these three keys, and other file meta
keys, in
overrides._meta. The returneddataset._metadoes notchange.
builder keeps the other
_metakeys, and the file must agree withthe dataset.
_metavalue (CORE-USR-6): text only. Give each_metavalue in the shape{ Value: [value] }, for example_meta.TransferSyntaxUID = { Value: ["1.2.840.10008.1.2.1"] }.buildVideoDatasetwrites no attribute for an absentmp4Infofield (VID-USR-2)
mp4Infowithout, for example,cineRategaveCineRate: undefinedin the result, and removed aCineRateoverride.
postProcesshad already run, so the key stayed.CineRate,FrameTime,NumberOfFrames,Rows, andColumnsonly whenmp4Infogives the value. AparseMp4Inforesult always gives the fields, so only acaller-built
mp4Infoshows the change.mp4ByteLengthstaysrequired.
decoded geometry of
buildImageDataset(IMG-USR-2).Exports
PDF_MIME_TYPEis now in the index of@dcmjs-org/encapsulated.normalizeFragmentBytesis no longer in the index of@dcmjs-org/video. It stays a module export ofencapsulatedVideo.jsfor
fromVideo.jsand the tests. No other package on this branch usesit.
Changes since the pushed HEAD c8aa8a7
The base of this comparison is the pushed branch (HEAD c8aa8a7).
Image and video builders (CORE-USR-9, IMG-USR-10, VID-USR-8)
imageBaseandvideoBasedo not includepredecessorBaseimageBaseandvideoBaseincludedpredecessorBase. Withpredecessor: trueand aninstance, animage or a video result had
PredecessorDocumentsSequence. Aninstancewithout one of the four reference UIDs threw thepredecessor error. CORE-USR-9 said "The default base of each builder
has it."
encapsulatedBaseandencapsulatedPdfBase) includepredecessorBase. With the defaultbase,
predecessor: truehas no effect onbuildImageDataset,buildVideoDataset,encapsulateVideo, andcreateVideoEventSource. The result has noPredecessorDocumentsSequence, and the builder throws nopredecessor error. A caller can add the block to a custom base, for
example
combineBases(imageBase, predecessorBase). CORE-USR-9 nowsays that
predecessorBaseis an optional base block. IMG-USR-10and VID-USR-8 are new.
predecessorBaseis onemore way to add default attributes, and not a feature that every
builder must support.
PredecessorDocumentsSequencereplaces anolder document, so the encapsulated documents use the block now.
Future document types can also add the block to their default base.
predecessorBase,hierarchicalReferences, and thepredecessorcontrol stay in
@dcmjs-org/core. Before f875187, the image andvideo builders had no
predecessorBaseeither.🤖 Generated with Claude Code