Inspired by contrib-pydicom:
https://github.com/pydicom/contrib-pydicom/blob/cbd27f1ac523863aeba820edf796bf040d63993f/input-output/dicom_model/dicom_dir.py#L43-L50
Looks like the following should complement medio's is_dicom function:
def is_dcm(filename):
with open(filename, 'rb') as f:
x = f.read(132)
return x[128:] == b"DICM"
It is particularly useful since many times dicom files lack any extension.
I checked the above is_dcm on some data and it looks reliable.
With that, we can change the default dicom reader backend to pydicom (single and series).
Edit:
Even better, use pydicom's built-in is_dicom function (equivalent to the above is_dcm function).
Inspired by contrib-pydicom:
https://github.com/pydicom/contrib-pydicom/blob/cbd27f1ac523863aeba820edf796bf040d63993f/input-output/dicom_model/dicom_dir.py#L43-L50
Looks like the following should complement medio's
is_dicomfunction:It is particularly useful since many times dicom files lack any extension.
I checked the above
is_dcmon some data and it looks reliable.With that, we can change the default dicom reader backend to pydicom (single and series).
Edit:
Even better, use pydicom's built-in
is_dicomfunction (equivalent to the aboveis_dcmfunction).