problem with 'Howto: Add an item to a sequence' example

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Geert Vandenbussche
Posts: 13
Joined: Tue, 2018-11-13, 09:05

problem with 'Howto: Add an item to a sequence' example

#1 Post by Geert Vandenbussche »

Hi,

Compiled / installed DCMTK 3.6.3 on Ubuntu 14.04 (g++ (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4).
using the following example (https://support.dcmtk.org/redmine/proje ... quenceItem):

Code: Select all

#include "dcmtk/config/osconfig.h" 
#include "dcmtk/dcmdata/dctk.h" 

int main(int argc, char *argv[]) 
{
    DcmFileFormat fileformat;
    if (fileformat.loadFile("test.dcm").good())
    {        
	DcmItem *item = NULL;
        DcmDataset *dataset = fileformat.getDataset();
        if (dataset->findOrCreateSequenceItem(DCM_ReferencedImageSequence, item, -2 /* append */).good())
        {
            item->putAndInsertString(DCM_ReferencedSOPClassUID, UID_CTImageStorage);
            item->putAndInsertString(DCM_ReferencedSOPInstanceUID, "1.2.276.0.7230010.3.1.4.1787205428.14833.1256718852.966062");
            fileformat.saveFile("test_out.dcm");
        }
    }
    return 0;
}
compiled using:

Code: Select all

g++ dcmtk_sample.cpp -I /tmp/dcmtk-3.6.3-install/usr/local/include -pthread -ldcmdata -lz -loflog -lofstd -L /tmp/dcmtk-3.6.3-install/usr/local/lib/i386-linux-gnu/
when running this against an image object the sequence framework is added:

Code: Select all

(0008,1140) SQ (Sequence with undefined length #=1)     # u/l, 1 ReferencedImageSequence
  (fffe,e000) na (Item with undefined length #=0)         # u/l, 1 Item
  (fffe,e00d) na (ItemDelimitationItem)                   #   0, 0 ItemDelimitationItem
(fffe,e0dd) na (SequenceDelimitationItem)               #   0, 0 SequenceDelimitationItem
but the items are not added.
Any idea's?

best regards,

Geert Vandenbussche

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: problem with 'Howto: Add an item to a sequence' example

#2 Post by J. Riesmeier »

What is the return value of your putAndInsertString() calls?
Did you make sure that the data dictionary is actually loaded?

Geert Vandenbussche
Posts: 13
Joined: Tue, 2018-11-13, 09:05

Re: problem with 'Howto: Add an item to a sequence' example

#3 Post by Geert Vandenbussche »

Loading the dictionary solved the problem.

Code: Select all

(0008,1140) SQ (Sequence with undefined length #=1)     # u/l, 1 ReferencedImageSequence
  (fffe,e000) na (Item with undefined length #=2)         # u/l, 1 Item
    (0008,1150) UI =CTImageStorage                          #  26, 1 ReferencedSOPClassUID
    (0008,1155) UI [1.2.276.0.7230010.3.1.4.1787205428.14833.1256718852.966062] #  58, 1 ReferencedSOPInstanceUID
  (fffe,e00d) na (ItemDelimitationItem)                   #   0, 0 ItemDelimitationItem


Apologies for the noob question. C++ is new to me and I also must get acquainted with the DCMTK library.
I'll dive in some books to get some deeper knowledge, in order to incorporate this library into a migration engine.

Thanks for the support!

Sergey Prokudaylo
Posts: 11
Joined: Mon, 2020-09-07, 14:47

Re: problem with 'Howto: Add an item to a sequence' example

#4 Post by Sergey Prokudaylo »

Dear collegues, what a dictionary you are talking about above ? I have similar problem with putAndInsertString...


Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest