Validating DICOM File

Harsha picture Harsha · Jan 25, 2011 · Viewed 8.5k times · Source

I have to pick all valid DICOM Files from folder. I can recursively pick all the files from the folder which have *.DCM extension. But any file with *.DCM also picked up and such file is not valid DICOM File.

What is best way.

I thought of reading few byte of the file and validating.

Or

Any Other Method or any other EXEs we have which validates.

Thank you, Harsha

Edit: Solution for the problem: I finally used the dcmftest.exe for verification. Hope I am on right track. -Harsha

Answer

ruslik picture ruslik · Jan 25, 2011

You want to recognize DICOM files, not to validate. There is big difference. Validation means (at least!) that all the tags required for its SOP class are present.

Recognition is easy, as the DICOM file has to contain text DICM at the offset 0x80, so that tags start at the offset 0x84 of file.

Note that sometimes only the serialized dataset is stored (starting with tag group 8 at file offset 0), and these are more difficult to recognize, but are not standard.

EDIT: As an example, consider a RAR archive. It's easy to recognize, because it starts with Rar!. However, to be sure that it's a valid RAR archive, you have to decompress all the files and check their CRCs, and this is something that could be done only by RAR itself (and it's slow).