Checking DICOM File

I need to select all valid DICOM files from a folder. I can recursively select all files from a folder with the extension * .DCM. But any file with * .DCM also received and such a file is not valid DICOM File.

What is the best way.

It seemed to me that I was reading a few bytes of the file and checking.

Or

Any other method or any other EXE that we check.

Thanks Harsha

Edit: Solution: I finally used dcmftest.exe for verification. I hope I'm on the right track. -Harsha

+3
source share
6 answers

DICOM , , IOD. , . DCMCHECK DCMTK .

+3

DICOM, . . ( !), , SOP, .

, DICOM DICM 0x80, 0x84 .

, ( 8 0), , .

EDIT: RAR. , Rar!. , , RAR, CRC, , RAR ( ).

+11

FYI, .dcm DICOM, , ( 3- DICOM, ). DICOM , " ISO 9660 ". , , DICOMDIR, 10 12 .

ruslik DICOM. DICM , DICOM. .

+4

, , , , . , , . 4 , . , .

#

public static class Dicom
{
    public static bool IsDicomFile(this Stream s)
    {
        //Create an empty 4 byte array
        byte[] dba = new byte[4];

        //Seek to 0x80
        s.Seek(128, SeekOrigin.Begin);

        //Read the following 4 dba
        s.Read(dba, 0, 4);

        //Compare to 'DICM'
        return dba.SequenceEqual(new byte[4] {68, 73, 67, 77});
    }

    public static bool IsDicomFile(this MemoryStream ms)
    {
        return ((Stream)ms).IsDicomFile();
    }

    public static bool IsDicomFile(this FileStream fs)
    {
        return ((Stream)fs).IsDicomFile();
    }

    public static bool IsDicomFile(this FileInfo fi)
    {
        return fi.OpenRead().IsDicomFile();
    }
}

VB.NET

<Extension()> _
Public Function IsDicomFile(ByVal s As Stream) As Boolean
    'Create an empty 4 byte array
    Dim dba() As Byte = New Byte(3) {}

    'Seek to 0x80
    s.Seek(128, SeekOrigin.Begin)

    'Read the subsequent 4 bytes
    s.Read(dba, 0, 4)

    'Compare to 'DICM'
    Return dba.SequenceEqual(New Byte(3) {68, 73, 67, 77})
End Function

<Extension()> _
Public Function IsDicomFile(ByVal ms As MemoryStream) As Boolean
    Return DirectCast(ms, Stream).IsDicomFile
End Function

<Extension()> _
Public Function IsDicomFile(ByVal fs As FileStream) As Boolean
    Return DirectCast(fs, Stream).IsDicomFile
End Function

<Extension()> _
Public Function IsDicomFile(ByVal fi As FileInfo) As Boolean
    Return fi.OpenRead().IsDicomFile
End Function
+4
< > Java dcm4che--dcmvalidate : dcmvalidate --iod [..] [..] DICOM . - :  -h, -   - xml  -V, - : $ dcmvalidate --iod etc/dcmvalidate/dicomdir-iod.xml DICOMDIR DICOMDIR IOD, etc/dcmvalidate/dicomdir.xml
+1

: "DICM" , , DICOM v3.

Previous versions of DICOM did not have a preamble. 100% valid DICOM files that can be viewed, with all the necessary DICOM tags, etc., and imported into the DICOM node, do not have a preamble.

I check with OFFIS to see if the licensed version of DCMCHECK has this limitation or not, but I have not heard from them.

0
source

Source: https://habr.com/ru/post/1787658/


All Articles