Class: Dataset
One parsed DICOM dataset - the structural shell shipped by Phase 2.
Phase 2 public surface: fileMeta, warnings. The internal element
map is stored on _elements (protected) and Phase 3 promotes it to
the public get / has / elements / getAll navigation API per
D-42.
Example
import { parseDicom } from "@cosyte/dicom";
const ds = parseDicom(buf);
console.log(ds.fileMeta?.transferSyntaxUID);
for (const w of ds.warnings) {
console.warn(w.code, w.message);
}
Extended by
Constructors
Constructor
new Dataset(
init):Dataset
Internal
Construct a new structural Dataset. Phase 2 freezes the warnings
array at the model boundary (sibling message.ts lines 117–118).
Parameters
init
DatasetInit
Returns
Dataset
Properties
_elements
protectedreadonly_elements:ReadonlyMap<string,Element>
Internal
Element map, keyed by uppercase 8-hex tag. Phase 3 promotes to
public navigation surface; Phase 2 keeps it protected so only
subclasses (Item, future Phase-3 extensions) can introspect.
fileMeta
readonlyfileMeta:FileMeta|undefined
warnings
readonlywarnings: readonlyDicomParseWarning[]
Accessors
image
Get Signature
get image():
ImageView
Pixel-interpretation + geometry view (§4.2–§4.5). Surfaces exactly
what a renderer needs without guessing: rescaleSlope/signed/
photometricInterpretation stay absent rather than defaulted, and the
three pixel-spacing tags are distinct. Memoised on first read.
Example
import { parseDicom } from "@cosyte/dicom";
const img = parseDicom(buf).image;
img.rescaleSlope; // undefined ⇒ MUST NOT assume 1
Returns
patient
Get Signature
get patient():
PatientView
Patient-identity view (§4.1). Fail-safe typed-absent fields; id is
not globally unique - match on the {id, issuerOfId, ...} tuple
plus otherIds, never on a bare (0010,0020). Memoised on first read.
Example
import { parseDicom } from "@cosyte/dicom";
const p = parseDicom(buf).patient;
p.name?.alphabetic.familyName; // structured PN, never flattened
Returns
series
Get Signature
get series():
SeriesView
Series-identity & co-registration view (§4.1, §4.3). A shared
frameOfReferenceUid means images are spatially co-registered.
Memoised on first read.
Example
import { parseDicom } from "@cosyte/dicom";
const s = parseDicom(buf).series;
s.modality; // "CT"
Returns
study
Get Signature
get study():
StudyView
Study-identity view (§4.1). instanceUid is the cross-system study
key; accessionNumber ties it to the order. Memoised on first read.
Example
import { parseDicom } from "@cosyte/dicom";
const s = parseDicom(buf).study;
s.instanceUid; // "1.2.840.113619..."
Returns
Methods
elements()
elements(): readonly
Element[]
All elements in this dataset, in parse (insertion) order.
Returns
readonly Element[]
Example
import { parseDicom } from "@cosyte/dicom";
const ds = parseDicom(buf);
for (const el of ds.elements()) console.log(el.tag, el.vr);
get()
get(
tag):Element|undefined
Look up a single element by tag. Tags are normalised to 8-char
uppercase hex, so "7fe00010" and "7FE00010" resolve to the same
element. Returns undefined when the tag is absent.
Parameters
tag
string
Returns
Element | undefined
Example
import { parseDicom } from "@cosyte/dicom";
const ds = parseDicom(buf);
const rows = ds.get("00280010"); // Rows
if (rows?.value.kind === "numbers") console.log(rows.value.values[0]);
getAll()
getAll(
tag): readonlyElement[]
All elements matching a tag as an array (never undefined). A dataset
holds at most one element per tag, so this returns a 0- or 1-length
array - the convenience complement of Dataset.get for callers
that prefer an always-array shape.
Parameters
tag
string
Returns
readonly Element[]
Example
import { parseDicom } from "@cosyte/dicom";
const ds = parseDicom(buf);
for (const el of ds.getAll("00080060")) console.log(el.value);
has()
has(
tag):boolean
true when an element with the given tag is present (case-insensitive).
Parameters
tag
string
Returns
boolean
Example
import { parseDicom } from "@cosyte/dicom";
const ds = parseDicom(buf);
if (ds.has("00100010")) console.log("has Patient's Name");