Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lnogueir committed May 29, 2024
1 parent eef01d8 commit e266bbf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e266bbf

Please sign in to comment.