Function to scan a directory of DICOM files and return a structure variable containing information from a user-defined set of DICOM tags. Basically, it's MATLAB's built-in "dicominfo.m" but up to 100x faster (depending on how many tags you request) with X times more stability issues ¯\_(ツ)_/¯
This code was inspired by Brunno Machado de Campos's "alt_dicominfo" which you should check out as it might suit your needs better:
1) "Enhanced" DICOM files (i.e. 1 file per N-Dimensional acquisition vs. the 1 file per 2D slice of the "classic" DICOM format) are not (yet?) fully supported. If asked to parse such a file, fast_dcm_head should work for tags that are common across all slices/timepoints/dynamics - like "PatientName" or "Manufacturer" - but not for tags with variable information like "DiffusionBValue" or "ImagePositionPatient"
2) fast_dcm_head gets it's speed from reading the first 50k bytes of a DICOM file as 8-bit unsigned integers and then simply searching this vector for patterns of 4 (or 6) numbers that correspond to user-specified DICOM tags (and VR types). Thus, there is a distinct possibility of getting false positive matches (especially when the file being read has implicit VR encoding and especially when the search pattern has two or three 0's). In these cases, fast_dcm_head assumes the first match is the right one, and that might not be the case.
Unknown Issues (an incomplete list, of course)
1) Endianness: I haven't gotten my hands on any DICOM files that have big-endian encoding, so I can't test whether fast_dcm_head will work properly in that case. If it detects big-endian data, it will warn you and then try in earnest to read the header.