Eliminate double iteration through dicom headers