How to modify sequence in multiframe
Moderator: Moderator Team
-
- Posts: 11
- Joined: Mon, 2020-09-07, 14:47
How to modify sequence in multiframe
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.
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.
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: How to modify sequence in multiframe
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?Or perhaps I have to ask what for an approach should be used reduce amount of frames in multiframe CT dicom in general ?
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.
-
- Posts: 11
- Joined: Mon, 2020-09-07, 14:47
Re: How to modify sequence in multiframe
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:
but it doesn't work, all items of dcmSqPerFrame are kept. How to really erase part of them?
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);
}
}
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: How to modify sequence in multiframe
Something like the following should work:
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.
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);
}
}
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.
-
- Posts: 11
- Joined: Mon, 2020-09-07, 14:47
Re: How to modify sequence in multiframe
It works, thanks al lot!
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: How to modify sequence in multiframe
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).
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest