Modifying Tags in the Meta Header

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
newbould
Posts: 3
Joined: Wed, 2005-01-05, 23:52

Modifying Tags in the Meta Header

#1 Post by newbould »

Hi guys (wonderful toolkit)!

I have a dicom file I am modifying. I can happily open/read/modify/save the file, except for the tags found inside the meta-header. I've tried putAndInsert'ing it using the dataset pointer, and using the metaheader pointer. Neither returns a bad code condition, but the written out file does not have a modified value at that tag (according to dcmdump)

Some bits code (... means I chopped out the rest of the line):

Code: Select all

          // set a new UID in two fields (same UID).
          // this one is not in the meta-header:
	  key.set(0x0008, 0x0018);
	  cond = ((DcmItem *)tempdataset)->findAndGetOFString(key, UID);
	  snprintf(cUID,99,"...
	  cond = ((DcmItem *)tempdataset)->putAndInsertString(key, cUID);
          // the above works beautifully

          // neither way to set the tag 0002/0003 works
  	  key.set(0x0002, 0x0003);
	  cond = ((DcmItem *)tempdataset)->putAndInsertString(key, cUID);
		if(cond.bad())
                      cout << "error: " << cond.text() << endl;  
          DcmMetaInfo *metinf = dfile.getMetaInfo();
          cond = metinf->putAndInsertString(key, cUID);	  
		if(cond.bad())
                      cout << "error: " << cond.text() << endl;  

           // just in case it helps, lets try validating:
           cond = tempfile.validateMetaInfo(EXS_Unknown);

           // we then save out the file
           cond = tempfile.saveFile(filename, metinf->getOriginalXfer()....
What blindingly obvious part am I missing? I can write out the file without the metaheader, and it works on our dicom server, however IDL's read_dicom needs a metaheader to be able to read the file.

Thanks,
Rex[/code]

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

There is currently no way to modify most of the tags in the meta-header directly. In your case you should do something like the following:

Code: Select all

// force meta-header to refresh SOP Class/Instance UIDs.
DcmItem *metaInfo = fileformat.getMetaInfo();
if (metaInfo)
{
  delete metaInfo->remove(DCM_MediaStorageSOPClassUID);
  delete metaInfo->remove(DCM_MediaStorageSOPInstanceUID);
}

newbould
Posts: 3
Joined: Wed, 2005-01-05, 23:52

#3 Post by newbould »

Ah, thank you.

Cheers,
Rex

Post Reply

Who is online

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