The DICOM file format: preamble, DICM, and File Meta

  • A DICOM Part 10 file consists of a 128-byte preamble, a 4-byte DICM prefix, File Meta Information, and the data set.
  • The DICM prefix at byte 128 acts as a magic number so parsers can confirm a file is valid DICOM.
  • File Meta Information always uses Explicit VR Little Endian, regardless of the dataset's own transfer syntax.
  • DIMSE network transfers omit the preamble and File Meta Information because the association already negotiated the syntax.
  • Some DICOM files lack the preamble because legacy tools wrote bare datasets without Part 10 headers.

The DICOM file format encapsulates a medical dataset with a 128-byte preamble, a 4-byte DICM prefix, and File Meta Information. Defined in Part 10 of the standard (PS3.10), this structure lets software decode imaging files on disk without guessing their encoding.

When software engineers first encounter medical imaging, they often expect plain PNG or JPEG files. In reality, DICOM packages clinical attributes and pixel arrays together in one binary container. Understanding this layout helps you parse files reliably, avoid corruption, and design clean imaging pipelines.

What is the DICOM file format structure?

The DICOM file format structure defines how medical imaging objects are stored on disk and exchanged over HTTP.

In classic networking, two DICOM systems negotiate data types and byte encoding before sending an image. A stored file does not have an active network session to explain what it contains. The file itself must provide that context.

To solve this, DICOM PS3.10 Chapter 7 defines the Part 10 media storage format. A Part 10 file wraps the clinical dataset with standardized headers. Any compliant reader can open the file, inspect the metadata, and decode the image.

The format uses four sequential components:

  1. File Preamble: 128 bytes of unconstrained application data or zero padding.
  2. DICOM Prefix: 4 bytes containing the ASCII characters DICM.
  3. File Meta Information: Standardized metadata elements from group 0002.
  4. Data Set: The clinical imaging payload, including patient tags and pixel data.

The PS3.10 byte layout: preamble, prefix, and File Meta

The byte layout defined in DICOM PS3.10 divides every stored file into three distinct sequential sections.

The first 128 bytes form the File Preamble. The DICOM standard does not restrict what you put here. Most systems fill these 128 bytes with 0x00 null bytes. Some tools use the space for compatibility wrappers, such as TIFF headers. Your parser can safely skip these 128 bytes.

Immediately after the preamble, bytes 128 through 131 contain the DICOM Prefix. This 4-byte field contains the uppercase ASCII string DICM (0x44 0x49 0x43 0x4D). It works as a magic number. File utilities and parsers check this offset to confirm that a file is a valid DICOM object.

Byte 132 marks the start of the File Meta Information. This section consists of data elements from group 0002. It describes the file itself rather than clinical patient details.

Key attributes in the File Meta Information include:

  • File Meta Information Group Length (0002,0000): Total byte length of all following group 0002 tags.
  • File Meta Information Version (0002,0001): A 2-byte field (0x00 0x01) indicating the header version.
  • Media Storage SOP Class UID (0002,0002): Identifies the clinical data type, such as CT Image Storage.
  • Media Storage SOP Instance UID (0002,0003): Unique identifier for this instance. See our guide on understanding DICOM UIDs.
  • Transfer Syntax UID (0002,0010): Specifies how the rest of the file is encoded.

Why does File Meta Information always use Explicit VR Little Endian?

File Meta Information always uses Explicit VR Little Endian so any DICOM parser can read the header without prior configuration.

The clinical dataset that follows can use any transfer syntax. It might use big-endian bytes, Implicit VR, or compressed pixel data. If the header used the same encoding as the dataset, a parser would face a deadlock. It could not decode the header without knowing the syntax, but it could not read the syntax without decoding the header.

To prevent this problem, PS3.10 Section 7.1 fixes the encoding of group 0002. All group 0002 attributes must use Explicit VR Little Endian (UID 1.2.840.10008.1.2.1).

In this syntax:

  • Multi-byte integers store the least significant byte first.
  • Every element includes its two-character Value Representation (VR), such as UI or UL.
  • Parsers do not need an external data dictionary to read the header.

Once your parser reads (0002,0010), it extracts the Transfer Syntax UID. It uses the length in (0002,0000) to jump directly to the dataset. It then switches its decoder to the dataset syntax. To learn more about encoding modes, see our guide on Implicit vs Explicit VR in DICOM.

How does a Part 10 file differ from a network stream?

A DICOM Part 10 file differs from a network stream because DIMSE network transfers omit the preamble and File Meta Information entirely.

When a hospital scanner sends images via DIMSE C-STORE, it does not send files. It streams raw datasets inside network protocol data units (PDUs). The two devices establish an association first. During this handshake, they negotiate the SOP Class and Transfer Syntax for each presentation context.

Because both systems agree on the syntax during association setup, the network stream needs no group 0002 header. It sends raw DICOM tags starting at group 0008. To compare network protocols, read our guide on DICOM C-STORE vs DICOMweb STOW-RS.

If you write raw C-STORE network bytes straight to disk, you get a bare dataset. Most DICOM viewers reject that file because it lacks the DICM prefix and group 0002 header.

To turn a network stream into a valid Part 10 file, software must:

  1. Read the negotiated Transfer Syntax and SOP Class from the association state.
  2. Write a 128-byte preamble and the 4-byte DICM prefix.
  3. Build the group 0002 File Meta Information elements.
  4. Calculate the group length in (0002,0000).
  5. Prepend this header to the received clinical dataset.

Managing raw TCP sockets, DIMSE handshakes, and timeouts across hospital firewalls takes ongoing operational effort. A managed gateway like Dicomly handles this translation for you. It receives DIMSE streams from hospitals over mutual TLS. It then delivers each study as standard STOW-RS HTTP POST requests to your web endpoint (see how to receive deliveries). You pay a monthly fee, but you avoid maintaining raw socket listeners.

Why do some DICOM files have no preamble?

Some DICOM files have no preamble because legacy software or simple network dump scripts write raw datasets directly to disk without adding Part 10 headers.

Before the Part 10 standard was published, early imaging systems stored bare datasets. In addition, some developers extract datasets from network captures without wrapping them in group 0002. These files usually end in .dcm, but they lack the 128-byte preamble and DICM prefix.

If your code assumes every file has a DICM prefix, it will fail on these files. Resilient parsers use a fallback check:

  1. Read 4 bytes at offset 128.
  2. If those bytes match DICM, parse the file as standard Part 10.
  3. If they do not match, seek back to byte 0 and inspect the first tag.
  4. If the first 2 bytes represent group 0002 or 0008, parse the file as a bare dataset.

In Python, the pydicom library provides this fallback through the force=True flag:

import pydicom

# force=True reads datasets that lack the Part 10 preamble
dataset = pydicom.dcmread("scan.dcm", force=True)
print(f"Modality: {dataset.Modality}")

Modern web services and cloud archives require complete Part 10 files. All DICOMweb STOW-RS payloads use complete Part 10 binary instances.

How to inspect and parse DICOM file headers

You can inspect and parse DICOM file headers using standard command-line tools or programming libraries.

On Linux and macOS, you can use xxd to check the preamble and prefix directly:

xxd -l 144 scan.dcm

This command prints the first 144 bytes of the file. You will see 128 null bytes, followed by DICM at byte 128 (0x80). Tag (0002,0000) appears immediately after.

For deeper inspection, the DCMTK toolkit includes the dcmdump utility:

dcmdump +P "0002,*" scan.dcm

This command displays all group 0002 File Meta Information elements. You can verify the Transfer Syntax UID and SOP Class UID before reading pixel data.

Understanding the Part 10 format gives you full visibility into your imaging pipeline. You can validate incoming files, inspect encodings safely, and handle legacy files. To explore core concepts further, read our guide on DICOM SOP Classes and Transfer Syntaxes. You can also configure your webhook destination using our endpoints guide.

Dicomly builds infrastructure for healthcare software teams that receive DICOM studies from hospitals. Why we built Dicomly →

Sources

  1. DICOM Standard Part 10 (PS3.10, Chapter 7 — DICOM File Format) (dicom.nema.org)
  2. DICOM Standard Part 5 (PS3.5, Chapter 7 — The Data Set) (dicom.nema.org)
  3. DICOM Standard Part 5 (PS3.5, Chapter 10 — Transfer Syntax) (dicom.nema.org)
  4. DICOM Standard Part 18 (PS3.18, Section 10.5 — Store Instances / STOW-RS) (dicom.nema.org)

Start receiving DICOM today.

Early access. No credit card. First endpoint free.