mitk::Image::Pointer mitk::ITKDICOMSeriesReaderHelper::Load( const StringContainer& filenames,
                                                             bool correctTilt,
                                                             const GantryTiltInformation& tiltInfo )
{
  if ( filenames.empty() )
  {
    MITK_DEBUG
      << "Calling LoadDicomSeries with empty filename string container. Probably invalid application logic.";
    return nullptr; // this is not actually an error but the result is very simple
  }

  typedef itk::GDCMImageIO DcmIoType;
  DcmIoType::Pointer io = DcmIoType::New();

  try
  {
    if ( io->CanReadFile( filenames.front().c_str() ) )
    {
      io->SetFileName( filenames.front().c_str() );
      io->ReadImageInformation();

      if ( io->GetPixelType() == itk::ImageIOBase::SCALAR )
      {
        switch ( io->GetComponentType() )
        {
          switch3DCase(DcmIoType::UCHAR, unsigned char) switch3DCase(DcmIoType::CHAR, char) switch3DCase(
            DcmIoType::USHORT, unsigned short) switch3DCase(DcmIoType::SHORT, short)
              switch3DCase(DcmIoType::UINT, unsigned int) switch3DCase(DcmIoType::INT, int) switch3DCase(
                DcmIoType::ULONG, long unsigned int) switch3DCase(DcmIoType::LONG, long int)
                switch3DCase(DcmIoType::FLOAT, float) switch3DCase(DcmIoType::DOUBLE, double) default
            : MITK_ERROR
              << "Found unsupported DICOM scalar pixel type: (enum value) "
              << io->GetComponentType();
        }
      }
      else if ( io->GetPixelType() == itk::ImageIOBase::RGB )
      {
        switch ( io->GetComponentType() )
        {
          switch3DCase(DcmIoType::UCHAR, itk::RGBPixel<unsigned char>) switch3DCase(
            DcmIoType::CHAR, itk::RGBPixel<char>) switch3DCase(DcmIoType::USHORT,
                                                               itk::RGBPixel<unsigned short>)
              switch3DCase(DcmIoType::SHORT, itk::RGBPixel<short>) switch3DCase(
                DcmIoType::UINT, itk::RGBPixel<unsigned int>) switch3DCase(DcmIoType::INT, itk::RGBPixel<int>)
                switch3DCase(DcmIoType::ULONG, itk::RGBPixel<long unsigned int>)
                  switch3DCase(DcmIoType::LONG, itk::RGBPixel<long int>) switch3DCase(
                    DcmIoType::FLOAT, itk::RGBPixel<float>) switch3DCase(DcmIoType::DOUBLE,
                                                                         itk::RGBPixel<double>) default
            : MITK_ERROR
              << "Found unsupported DICOM scalar pixel type: (enum value) "
              << io->GetComponentType();
        }
      }

      MITK_ERROR << "Unsupported DICOM pixel type";
      return nullptr;
    }
Пример #2
0
 Image::Pointer DicomSeriesReader::MultiplexLoadDICOMByITK4DScalar(std::list<StringContainer> &imageBlocks,
                                                                   ImageBlockDescriptor imageBlockDescriptor,
                                                                   bool correctTilt,
                                                                   const GantryTiltInformation &tiltInfo,
                                                                   DcmIoType::Pointer &io,
                                                                   CallbackCommand *command,
                                                                   Image::Pointer preLoadedImageBlock)
 {
   switch (io->GetComponentType())
   {
     case DcmIoType::UCHAR:
       return LoadDICOMByITK4D<unsigned char>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::CHAR:
       return LoadDICOMByITK4D<char>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::USHORT:
       return LoadDICOMByITK4D<unsigned short>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::SHORT:
       return LoadDICOMByITK4D<short>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::UINT:
       return LoadDICOMByITK4D<unsigned int>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::INT:
       return LoadDICOMByITK4D<int>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::ULONG:
       return LoadDICOMByITK4D<long unsigned int>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::LONG:
       return LoadDICOMByITK4D<long int>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::FLOAT:
       return LoadDICOMByITK4D<float>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     case DcmIoType::DOUBLE:
       return LoadDICOMByITK4D<double>(
         imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
     default:
       MITK_ERROR << "Found unsupported DICOM scalar pixel type: (enum value) " << io->GetComponentType();
       return nullptr;
   }
 }