Eliminate double iteration through dicom headers (slightly faster)