From bb750f079954f4e4b290cc6aed7bcb5e53e5ba9b Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Wed, 29 May 2024 17:39:49 -0400 Subject: [PATCH] Improve comment about magic word not present. (#318) --- read.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/read.go b/read.go index fe610eb3..eb45cc92 100644 --- a/read.go +++ b/read.go @@ -151,15 +151,17 @@ func (r *reader) readValue(t tag.Tag, vr string, vl uint32, isImplicit bool, d * // readHeader reads the DICOM magic header and group two metadata elements. // This should only be called once per DICOM at the start of parsing. func (r *reader) readHeader() ([]*Element, error) { - // Check to see if magic word is at byte offset 128. If not, this is a - // non-standard non-compliant DICOM. We try to read this DICOM in a - // compatibility mode, where we rewind to position 0 and blindly attempt to - // parse a Dataset (and do not parse metadata in the usual way). + // Check for Preamble (128 bytes) + magic word (4 bytes). data, err := r.rawReader.Peek(128 + 4) if err != nil { return nil, err } if string(data[128:]) != magicWord { + // If magic word is not at byte offset 128 this is a non-standard + // non-compliant DICOM. We try to read this DICOM in a compatibility + // mode, where we rewind to position 0 and blindly attempt to parse + // a Dataset (and do not parse metadata in the usual way), which is + // why we return nil error. return nil, nil }