[Insight-users] Reading compressed DICOM files

Bing Jian bing.jian at gmail.com
Wed Dec 24 18:45:09 EST 2008


Hi all,

    I have some dicom files that are probably in compressed format as they
are
much smaller than other files of same slice size (512x512x1) in the same
folder
and there is a tag (0008,2111) called derivative description found in these
files with value
"Compress BN JPEG Lossless".  The problem I encountered is that when reading

these files using itk::GDCMImageIO, I receive the following message:

       "Must downscale data from 16 bits to 12"

To make things worse, sometimes my program aborts when trying to access data
read
from these files or it returns the wrong intensity values. However I am able
to read
these files using MATLAB and other programs. Below is the dicom reading part
of my ITK code which is based on

   Insight/Examples/IO/DicomSeriesReadImageWrite.cxx

     typedef itk::ImageSeriesReader< ImageType >        ReaderType;
    ReaderType::Pointer reader = ReaderType::New();

    typedef itk::GDCMImageIO       ImageIOType;
    ImageIOType::Pointer dicomIO = ImageIOType::New();
    reader->SetImageIO( dicomIO );

    typedef itk::GDCMSeriesFileNames NamesGeneratorType;
    NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
    nameGenerator->SetUseSeriesDetails( true );
    nameGenerator->SetRecursive(true);
    nameGenerator->SetDirectory(inputFolder);

    typedef std::vector< std::string >    SeriesIdContainer;
    const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
    SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
    SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();

    std::string seriesIdentifier;
    typedef std::vector< std::string >   FileNamesContainer;
    FileNamesContainer fileNames;
    while( seriesItr != seriesEnd ){
        seriesIdentifier = seriesItr->c_str();
        fileNames = nameGenerator->GetFileNames( seriesIdentifier );
        reader->SetFileNames( fileNames );
        reader->Update();
        image = reader->GetOutput();
        // ...
    }

The same code works well for other uncompressed dicom files in the same
folder.
I found similar questions have been asked in the mailing list, for example,
  http://www.cmake.org/pipermail/insight-users/2007-April/021955.html
However, in my case, adding
    dicomIO->UseCompressionOn();
    dicomIO->SetCompressionType(itk::GDCMImageIO::JPEG2000); // I also tried
JPEG
 does not solve the problem.


I guess I must have missed some obvious solution and would appreciate any
clue that will help me out.
Many thanks in advance and wish you all have a great holiday!


Bing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081224/7a8bcbfc/attachment.htm>


More information about the Insight-users mailing list