splitting a multiframe dicom into single slice dicom

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
zeinsalah
Posts: 5
Joined: Mon, 2016-06-27, 12:14

splitting a multiframe dicom into single slice dicom

#1 Post by zeinsalah »

Hi,

I am tryig to writ a function to splitt and rewrite multiframe dicoms into a set of single frame dicom files.
I relied on the code in this "howto":

http://support.dcmtk.org/redmine/projec ... Multiframe


Code: Select all

DicomImage *image = new DicomImage(mfFileName.toAscii().data(), CIF_UsePartialAccessToPixelData, 0, 1 /* fcount */); 


    if (image->getStatus() == EIS_Normal)
    {
      int i = 0;
      QString path = "c:/temp_slices/slice_";
      do {
        QString currentFileName = path + QString::number(i) + ".dcm";

        DcmFileFormat fileformat;
        DcmDataset *dataset = fileformat.getDataset(); 

        image->writeImageToDataset(*dataset);

        OFCondition status = fileformat.saveFile(currentFileName.toAscii().data(), EXS_LittleEndianExplicit);
        if (status.bad())
          printf("Error: cannot write DICOM file (%s)\n", status.text());

        ++i;
      } while (image->processNextFrames());
    }

    delete image;
This actually worked. But I have few questions:

1. would this also work if the input file is compressed? Also regarding this, if the inut image is compressed, would it be possible to access and extract the pixel data of a frame in the middle (e.g. to generate a thumbnail of the image) without loading the whole image?

2. the generated single frame dicoms do not include and information from the input Tags (patient name, spacing, position, orientation ,...., ), practically nothing. Should these tags be explicitely set?

I would also appreciate if somebody has a better (simpler, faster, ...!) idea to do the splitting, especially if tags are automatically set :).

Much thansk,

Zein

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

Re: splitting a multiframe dicom into single slice dicom

#2 Post by J. Riesmeier »

First of all, I personally wouldn't use the DicomImage class for "splitting a multi-frame DICOM image into multiple single-frame images". The reason is: the dcmimgle/dcmimage module is for visualization (i.e. rendering) of DICOM image and nothing else.

Re. 1: If the input file is compressed, you need to add support for the corresponding decompression codec. But, as I said before, I wouldn't use the DicomImage class for this particular purpose.

Re. 2: Of course, it does not. Did you read the documentation of DicomImage::writeImageToDataset()? Copying further DICOM data elements can be done using methods from the dcmdata module (or simply use the input dataset if appropriate).

Anyway, your current approach seems to be wrong to me. One reason, in addition to the above mentioned, is that you do not check whether for the underlying SOP Class (and IOD), e.g. what about the spatial and/or temporal relationships of the "slices"? Maybe, you could first describe the background of what you intend to do before you start with programming.
would also appreciate if somebody has a better (simpler, faster, ...!) idea to do the splitting
I'm sorry to say that but your current approach is already far too simple (see above).

Post Reply

Who is online

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