How to write tag to multiframe

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Sergey Prokudaylo
Posts: 11
Joined: Mon, 2020-09-07, 14:47

How to write tag to multiframe

#1 Post by Sergey Prokudaylo »

Dear All,
I try to write tag to CT multiframe, namely DCM_XRayTubeCurrentInmA. This tag in my file is twice wrapped in sequence. This is my code:

Code: Select all

		DcmFileFormat fileformat;

		if (fileformat.loadFile("D:/xxx/test.dcm").good() cout << "File opened \n" << endl;
		else 
		{
		cout << cout << "File opened \n" << endl;
		return;
		}

		DcmDataset* Dataset = fileformat.getDataset();

		DcmSequenceOfItems* dcmSqPerFrame;
		DcmSequenceOfItems* dcmSqCTExposure;

		if (Dataset->findAndGetSequence(DCM_PerFrameFunctionalGroupsSequence, dcmSqPerFrame, true, true).good())
		{
			int i = 0;
			auto* item = dcmSqPerFrame->getItem(i);
			while (item)
			{
				if (item->findAndGetSequence(DCM_CTExposureSequence, dcmSqCTExposure, true, true).good())
				{
/*1*/					if(dcmSqCTExposure->getItem(0)->findAndGetOFStringArray(DCM_XRayTubeCurrentInmA, XRayTubeCurrentInmAstr, true).good()) cout << XRayTubeCurrentInmAstr <<"\n";
/*2*/					if(dcmSqCTExposure->getItem(0)->putAndInsertString(DCM_XRayTubeCurrentInmA, "22").good()) cout << "tag is written\n";
				}
				i++;
				item = dcmSqPerFrame->getItem(i);
			}
		}

		if (fileformat.saveFile("D:/xxx/result.dcm").good()) cout << "File saved\n" << endl;
The line /*1*/, reading current value of particula frame, works perfect.
The line /*2*/, where I set the current, doesn't work, while good() returns true.
What do I wrong ? What should be changed to write tag value when tag is wrapped in sequence twice.

With kindest regards, Sergey.

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: How to write tag to multiframe

#2 Post by Michael Onken »

Hi,

it took me some time but look at the meaning of the 4th parameter of findAndGetSequence() :-) As for example in:

Code: Select all

if (item->findAndGetSequence(DCM_CTExposureSequence, dcmSqCTExposure, true, true).good())
Best regards,
Michael

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

Re: How to write tag to multiframe

#3 Post by Sergey Prokudaylo »

Thanks a lot, it works, I've changes 4th parameters to "false" as in call

Code: Select all

Dataset->findAndGetSequence(DCM_PerFrameFunctionalGroupsSequence, dcmSqPerFrame, true, false).good()
so in call

Code: Select all

item->findAndGetSequence(DCM_CTExposureSequence, dcmSqCTExposure, true, false).good()
obviously omitting of 4th paramenter in findAndGetSequence also works.
Thanks a lot again.

Post Reply

Who is online

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