Information about dicom Header - DICOM

This is a discussion on Information about dicom Header - DICOM ; Hi I would have to create a software for create dicom file I studied the format but they are not successful to understand the structure of tag..How can I recognize them in the file?...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Information about dicom Header

  1. Information about dicom Header

    Hi I would have to create a software for create dicom file I studied
    the format but they are not successful to understand the structure of
    tag..How can I recognize them in the file?


  2. Re: Information about dicom Header


    gnu.nico@gmail.com wrote:
    > Hi I would have to create a software for create dicom file I studied
    > the format but they are not successful to understand the structure of
    > tag..How can I recognize them in the file?


    Hi Nico,

    I am not sure I understand your question. Are you trying to find out
    if a binary file is a DICOM file or not. If so this is not a trivial
    task to do. In theory all DICOM files are marked with a magic number
    (DICM at offset 128 in the file). But I still see files without
    preamble and you have to use a complex heuristic to find out whether or
    not they are DICOM files.

    HTH
    -M


  3. Re: Information about dicom Header


    Mathieu Malaterre wrote:
    > gnu.nico@gmail.com wrote:
    > > Hi I would have to create a software for create dicom file I studied
    > > the format but they are not successful to understand the structure of
    > > tag..How can I recognize them in the file?

    >
    > Hi Nico,
    >
    > I am not sure I understand your question. Are you trying to find out
    > if a binary file is a DICOM file or not. If so this is not a trivial
    > task to do. In theory all DICOM files are marked with a magic number
    > (DICM at offset 128 in the file). But I still see files without
    > preamble and you have to use a complex heuristic to find out whether or
    > not they are DICOM files.
    >
    > HTH
    > -M


    Sorry for replying that late.

    I had to do nearly the same as you might have to do.
    First of all (AFAIK) there are two different kinds of DICOM files.
    The implicit format might be the one which is easier to parse.
    Each data element starts with the tag group followed by the tag
    element. Each of them are two byte long. The next 4byte will represent
    the length (in bytes) of the following data. The VR (Value
    Representation) is implicit defined by the VR of the Tag.
    I used the following datastructures in C:
    struct dcom_tag {
    unsigned short group;
    unsigned short element;
    };

    struct dcom_tag_vr {
    struct dcom_tag tag;
    enum vr_type vr;
    const unsigned char *desc;
    };
    Depending on the length I allocated the amount of characters needed.

    With this information you should be able to parse the file located at:
    http://www.wolfram.com/products/webm...oads/brain.dcm

    The file format which Mathieu already mentioned is the explicit format.
    This format is identified by the string "DICM" at offset 128.
    This is the much more complicated format. In this case the VR is stored
    as two bytes after the tag information. The length field - which is
    following the VR field - is now only 2byte long.
    Depending on the VR it is possible to do nesting with tags. For this
    case there are special Tags which will identify a series of tags. A
    sequence delimiter will then end this sequence.

    I strongly recommend the DICOM specs:
    http://www.dicomwiki.com/wiki/index....DICOM_Standard

    Especially the parts 3, 5 and 6 might help you.

    Different character encodings as well as big endian / little endian
    don't make it easier to read the contents of DICOM files.

    Have fun using DICOM.

    Regards,
    Jochen


  4. Re: Information about dicom Header


    Jochen wrote:
    > I had to do nearly the same as you might have to do.
    > First of all (AFAIK) there are two different kinds of DICOM files.
    > The implicit format might be the one which is easier to parse.
    > Each data element starts with the tag group followed by the tag
    > element. Each of them are two byte long. The next 4byte will represent
    > the length (in bytes) of the following data. The VR (Value
    > Representation) is implicit defined by the VR of the Tag.
    > I used the following datastructures in C:
    > struct dcom_tag {
    > unsigned short group;
    > unsigned short element;
    > };
    >
    > struct dcom_tag_vr {
    > struct dcom_tag tag;
    > enum vr_type vr;
    > const unsigned char *desc;
    > };
    > Depending on the length I allocated the amount of characters needed.
    >
    > With this information you should be able to parse the file located at:
    > http://www.wolfram.com/products/webm...oads/brain.dcm


    There is a SQ in the dataset, how do you handle that with your data
    structure ?

    > The file format which Mathieu already mentioned is the explicit format.


    AFAIK there is no difference between explicit and implicit (well I mean
    except the encoding of the element with/without VR). I believe you are
    talking about the old ACR-NEMA format where there was neither no
    Meta-Header, nor Preamble. Anyway as of DICOM v3, you have to specify
    both the preamble and the MetaHeader (in explicit) before adding the
    dataset (that can be written in either implicit or explicit form)

    > This format is identified by the string "DICM" at offset 128.
    > This is the much more complicated format. In this case the VR is stored
    > as two bytes after the tag information. The length field - which is
    > following the VR field - is now only 2byte long.
    > Depending on the VR it is possible to do nesting with tags. For this
    > case there are special Tags which will identify a series of tags. A
    > sequence delimiter will then end this sequence.
    >
    > I strongly recommend the DICOM specs:
    > http://www.dicomwiki.com/wiki/index....DICOM_Standard


    Nice wiki !

    -M


  5. Re: Information about dicom Header


    Mathieu Malaterre wrote:
    > Jochen wrote:
    > > I had to do nearly the same as you might have to do.
    > > First of all (AFAIK) there are two different kinds of DICOM files.
    > > The implicit format might be the one which is easier to parse.
    > > Each data element starts with the tag group followed by the tag
    > > element. Each of them are two byte long. The next 4byte will represent
    > > the length (in bytes) of the following data. The VR (Value
    > > Representation) is implicit defined by the VR of the Tag.
    > > I used the following datastructures in C:
    > > struct dcom_tag {
    > > unsigned short group;
    > > unsigned short element;
    > > };
    > >
    > > struct dcom_tag_vr {
    > > struct dcom_tag tag;
    > > enum vr_type vr;
    > > const unsigned char *desc;
    > > };
    > > Depending on the length I allocated the amount of characters needed.
    > >
    > > With this information you should be able to parse the file located at:
    > > http://www.wolfram.com/products/webm...oads/brain.dcm

    >


    Hi Mathieu,

    > There is a SQ in the dataset, how do you handle that with your data
    > structure ?
    >
    > > The file format which Mathieu already mentioned is the explicit format.


    I don't store the the header-information in the data-structure. The
    only purpose of this structure is to predefine all needed tags at
    compile time. My intention is to parse the file and filter out the
    necessary information in which I'm interested. The whole other crump
    will be thrown away by my parser. The main thing I'm interested in is
    the pixel data as well as other usefull information as the diffusion
    gradient.


    >
    > AFAIK there is no difference between explicit and implicit (well I mean
    > except the encoding of the element with/without VR). I believe you are
    > talking about the old ACR-NEMA format where there was neither no
    > Meta-Header, nor Preamble. Anyway as of DICOM v3, you have to specify
    > both the preamble and the MetaHeader (in explicit) before adding the
    > dataset (that can be written in either implicit or explicit form)
    >


    That seems to be right. Thanks for the details. Based on my little
    experience I assumed that having a preamble must be the indicator for
    the explicit format. But as you wrote is that assumption wrong.


    cheers

    Jochen

    > > This format is identified by the string "DICM" at offset 128.
    > > This is the much more complicated format. In this case the VR is stored
    > > as two bytes after the tag information. The length field - which is
    > > following the VR field - is now only 2byte long.
    > > Depending on the VR it is possible to do nesting with tags. For this
    > > case there are special Tags which will identify a series of tags. A
    > > sequence delimiter will then end this sequence.
    > >
    > > I strongly recommend the DICOM specs:
    > > http://www.dicomwiki.com/wiki/index....DICOM_Standard

    >
    > Nice wiki !
    >
    > -M



+ Reply to Thread