A DICOM file (DICOM PS3.10) starts with a fixed preamble and prefix, then the file meta
information: a short list of group 0002 data elements that say what the
file holds and how the rest of it is encoded. The element syntax is on the
data elements page.
Layout
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 128 | Preamble | Free for an application profile or implementation (some files put a TIFF header here). All 00 when unused. No tag or length. |
| 128 | 4 | Prefix | The characters DICM (44 49 43 4D). No tag or length. |
| 132 | varies | File meta elements | Group 0002, always explicit VR little endian. |
| … | varies | Data set | The rest of the file, in the transfer syntax named by (0002,0010). |
Every DICOM file has this header. The meta elements are always encoded in explicit VR
little endian (1.2.840.10008.1.2.1), whatever the transfer syntax of the
data set. Values are padded to an even length as their VR requires, and the VR
UN is not allowed. Group 0002 appears only here, never in
other data sets or inside sequences.
File meta elements
Type 1 elements must be present with a value; type 1C when a condition holds; type 3
are optional. A reader ignores 0002 elements it does not know.
| Tag | VR | Type | Name | Meaning |
|---|---|---|---|---|
(0002,0000) | UL | 1 | File Meta Information Group Length | Bytes from the end of this element to the end of the last group 0002 element. |
(0002,0001) | OB | 1 | File Meta Information Version | Two bytes, 00 01 for version 1. Bit 0 of the second byte set means a reader may interpret the header. |
(0002,0002) | UI | 1 | Media Storage SOP Class UID | The kind of object stored, such as CT Image Storage. |
(0002,0003) | UI | 1 | Media Storage SOP Instance UID | The unique identifier of this object. |
(0002,0010) | UI | 1 | Transfer Syntax UID | How the data set after the meta information is encoded (see transfer syntaxes). The JPIP referenced syntaxes are not used in files. |
(0002,0012) | UI | 1 | Implementation Class UID | Identifies the software that last wrote the file. |
(0002,0013) | SH | 3 | Implementation Version Name | Version of that software, up to 16 characters. |
(0002,0016) | AE | 3 | Source Application Entity Title | The DICOM application that wrote or last updated the file. |
(0002,0017) | AE | 3 | Sending Application Entity Title | The sender, when the data set was received over a network. |
(0002,0018) | AE | 3 | Receiving Application Entity Title | The receiver, when the data set was received over a network. |
(0002,0026) | UR | 3 | Source Presentation Address | Network address of the source application. |
(0002,0027) | UR | 3 | Sending Presentation Address | Network address of the sender. |
(0002,0028) | UR | 3 | Receiving Presentation Address | Network address of the receiver. |
(0002,0100) | UI | 3 | Private Information Creator UID | Who defined the private information below. |
(0002,0102) | OB | 1C | Private Information | Private data; required when (0002,0100) is present. |
Reading the header
- Check for
DICMat offset 128. Files without it are not PS3.10 files (some old files are a bare data set with no preamble). - Read the first element at offset 132. If it is
(0002,0000), its value says where group0002ends. - Read the meta elements as explicit VR little endian, and take the transfer syntax
from
(0002,0010). - Read the data set from the end of group
0002in that transfer syntax.
Bytes
| Element | Bytes |
|---|---|
| Prefix at offset 128 | 44 49 43 4D |
Version, 00 01 | 02 00 01 00 tag, 4F 42 “OB”, 00 00 reserved, 02 00 00 00 length 2, 00 01 |
Transfer syntax 1.2.840.10008.1.2.1 | 02 00 10 00 tag, 55 49 “UI”, 14 00 length 20, 31 2E 32 2E 38 34 30 2E 31 30 30 30 38 2E 31 2E 32 2E 31 00: 19 characters and a 00 pad |