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 /*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.