Error while writing private tags in DcmDataset

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Akshaybar Singh
Posts: 13
Joined: Mon, 2014-03-03, 09:53

Error while writing private tags in DcmDataset

#1 Post by Akshaybar Singh »

Hi Members,

I am trying to add private tags in exiting dicom file using DCMTK V3.6.
I have found some stuff after finding the string "Howto: Add private data elements to a DICOM dataset" and using the same in my code..
Private creator tag writing successful but getting error as below
"ERROR 0001:0007 Illegal call, perhaps wrong parameter" while writing private tags(tag1,tag2).

I have created private dictionary and tag writing code as below.

Code:
=================================================================================================
DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.loadDictionary("C:\\Tprivate.dic");
dcmDataDict.unlock();

DcmFileFormat inFile;
inFile.loadFile("c:\\0002.dcm");
DcmDataset *dset = inFile.getDataset();

if (!dset->tagExists(DcmTag(0x0029, 0x0010))) //private creator exists
{
dset->putAndInsertString(DcmTag(0x0029, 0x0010,EVR_LO), "mycomp"); //private creator

DcmTag tag1(0x0029, 0x1023);
tag1.setPrivateCreator("mycomp");
dset->putAndInsertString(tag1, "T1"); //private tag writing

DcmTag tag2(0x0029, 0x1027);
tag2.setPrivateCreator("mycomp");
dset->putAndInsertString(tag2, "T2"); //private tag writing

inFile.saveFile("c:\\2_edit.dcm");

}
=================================================================================================



Private Dictionary:
-----------------------------------------------------
(0029,"mycomp",1023) LO Unknown 1
(0029,"mycomp",1027) DS Unknown 1

-----------------------------------------------------

Please help me to resolve the above query.

Thanks & Regards
Akshay

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1437
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: Error while writing private tags in DcmDataset

#2 Post by Marco Eichelberg »

Lookup of Value Representations based on a private creator is not active when you create a dataset.
You have to include the VR explicitly in your call to putAndInsertString, just as you do here:

Code: Select all

putAndInsertString(DcmTag(0x0029, 0x0010,EVR_LO), "mycomp")

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

Re: Error while writing private tags in DcmDataset

#3 Post by J. Riesmeier »

Alternatively, you could pass the Private Creator string to the DcmTag constructor as a third parameter (introduced 2011-08-23).

Post Reply

Who is online

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