How to modify sequence in 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 modify sequence in multiframe

#1 Post by Sergey Prokudaylo »

Hi All,
Working with CT multiframe dicom file, I need to reduce number of frames. To do it correctly I need (at least) to reduce amount of sequence in DCM_CTExposureSequence. How it could be done ? Or perhaps I have to ask what for an approach should be used reduce amount of frames in multiframe CT dicom in general ? How to reduce number of frames in Pixeldata is clear for me, main questions concerns the sequence describing CT parameters.

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

Re: How to modify sequence in multiframe

#2 Post by J. Riesmeier »

Or perhaps I have to ask what for an approach should be used reduce amount of frames in multiframe CT dicom in general ?
What do you mean by "reduce"? Do you want to delete a number of slices / frames since they are of no interest for your purposes?

If you just want to get smaller DICOM SOP Instances, you should think about creating a "Concatenation of Instances". More details can be found in DICOM PS3.3 Section C.7.6.16.2.2.4.

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

Re: How to modify sequence in multiframe

#3 Post by Sergey Prokudaylo »

Thank you. Let me clarify my question: how to erase items in sequence ?
For example I have CT multiframe. The details of each frame are given in DCM_PerFrameFunctionalGroupsSequence, in this sequence there are some items like DCM_CTExposureSequence. As soon as I reduce number of frames I have to erase some items in DCM_PerFrameFunctionalGroupsSequence (together with modifing number of frames itself). My question is how to erase items in DCM_PerFrameFunctionalGroupsSequence? The code I've tried is:

Code: Select all

		
		if (Dataset->findAndGetSequence(DCM_PerFrameFunctionalGroupsSequence, dcmSqPerFrame, true, false).good())
		{
			int i = 0;
			auto* item = dcmSqPerFrame->getItem(i);
			while (item)
			{
				if (i > 1)	delete dcmSqPerFrame->remove(item);
				i++;
				item = dcmSqPerFrame->getItem(i);
			}
		}
but it doesn't work, all items of dcmSqPerFrame are kept. How to really erase part of them?

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

Re: How to modify sequence in multiframe

#4 Post by J. Riesmeier »

Something like the following should work:

Code: Select all

void removeSequenceItems(DcmFileFormat &dfile)
{
    DcmDataset *dset = dfile.getDataset();
    DcmSequenceOfItems *dseq = NULL;
    if (dset->findAndGetSequence(DCM_PerFrameFunctionalGroupsSequence, dseq).good())
    {
        for (unsigned long i = dseq->card(); i > 50; --i)
            delete dseq->remove(i - 1);
    }
}
This little function removes all but the first 50 items from the Per-frame Functional Groups Sequence (5200,9230).
The trick is that it removes the items from the end of the sequence, which is the most efficient way of doing it.
Last edited by J. Riesmeier on Wed, 2021-09-01, 11:16, edited 1 time in total.

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

Re: How to modify sequence in multiframe

#5 Post by Sergey Prokudaylo »

It works, thanks al lot!

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

Re: How to modify sequence in multiframe

#6 Post by J. Riesmeier »

I'm glad I was able to help. Maybe, we could introduce a helper function that removes a range of sequence items (in the future).

Post Reply

Who is online

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