HELP : DICOM initialization failure - DICOM

This is a discussion on HELP : DICOM initialization failure - DICOM ; Hi, I already wrote C code to generate 12lead ECG in dicom waveform format. But it can't be initialized by dicom veiwer. Is there anyone can help me to determine which part was went wrong ? Please see dcm file ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: HELP : DICOM initialization failure

  1. HELP : DICOM initialization failure

    Hi,

    I already wrote C code to generate 12lead ECG in dicom waveform
    format. But it can't be initialized by dicom veiwer. Is there anyone
    can help me to determine which part was went wrong ? Please see dcm
    file in here (zipped) : http://www.materikuliah.com/DICOMTEST.zip

    Best regards,
    Budhi

  2. Re: HELP : DICOM initialization failure

    The file doesn't seem to be a valid DICOM object.
    Tried with DCMTK dcmdump and it didn't recognize it.

    Regards,
    Rafael Sanguinetti
    CharruaSoft.com

  3. Re: HELP : DICOM initialization failure

    It is not correctly encoded.

    The tags aren't right (they need to be sorted in ascending numeric order)
    and though it seems to be explicit VR there don't seem to be any value
    lengths.

    Are you doing this by hand (!) or using a toolkit ?

    David

    00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    *
    00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    00000090 02 00 01 00 4f 42 00 00 01 00 00 00 02 00 02 00 |....OB..........|
    000000a0 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 30 |UI..1.2.840.1000|
    000000b0 38 2e 35 2e 31 2e 34 2e 31 2e 31 2e 39 2e 31 2e |8.5.1.4.1.1.9.1.|
    000000c0 31 02 00 03 00 55 49 00 00 31 2e 33 2e 36 2e 31 |1....UI..1.3.6.1|
    000000d0 2e 34 2e 31 2e 36 30 31 38 2e 31 2e 31 02 00 10 |.4.1.6018.1.1...|
    000000e0 00 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 |.UI..1.2.840.100|
    000000f0 30 38 2e 31 2e 32 2e 31 02 00 12 00 55 49 00 00 |08.1.2.1....UI..|
    00000100 31 2e 33 2e 36 2e 31 2e 34 2e 31 2e 36 30 31 38 |1.3.6.1.4.1.6018|
    00000110 2e 32 2e 31 31 31 31 31 08 00 20 00 44 41 00 00 |.2.11111.. .DA..|
    00000120 32 30 30 38 30 37 31 31 08 00 30 00 54 4d 00 00 |20080711..0.TM..|
    00000130 32 33 34 36 31 32 08 00 60 00 43 53 00 00 45 43 |234612..`.CS..EC|
    00000140 47 08 00 80 00 4c 4f 00 00 42 4d 45 20 4c 61 62 |G....LO..BME Lab|


    budhik wrote:
    > Hi,
    >
    > I already wrote C code to generate 12lead ECG in dicom waveform
    > format. But it can't be initialized by dicom veiwer. Is there anyone
    > can help me to determine which part was went wrong ? Please see dcm
    > file in here (zipped) : http://www.materikuliah.com/DICOMTEST.zip
    >
    > Best regards,
    > Budhi


  4. Re: HELP : DICOM initialization failure

    On Jul 15, 8:26 am, David Clunie wrote:
    > It is not correctly encoded.
    >
    > The tags aren't right (they need to be sorted in ascending numeric order)
    > and though it seems to be explicit VR there don't seem to be any value
    > lengths.
    >
    > Are you doing this by hand (!) or using a toolkit ?
    >
    > David
    >
    > 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    > *
    > 00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    > 00000090 02 00 01 00 4f 42 00 00 01 00 00 00 02 00 02 00 |....OB..........|
    > 000000a0 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 30 |UI..1.2.840.1000|
    > 000000b0 38 2e 35 2e 31 2e 34 2e 31 2e 31 2e 39 2e 31 2e |8.5.1.4.1.1.9.1.|
    > 000000c0 31 02 00 03 00 55 49 00 00 31 2e 33 2e 36 2e 31 |1....UI..1.3.6.1|
    > 000000d0 2e 34 2e 31 2e 36 30 31 38 2e 31 2e 31 02 00 10 |.4.1.6018.1.1...|
    > 000000e0 00 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 |.UI..1.2.840.100|
    > 000000f0 30 38 2e 31 2e 32 2e 31 02 00 12 00 55 49 00 00 |08.1.2.1....UI..|
    > 00000100 31 2e 33 2e 36 2e 31 2e 34 2e 31 2e 36 30 31 38 |1.3.6.1.4.1.6018|
    > 00000110 2e 32 2e 31 31 31 31 31 08 00 20 00 44 41 00 00 |.2.11111.. .DA..|
    > 00000120 32 30 30 38 30 37 31 31 08 00 30 00 54 4d 00 00 |20080711..0.TM..|
    > 00000130 32 33 34 36 31 32 08 00 60 00 43 53 00 00 45 43 |234612..`.CS..EC|
    > 00000140 47 08 00 80 00 4c 4f 00 00 42 4d 45 20 4c 61 62 |G....LO..BME Lab|
    >
    > budhik wrote:
    > > Hi,

    >
    > > I already wrote C code to generate 12lead ECG in dicom waveform
    > > format. But it can't be initialized by dicom veiwer. Is there anyone
    > > can help me to determine which part was went wrong ? Please see dcm
    > > file in here (zipped) :http://www.materikuliah.com/DICOMTEST.zip

    >
    > > Best regards,
    > > Budhi


    I'm doing this by hand, no toolkit used. The reason is, because I'll
    transfer the code into MSP-430 micro controller device. Since the
    micro controller has very limited flash memory capacity, I avoid using
    toolkit to reduce the file size. Please advise.

    Rgs,
    Budhi

  5. Re: HELP : DICOM initialization failure

    On Jul 15, 7:22*am, budhik wrote:
    > On Jul 15, 8:26 am, David Clunie wrote:
    >
    >
    >
    > > It is not correctly encoded.

    >
    > > The tags aren't right (they need to be sorted in ascending numeric order)
    > > and though it seems to be explicit VR there don't seem to be any value
    > > lengths.

    >
    > > Are you doing this by hand (!) or using a toolkit ?

    >
    > > David

    >
    > > 00000000 *00 00 00 00 00 00 00 00 *00 00 00 00 00 00 00 00 *|.................|
    > > *
    > > 00000080 *44 49 43 4d 88 02 00 00 *00 55 4c 00 00 31 33 36 *|DICM......UL..136|
    > > 00000090 *02 00 01 00 4f 42 00 00 *01 00 00 00 02 00 02 00 *|....OB..........|
    > > 000000a0 *55 49 00 00 31 2e 32 2e *38 34 30 2e 31 30 30 30 *|UI..1.2.840.1000|
    > > 000000b0 *38 2e 35 2e 31 2e 34 2e *31 2e 31 2e 39 2e 31 2e *|8.5.1.4.1.1.9.1.|
    > > 000000c0 *31 02 00 03 00 55 49 00 *00 31 2e 33 2e 36 2e 31 *|1.....UI..1.3.6.1|
    > > 000000d0 *2e 34 2e 31 2e 36 30 31 *38 2e 31 2e 31 02 00 10 *|.4.1..6018.1.1...|
    > > 000000e0 *00 55 49 00 00 31 2e 32 *2e 38 34 30 2e 31 30 30 *|.UI...1.2.840.100|
    > > 000000f0 *30 38 2e 31 2e 32 2e 31 *02 00 12 00 55 49 00 00 *|08.1..2.1....UI..|
    > > 00000100 *31 2e 33 2e 36 2e 31 2e *34 2e 31 2e 36 30 31 38 *|1.3.6.1.4.1.6018|
    > > 00000110 *2e 32 2e 31 31 31 31 31 *08 00 20 00 44 41 00 00 *|.2.11111.. .DA..|
    > > 00000120 *32 30 30 38 30 37 31 31 *08 00 30 00 54 4d 00 00 *|20080711..0.TM..|
    > > 00000130 *32 33 34 36 31 32 08 00 *60 00 43 53 00 00 45 43 *|234612..`.CS..EC|
    > > 00000140 *47 08 00 80 00 4c 4f 00 *00 42 4d 45 20 4c 61 62 *|G.....LO..BME Lab|

    >
    > > budhik wrote:
    > > > Hi,

    >
    > > > I already wrote C code to generate 12lead ECG in dicom waveform
    > > > format. But it can't be initialized by dicom veiwer. Is there anyone
    > > > can help me to determine which part was went wrong ? Please see dcm
    > > > file in here (zipped) :http://www.materikuliah.com/DICOMTEST.zip

    >
    > > > Best regards,
    > > > Budhi

    >
    > I'm doing this by hand, no toolkit used. The reason is, because I'll
    > transfer the code into MSP-430 micro controller device. Since the
    > micro controller has very limited flash memory capacity, I avoid using
    > toolkit to reduce the file size. Please advise.


    Budhi,

    I'l repeat here what I previously told you in private email. If you
    use the template stuff in GDCM you will NOT need to link to any
    library other than the system library and the C++ runtime library.
    This portion will not use virtual mechanism, use the C++ compiler to
    compute types and only expand to the minimal amount of operation
    needed to write a DICOM attribute.

    http://gdcm.svn.sourceforge.net/view...xx?view=markup

    For example:

    std:fstream os;
    gdcm::Attribute<0x0008,0x9007> bla =
    {"ORIGINAL","PRIMARY","T1","NONE"};
    bla.Write(os);

    2cts,
    -Mathieu

  6. Re: HELP : DICOM initialization failure

    On Jul 15, 2:52 pm, Mathieu Malaterre
    wrote:
    > On Jul 15, 7:22 am, budhik wrote:
    >
    >
    >
    > > On Jul 15, 8:26 am, David Clunie wrote:

    >
    > > > It is not correctly encoded.

    >
    > > > The tags aren't right (they need to be sorted in ascending numeric order)
    > > > and though it seems to be explicit VR there don't seem to be any value
    > > > lengths.

    >
    > > > Are you doing this by hand (!) or using a toolkit ?

    >
    > > > David

    >
    > > > 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    > > > *
    > > > 00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    > > > 00000090 02 00 01 00 4f 42 00 00 01 00 00 00 02 00 02 00 |....OB..........|
    > > > 000000a0 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 30 |UI..1.2.840.1000|
    > > > 000000b0 38 2e 35 2e 31 2e 34 2e 31 2e 31 2e 39 2e 31 2e |8.5.1.4.1.1.9.1.|
    > > > 000000c0 31 02 00 03 00 55 49 00 00 31 2e 33 2e 36 2e 31 |1....UI..1.3.6.1|
    > > > 000000d0 2e 34 2e 31 2e 36 30 31 38 2e 31 2e 31 02 00 10 |.4.1.6018.1.1...|
    > > > 000000e0 00 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 |.UI..1.2.840.100|
    > > > 000000f0 30 38 2e 31 2e 32 2e 31 02 00 12 00 55 49 00 00 |08.1.2.1....UI..|
    > > > 00000100 31 2e 33 2e 36 2e 31 2e 34 2e 31 2e 36 30 31 38 |1.3.6.1.4.1.6018|
    > > > 00000110 2e 32 2e 31 31 31 31 31 08 00 20 00 44 41 00 00 |.2.11111.. .DA..|
    > > > 00000120 32 30 30 38 30 37 31 31 08 00 30 00 54 4d 00 00 |20080711..0.TM..|
    > > > 00000130 32 33 34 36 31 32 08 00 60 00 43 53 00 00 45 43 |234612..`.CS..EC|
    > > > 00000140 47 08 00 80 00 4c 4f 00 00 42 4d 45 20 4c 61 62 |G....LO..BME Lab|

    >
    > > > budhik wrote:
    > > > > Hi,

    >
    > > > > I already wrote C code to generate 12lead ECG in dicom waveform
    > > > > format. But it can't be initialized by dicom veiwer. Is there anyone
    > > > > can help me to determine which part was went wrong ? Please see dcm
    > > > > file in here (zipped) :http://www.materikuliah.com/DICOMTEST.zip

    >
    > > > > Best regards,
    > > > > Budhi

    >
    > > I'm doing this by hand, no toolkit used. The reason is, because I'll
    > > transfer the code into MSP-430 micro controller device. Since the
    > > micro controller has very limited flash memory capacity, I avoid using
    > > toolkit to reduce the file size. Please advise.

    >
    > Budhi,
    >
    > I'l repeat here what I previously told you in private email. If you
    > use the template stuff in GDCM you will NOT need to link to any
    > library other than the system library and the C++ runtime library.
    > This portion will not use virtual mechanism, use the C++ compiler to
    > compute types and only expand to the minimal amount of operation
    > needed to write a DICOM attribute.
    >
    > http://gdcm.svn.sourceforge.net/view...ng/Source/Data...
    >
    > For example:
    >
    > std:fstream os;
    > gdcm::Attribute<0x0008,0x9007> bla =
    > {"ORIGINAL","PRIMARY","T1","NONE"};
    > bla.Write(os);
    >
    > 2cts,
    > -Mathieu


    Hi Mathieu,

    Since MSP-430 environment using pure C code, and some C++ code can't
    run well in the micro controller environment, are you pretty sure that
    the compiled bin file will run well in micro controller environment ?

    My steps are :
    1. Writing in C code based on PC.
    2. After well verified, I just move to micro controller environment,
    using IAR tools (MSP-430 main tools), and download the compiled bin
    file into the chip.

    That's why I avoid using toolkit, since file size in micro controller
    domain is very critical (unless there is toolkit that provide very
    small file size in result).

    By the way, a friend from DVT send me an error message :
    ----------
    DVT Detailed Results File
    Communication Overview:
    Session Details
    Session ID: 1
    Session Title: Media Session
    Application Entity Name: DICOM
    Application Entity Version: 3.0
    Tester: DVT
    Test Date: 7/14/2008 10:48:33 AM

    Reading media file: "C:\Temp\DICOMTEST.dcm"
    Error: Cannot get Transfer Syntax UID (0002,0010) from File Meta
    Information in: C:\Temp\DICOMTEST.dcm
    Link to Summary Result
    Error: Failed to retrieve Transfer Syntax from File Meta Information:
    "C:\Temp\DICOMTEST.dcm"
    Link to Summary Result

    RESULT: FAILED
    Number of Validation Errors: 0 - Number of Validation Warnings: 0
    Number of User Validation Errors: 0 - Number of User Validation
    Warnings: 0
    Number of General Errors: 2 - Number of General Warnings: 0
    -----------
    It looks like the (0002,0010) tag is not correctly encoded. But I
    checked my code, and read the result in hex, it seems ok (please see
    David's reply also). I'm still confusing, are the tags switched or
    wrong type (tags using unsigned int) or what ?

    Rgs,
    Budhi

  7. Re: HELP : DICOM initialization failure

    On Jul 15, 3:26 pm, budhik wrote:
    > On Jul 15, 2:52 pm, Mathieu Malaterre
    > wrote:
    >
    >
    >
    > > On Jul 15, 7:22 am, budhik wrote:

    >
    > > > On Jul 15, 8:26 am, David Clunie wrote:

    >
    > > > > It is not correctly encoded.

    >
    > > > > The tags aren't right (they need to be sorted in ascending numeric order)
    > > > > and though it seems to be explicit VR there don't seem to be any value
    > > > > lengths.

    >
    > > > > Are you doing this by hand (!) or using a toolkit ?

    >
    > > > > David

    >
    > > > > 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    > > > > *
    > > > > 00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    > > > > 00000090 02 00 01 00 4f 42 00 00 01 00 00 00 02 00 02 00 |....OB..........|
    > > > > 000000a0 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 30 |UI..1.2.840.1000|
    > > > > 000000b0 38 2e 35 2e 31 2e 34 2e 31 2e 31 2e 39 2e 31 2e |8.5.1.4.1.1.9.1.|
    > > > > 000000c0 31 02 00 03 00 55 49 00 00 31 2e 33 2e 36 2e 31 |1....UI..1.3.6.1|
    > > > > 000000d0 2e 34 2e 31 2e 36 30 31 38 2e 31 2e 31 02 00 10 |.4.1.6018.1.1...|
    > > > > 000000e0 00 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 |.UI..1.2.840.100|
    > > > > 000000f0 30 38 2e 31 2e 32 2e 31 02 00 12 00 55 49 00 00 |08.1.2.1....UI..|
    > > > > 00000100 31 2e 33 2e 36 2e 31 2e 34 2e 31 2e 36 30 31 38 |1.3.6.1.4.1.6018|
    > > > > 00000110 2e 32 2e 31 31 31 31 31 08 00 20 00 44 41 00 00 |.2.11111.. .DA..|
    > > > > 00000120 32 30 30 38 30 37 31 31 08 00 30 00 54 4d 00 00 |20080711..0.TM..|
    > > > > 00000130 32 33 34 36 31 32 08 00 60 00 43 53 00 00 45 43 |234612..`.CS..EC|
    > > > > 00000140 47 08 00 80 00 4c 4f 00 00 42 4d 45 20 4c 61 62 |G....LO..BME Lab|

    >
    > > > > budhik wrote:
    > > > > > Hi,

    >
    > > > > > I already wrote C code to generate 12lead ECG in dicom waveform
    > > > > > format. But it can't be initialized by dicom veiwer. Is there anyone
    > > > > > can help me to determine which part was went wrong ? Please see dcm
    > > > > > file in here (zipped) :http://www.materikuliah.com/DICOMTEST.zip

    >
    > > > > > Best regards,
    > > > > > Budhi

    >
    > > > I'm doing this by hand, no toolkit used. The reason is, because I'll
    > > > transfer the code into MSP-430 micro controller device. Since the
    > > > micro controller has very limited flash memory capacity, I avoid using
    > > > toolkit to reduce the file size. Please advise.

    >
    > > Budhi,

    >
    > > I'l repeat here what I previously told you in private email. If you
    > > use the template stuff in GDCM you will NOT need to link to any
    > > library other than the system library and the C++ runtime library.
    > > This portion will not use virtual mechanism, use the C++ compiler to
    > > compute types and only expand to the minimal amount of operation
    > > needed to write a DICOM attribute.

    >
    > >http://gdcm.svn.sourceforge.net/view...ng/Source/Data...

    >
    > > For example:

    >
    > > std:fstream os;
    > > gdcm::Attribute<0x0008,0x9007> bla =
    > > {"ORIGINAL","PRIMARY","T1","NONE"};
    > > bla.Write(os);

    >
    > > 2cts,
    > > -Mathieu

    >
    > Hi Mathieu,
    >
    > Since MSP-430 environment using pure C code, and some C++ code can't
    > run well in the micro controller environment, are you pretty sure that
    > the compiled bin file will run well in micro controller environment ?
    >
    > My steps are :
    > 1. Writing in C code based on PC.
    > 2. After well verified, I just move to micro controller environment,
    > using IAR tools (MSP-430 main tools), and download the compiled bin
    > file into the chip.
    >
    > That's why I avoid using toolkit, since file size in micro controller
    > domain is very critical (unless there is toolkit that provide very
    > small file size in result).
    >
    > By the way, a friend from DVT send me an error message :
    > ----------
    > DVT Detailed Results File
    > Communication Overview:
    > Session Details
    > Session ID: 1
    > Session Title: Media Session
    > Application Entity Name: DICOM
    > Application Entity Version: 3.0
    > Tester: DVT
    > Test Date: 7/14/2008 10:48:33 AM
    >
    > Reading media file: "C:\Temp\DICOMTEST.dcm"
    > Error: Cannot get Transfer Syntax UID (0002,0010) from File Meta
    > Information in: C:\Temp\DICOMTEST.dcm
    > Link to Summary Result
    > Error: Failed to retrieve Transfer Syntax from File Meta Information:
    > "C:\Temp\DICOMTEST.dcm"
    > Link to Summary Result
    >
    > RESULT: FAILED
    > Number of Validation Errors: 0 - Number of Validation Warnings: 0
    > Number of User Validation Errors: 0 - Number of User Validation
    > Warnings: 0
    > Number of General Errors: 2 - Number of General Warnings: 0
    > -----------
    > It looks like the (0002,0010) tag is not correctly encoded. But I
    > checked my code, and read the result in hex, it seems ok (please see
    > David's reply also). I'm still confusing, are the tags switched or
    > wrong type (tags using unsigned int) or what ?
    >
    > Rgs,
    > Budhi


    Currently, I'm trying to fix the encoding issue based on David's
    reply.

    Based on DICOM specification part 5 about data element with explicit
    VR, i found :

    1. For VR = "OF","OB","OW","SQ","UT","UN" the data element structure
    should be :
    Tag : 2 bytes unsigned int for group number and 2 bytes unsigned int
    for element number
    VR : 2 bytes char for "OF","OB","OW","SQ","UT","UN" and 2 bytes
    (unsigned int ?) for 0000h
    Value length : 4 bytes unsigned int
    Value : I'm not so clear (4 bytes unsigned int just like value
    length ?)

    2. For VR other than "OF","OB","OW","SQ","UT","UN" the data element
    structure should be :
    Tag : 2 bytes unsigned int for group number and 2 bytes unsigned int
    for element number
    VR : 2 bytes char for other than "OF","OB","OW","SQ","UT","UN"
    Value length : 2 bytes unsigned int
    Value : I'm not so clear (2 bytes unsigned int just like value
    length ?)

    QUESTIONS :

    1. If I need to write the (5400,0100) waveform sequence :
    Tag : It should be 54000100h
    VR : It should be "SQ" followed by 0000h
    Value length : ??
    Value : ??

    2. If I need to write the (0002,0010) transfer syntax UID :
    Tag : It should be 00020010h
    VR : It should be "UI"
    Value length : 19 (is it correct ? or should be wrote as 13h ?)
    Value : "1.2.840.10008.1.2.1" (is it correct ? so the data type should
    be char[19] ?)

    Please advise.

    best regards,
    Budhi

  8. Re: HELP : DICOM initialization failure

    Hi Budhik

    If you are going to do this from scratch, it is going to be a lot of
    work. I would strongly recommend that you build this twice, once
    with a toolkit so that the encoding is handled for you and you get
    the content of the instance right, then do a hex dump of the whole
    thing, throw the implementation away and do it again by hand but
    mimicking the contents of that hexdump with your hand coded version.

    First, what is the 0x88 byte after the "DICM" supposed to be ? There
    should be nothing between the "DICOM" and the beginning of the
    group length tag for the meta information header:

    00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    ^^

    Second, the first tag in the meta information header needs to be
    the group length of that group IN BINARY, since it is a UL value
    representation; so, if the group length is 136, the value of the
    (0002,0000) data element should be 0x88 (which, presumably not
    coincidentaly, is the extraneous byte after the "DICM").

    Third, every data element has the length of its value encoded,
    which in the case of the single value for the UL group length
    data element would be 4 bytes.

    I.e.,

    00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|

    should perhaps be

    00000080 44 49 43 4d 02 00 00 00 55 4c 04 00 88 00 00 00 |DICM....UL......|

    etc.

    Note that the group length is required for the meta information header,
    but should be used for the main data set.

    As for your other questions:

    - value lengths are required to be even, and strings are padded with
    a trailing space to make them even, except UIDs which are padded with
    a trailing null (0x00) byte to make them even

    - the easiest way to do sequences by hand is to use the delimited form
    with undefined length for the sequence and contained sequence items,
    so you will use 0xffffffff for the VL for the sequence and the items,
    and end each item with an item delimiter and the entire sequence with
    a sequence delimiter

    David

    budhik wrote:
    > On Jul 15, 3:26 pm, budhik wrote:
    >> On Jul 15, 2:52 pm, Mathieu Malaterre
    >> wrote:
    >>
    >>
    >>
    >>> On Jul 15, 7:22 am, budhik wrote:
    >>>> On Jul 15, 8:26 am, David Clunie wrote:
    >>>>> It is not correctly encoded.
    >>>>> The tags aren't right (they need to be sorted in ascending numeric order)
    >>>>> and though it seems to be explicit VR there don't seem to be any value
    >>>>> lengths.
    >>>>> Are you doing this by hand (!) or using a toolkit ?
    >>>>> David
    >>>>> 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    >>>>> *
    >>>>> 00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    >>>>> 00000090 02 00 01 00 4f 42 00 00 01 00 00 00 02 00 02 00 |....OB..........|
    >>>>> 000000a0 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 30 |UI..1.2.840.1000|
    >>>>> 000000b0 38 2e 35 2e 31 2e 34 2e 31 2e 31 2e 39 2e 31 2e |8.5.1.4.1.1.9.1.|
    >>>>> 000000c0 31 02 00 03 00 55 49 00 00 31 2e 33 2e 36 2e 31 |1....UI..1.3.6.1|
    >>>>> 000000d0 2e 34 2e 31 2e 36 30 31 38 2e 31 2e 31 02 00 10 |.4.1.6018.1.1...|
    >>>>> 000000e0 00 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 |.UI..1.2.840.100|
    >>>>> 000000f0 30 38 2e 31 2e 32 2e 31 02 00 12 00 55 49 00 00 |08.1.2.1....UI..|
    >>>>> 00000100 31 2e 33 2e 36 2e 31 2e 34 2e 31 2e 36 30 31 38 |1.3.6.1.4.1.6018|
    >>>>> 00000110 2e 32 2e 31 31 31 31 31 08 00 20 00 44 41 00 00 |.2.11111.. .DA..|
    >>>>> 00000120 32 30 30 38 30 37 31 31 08 00 30 00 54 4d 00 00 |20080711..0.TM..|
    >>>>> 00000130 32 33 34 36 31 32 08 00 60 00 43 53 00 00 45 43 |234612..`.CS..EC|
    >>>>> 00000140 47 08 00 80 00 4c 4f 00 00 42 4d 45 20 4c 61 62 |G....LO..BME Lab|
    >>>>> budhik wrote:
    >>>>>> Hi,
    >>>>>> I already wrote C code to generate 12lead ECG in dicom waveform
    >>>>>> format. But it can't be initialized by dicom veiwer. Is there anyone
    >>>>>> can help me to determine which part was went wrong ? Please see dcm
    >>>>>> file in here (zipped) :http://www.materikuliah.com/DICOMTEST.zip
    >>>>>> Best regards,
    >>>>>> Budhi
    >>>> I'm doing this by hand, no toolkit used. The reason is, because I'll
    >>>> transfer the code into MSP-430 micro controller device. Since the
    >>>> micro controller has very limited flash memory capacity, I avoid using
    >>>> toolkit to reduce the file size. Please advise.
    >>> Budhi,
    >>> I'l repeat here what I previously told you in private email. If you
    >>> use the template stuff in GDCM you will NOT need to link to any
    >>> library other than the system library and the C++ runtime library.
    >>> This portion will not use virtual mechanism, use the C++ compiler to
    >>> compute types and only expand to the minimal amount of operation
    >>> needed to write a DICOM attribute.
    >>> http://gdcm.svn.sourceforge.net/view...ng/Source/Data...
    >>> For example:
    >>> std:fstream os;
    >>> gdcm::Attribute<0x0008,0x9007> bla =
    >>> {"ORIGINAL","PRIMARY","T1","NONE"};
    >>> bla.Write(os);
    >>> 2cts,
    >>> -Mathieu

    >> Hi Mathieu,
    >>
    >> Since MSP-430 environment using pure C code, and some C++ code can't
    >> run well in the micro controller environment, are you pretty sure that
    >> the compiled bin file will run well in micro controller environment ?
    >>
    >> My steps are :
    >> 1. Writing in C code based on PC.
    >> 2. After well verified, I just move to micro controller environment,
    >> using IAR tools (MSP-430 main tools), and download the compiled bin
    >> file into the chip.
    >>
    >> That's why I avoid using toolkit, since file size in micro controller
    >> domain is very critical (unless there is toolkit that provide very
    >> small file size in result).
    >>
    >> By the way, a friend from DVT send me an error message :
    >> ----------
    >> DVT Detailed Results File
    >> Communication Overview:
    >> Session Details
    >> Session ID: 1
    >> Session Title: Media Session
    >> Application Entity Name: DICOM
    >> Application Entity Version: 3.0
    >> Tester: DVT
    >> Test Date: 7/14/2008 10:48:33 AM
    >>
    >> Reading media file: "C:\Temp\DICOMTEST.dcm"
    >> Error: Cannot get Transfer Syntax UID (0002,0010) from File Meta
    >> Information in: C:\Temp\DICOMTEST.dcm
    >> Link to Summary Result
    >> Error: Failed to retrieve Transfer Syntax from File Meta Information:
    >> "C:\Temp\DICOMTEST.dcm"
    >> Link to Summary Result
    >>
    >> RESULT: FAILED
    >> Number of Validation Errors: 0 - Number of Validation Warnings: 0
    >> Number of User Validation Errors: 0 - Number of User Validation
    >> Warnings: 0
    >> Number of General Errors: 2 - Number of General Warnings: 0
    >> -----------
    >> It looks like the (0002,0010) tag is not correctly encoded. But I
    >> checked my code, and read the result in hex, it seems ok (please see
    >> David's reply also). I'm still confusing, are the tags switched or
    >> wrong type (tags using unsigned int) or what ?
    >>
    >> Rgs,
    >> Budhi

    >
    > Currently, I'm trying to fix the encoding issue based on David's
    > reply.
    >
    > Based on DICOM specification part 5 about data element with explicit
    > VR, i found :
    >
    > 1. For VR = "OF","OB","OW","SQ","UT","UN" the data element structure
    > should be :
    > Tag : 2 bytes unsigned int for group number and 2 bytes unsigned int
    > for element number
    > VR : 2 bytes char for "OF","OB","OW","SQ","UT","UN" and 2 bytes
    > (unsigned int ?) for 0000h
    > Value length : 4 bytes unsigned int
    > Value : I'm not so clear (4 bytes unsigned int just like value
    > length ?)
    >
    > 2. For VR other than "OF","OB","OW","SQ","UT","UN" the data element
    > structure should be :
    > Tag : 2 bytes unsigned int for group number and 2 bytes unsigned int
    > for element number
    > VR : 2 bytes char for other than "OF","OB","OW","SQ","UT","UN"
    > Value length : 2 bytes unsigned int
    > Value : I'm not so clear (2 bytes unsigned int just like value
    > length ?)
    >
    > QUESTIONS :
    >
    > 1. If I need to write the (5400,0100) waveform sequence :
    > Tag : It should be 54000100h
    > VR : It should be "SQ" followed by 0000h
    > Value length : ??
    > Value : ??
    >
    > 2. If I need to write the (0002,0010) transfer syntax UID :
    > Tag : It should be 00020010h
    > VR : It should be "UI"
    > Value length : 19 (is it correct ? or should be wrote as 13h ?)
    > Value : "1.2.840.10008.1.2.1" (is it correct ? so the data type should
    > be char[19] ?)
    >
    > Please advise.
    >
    > best regards,
    > Budhi


  9. Re: HELP : DICOM initialization failure

    On Jul 15, 6:29 pm, David Clunie wrote:
    > Hi Budhik
    >
    > If you are going to do this from scratch, it is going to be a lot of
    > work. I would strongly recommend that you build this twice, once
    > with a toolkit so that the encoding is handled for you and you get
    > the content of the instance right, then do a hex dump of the whole
    > thing, throw the implementation away and do it again by hand but
    > mimicking the contents of that hexdump with your hand coded version.
    >
    > First, what is the 0x88 byte after the "DICM" supposed to be ? There
    > should be nothing between the "DICOM" and the beginning of the
    > group length tag for the meta information header:
    >
    > 00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    > ^^
    >
    > Second, the first tag in the meta information header needs to be
    > the group length of that group IN BINARY, since it is a UL value
    > representation; so, if the group length is 136, the value of the
    > (0002,0000) data element should be 0x88 (which, presumably not
    > coincidentaly, is the extraneous byte after the "DICM").
    >
    > Third, every data element has the length of its value encoded,
    > which in the case of the single value for the UL group length
    > data element would be 4 bytes.
    >
    > I.e.,
    >
    > 00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    >
    > should perhaps be
    >
    > 00000080 44 49 43 4d 02 00 00 00 55 4c 04 00 88 00 00 00 |DICM....UL......|
    >
    > etc.
    >
    > Note that the group length is required for the meta information header,
    > but should be used for the main data set.
    >
    > As for your other questions:
    >
    > - value lengths are required to be even, and strings are padded with
    > a trailing space to make them even, except UIDs which are padded with
    > a trailing null (0x00) byte to make them even
    >
    > - the easiest way to do sequences by hand is to use the delimited form
    > with undefined length for the sequence and contained sequence items,
    > so you will use 0xffffffff for the VL for the sequence and the items,
    > and end each item with an item delimiter and the entire sequence with
    > a sequence delimiter
    >
    > David
    >
    > budhik wrote:
    > > On Jul 15, 3:26 pm, budhik wrote:
    > >> On Jul 15, 2:52 pm, Mathieu Malaterre
    > >> wrote:

    >
    > >>> On Jul 15, 7:22 am, budhik wrote:
    > >>>> On Jul 15, 8:26 am, David Clunie wrote:
    > >>>>> It is not correctly encoded.
    > >>>>> The tags aren't right (they need to be sorted in ascending numeric order)
    > >>>>> and though it seems to be explicit VR there don't seem to be any value
    > >>>>> lengths.
    > >>>>> Are you doing this by hand (!) or using a toolkit ?
    > >>>>> David
    > >>>>> 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
    > >>>>> *
    > >>>>> 00000080 44 49 43 4d 88 02 00 00 00 55 4c 00 00 31 33 36 |DICM.....UL..136|
    > >>>>> 00000090 02 00 01 00 4f 42 00 00 01 00 00 00 02 00 02 00 |....OB..........|
    > >>>>> 000000a0 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 30 |UI..1.2.840.1000|
    > >>>>> 000000b0 38 2e 35 2e 31 2e 34 2e 31 2e 31 2e 39 2e 31 2e |8.5.1.4.1.1.9.1.|
    > >>>>> 000000c0 31 02 00 03 00 55 49 00 00 31 2e 33 2e 36 2e 31 |1....UI..1.3.6.1|
    > >>>>> 000000d0 2e 34 2e 31 2e 36 30 31 38 2e 31 2e 31 02 00 10 |.4.1.6018.1.1...|
    > >>>>> 000000e0 00 55 49 00 00 31 2e 32 2e 38 34 30 2e 31 30 30 |.UI..1.2.840.100|
    > >>>>> 000000f0 30 38 2e 31 2e 32 2e 31 02 00 12 00 55 49 00 00 |08.1.2.1....UI..|
    > >>>>> 00000100 31 2e 33 2e 36 2e 31 2e 34 2e 31 2e 36 30 31 38 |1.3.6.1.4.1.6018|
    > >>>>> 00000110 2e 32 2e 31 31 31 31 31 08 00 20 00 44 41 00 00 |.2.11111.. .DA..|
    > >>>>> 00000120 32 30 30 38 30 37 31 31 08 00 30 00 54 4d 00 00 |20080711..0.TM..|
    > >>>>> 00000130 32 33 34 36 31 32 08 00 60 00 43 53 00 00 45 43 |234612..`.CS..EC|
    > >>>>> 00000140 47 08 00 80 00 4c 4f 00 00 42 4d 45 20 4c 61 62 |G....LO..BME Lab|
    > >>>>> budhik wrote:
    > >>>>>> Hi,
    > >>>>>> I already wrote C code to generate 12lead ECG in dicom waveform
    > >>>>>> format. But it can't be initialized by dicom veiwer. Is there anyone
    > >>>>>> can help me to determine which part was went wrong ? Please see dcm
    > >>>>>> file in here (zipped) :http://www.materikuliah.com/DICOMTEST.zip
    > >>>>>> Best regards,
    > >>>>>> Budhi
    > >>>> I'm doing this by hand, no toolkit used. The reason is, because I'll
    > >>>> transfer the code into MSP-430 micro controller device. Since the
    > >>>> micro controller has very limited flash memory capacity, I avoid using
    > >>>> toolkit to reduce the file size. Please advise.
    > >>> Budhi,
    > >>> I'l repeat here what I previously told you in private email. If you
    > >>> use the template stuff in GDCM you will NOT need to link to any
    > >>> library other than the system library and the C++ runtime library.
    > >>> This portion will not use virtual mechanism, use the C++ compiler to
    > >>> compute types and only expand to the minimal amount of operation
    > >>> needed to write a DICOM attribute.
    > >>>http://gdcm.svn.sourceforge.net/view...ng/Source/Data...
    > >>> For example:
    > >>> std:fstream os;
    > >>> gdcm::Attribute<0x0008,0x9007> bla =
    > >>> {"ORIGINAL","PRIMARY","T1","NONE"};
    > >>> bla.Write(os);
    > >>> 2cts,
    > >>> -Mathieu
    > >> Hi Mathieu,

    >
    > >> Since MSP-430 environment using pure C code, and some C++ code can't
    > >> run well in the micro controller environment, are you pretty sure that
    > >> the compiled bin file will run well in micro controller environment ?

    >
    > >> My steps are :
    > >> 1. Writing in C code based on PC.
    > >> 2. After well verified, I just move to micro controller environment,
    > >> using IAR tools (MSP-430 main tools), and download the compiled bin
    > >> file into the chip.

    >
    > >> That's why I avoid using toolkit, since file size in micro controller
    > >> domain is very critical (unless there is toolkit that provide very
    > >> small file size in result).

    >
    > >> By the way, a friend from DVT send me an error message :
    > >> ----------
    > >> DVT Detailed Results File
    > >> Communication Overview:
    > >> Session Details
    > >> Session ID: 1
    > >> Session Title: Media Session
    > >> Application Entity Name: DICOM
    > >> Application Entity Version: 3.0
    > >> Tester: DVT
    > >> Test Date: 7/14/2008 10:48:33 AM

    >
    > >> Reading media file: "C:\Temp\DICOMTEST.dcm"
    > >> Error: Cannot get Transfer Syntax UID (0002,0010) from File Meta
    > >> Information in: C:\Temp\DICOMTEST.dcm
    > >> Link to Summary Result
    > >> Error: Failed to retrieve Transfer Syntax from File Meta Information:
    > >> "C:\Temp\DICOMTEST.dcm"
    > >> Link to Summary Result

    >
    > >> RESULT: FAILED
    > >> Number of Validation Errors: 0 - Number of Validation Warnings: 0
    > >> Number of User Validation Errors: 0 - Number of User Validation
    > >> Warnings: 0
    > >> Number of General Errors: 2 - Number of General Warnings: 0
    > >> -----------
    > >> It looks like the (0002,0010) tag is not correctly encoded. But I
    > >> checked my code, and read the result in hex, it seems ok (please see
    > >> David's reply also). I'm still confusing, are the tags switched or
    > >> wrong type (tags using unsigned int) or what ?

    >
    > >> Rgs,
    > >> Budhi

    >
    > > Currently, I'm trying to fix the encoding issue based on David's
    > > reply.

    >
    > > Based on DICOM specification part 5 about data element with explicit
    > > VR, i found :

    >
    > > 1. For VR = "OF","OB","OW","SQ","UT","UN" the data element structure
    > > should be :
    > > Tag : 2 bytes unsigned int for group number and 2 bytes unsigned int
    > > for element number
    > > VR : 2 bytes char for "OF","OB","OW","SQ","UT","UN" and 2 bytes
    > > (unsigned int ?) for 0000h
    > > Value length : 4 bytes unsigned int
    > > Value : I'm not so clear (4 bytes unsigned int just like value
    > > length ?)

    >
    > > 2. For VR other than "OF","OB","OW","SQ","UT","UN" the data element
    > > structure should be :
    > > Tag : 2 bytes unsigned int for group number and 2 bytes unsigned int
    > > for element number
    > > VR : 2 bytes char for other than "OF","OB","OW","SQ","UT","UN"
    > > Value length : 2 bytes unsigned int
    > > Value : I'm not so clear (2 bytes unsigned int just like value
    > > length ?)

    >
    > > QUESTIONS :

    >
    > > 1. If I need to write the (5400,0100) waveform sequence :
    > > Tag : It should be 54000100h
    > > VR : It should be "SQ" followed by 0000h
    > > Value length : ??
    > > Value : ??

    >
    > > 2. If I need to write the (0002,0010) transfer syntax UID :
    > > Tag : It should be 00020010h
    > > VR : It should be "UI"
    > > Value length : 19 (is it correct ? or should be wrote as 13h ?)
    > > Value : "1.2.840.10008.1.2.1" (is it correct ? so the data type should
    > > be char[19] ?)

    >
    > > Please advise.

    >
    > > best regards,
    > > Budhi


    Please make it clear....

    In my case, I need to declare transfer syntax (0002,0010) with VR of
    "UI" and the value is "1.2.840.10008.1.2.1"

    Tag : 0x00020010
    VR : "UI"
    Value length : ...............
    Value : .........................

    Sorry, sometimes real sample give much help than words explanations ^^

    Best regards,
    Budhi

  10. Re: HELP : DICOM initialization failure


    >
    > Please make it clear....
    >
    > In my case, I need to declare transfer syntax (0002,0010) with VR of
    > "UI" and the value is "1.2.840.10008.1.2.1"
    >
    > Tag : 0x00020010
    > VR : "UI"
    > Value length : 19 make it even 20 = 14 hex
    > Value : convert the text to ascii (http://www.paulschou.com/tools/xlate/) and add a trailing 00 as David told you

    Tag numbers and length are byte swapped because of the transfer
    syntax. UID is text, byte oriented and not swapped

    You need to understand the basic concept otherwise it will be very
    tough, take David's recommendation seriously!
    Anyway it's a nice exercise assuming the transfer syntax is Explicit
    Little Endian:
    >02 00 10 00 45 49 14 00 31 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 31 2e 32 2e 31 00<

    Best regards

    Thomas




+ Reply to Thread