why can't itk read dicomdir files?

hi, I tried to read dicom files which are all stored in a directory using the following code

void readDicomSeries(const std::string& dicom_dir, itk::Image<float, 3>::Pointer& out_image)
    using ImageIOType = itk::GDCMImageIO;
    ImageIOType::Pointer DicomIO = ImageIOType::New();

    using ImageReaderType3D = itk::ImageSeriesReader<itk::Image<float, 3>>;
    ImageReaderType3D::Pointer ImageReader3D = ImageReaderType3D::New();


    using NamesGeneratorType = itk::GDCMSeriesFileNames;
    NamesGeneratorType::Pointer NameGenerator = NamesGeneratorType::New();

    using SeriesIdContainer = std::vector<std::string>;
    const SeriesIdContainer& SeriesUID = NameGenerator->GetSeriesUIDs();
    SeriesIdContainer::const_iterator SeriesItr_begin = SeriesUID.begin();
    SeriesIdContainer::const_iterator SeriesItr_end = SeriesUID.end();

    while (SeriesItr_begin != SeriesItr_end)
        std::cout << SeriesItr_begin->c_str() << std::endl;

    std::string SeriesIdentifier;
    SeriesIdentifier = SeriesUID.begin()->c_str();
    using FileNamesContainer = std::vector<std::string>;
    FileNamesContainer filenames;
    filenames = NameGenerator->GetFileNames(SeriesIdentifier);

    catch (itk::ExceptionObject& err)
        std::cerr << "error, exception object caught!" << std::endl;
    out_image = ImageReader3D->GetOutput();

the files looks right, and I can open them with radiAnt software, but I got the exception that saying “GDCMSeriesFileNames (000001DDACC3E6C0): No Series were found”.
all files looks like this:

how can I solve the problem? Thank you!

Probably the images do not contain 3D geometry information. They may be secondary captures (screenshots) or they may have been corrupted (e.g., by incorrect anonymization).

RadiANT’s 2D viewer shows the image because it does not need to analyze the metadata, it just displays the stored 2D images as they are. It does not reconstruct a 3D volume. You can confirm this by trying to use RadiANT’s MPR viewer on this image series - probably it will refuse this data set.

1 Like

Thank you for your reply! The dcm files listed here were saved by reading a sequence of bmp files. So how can I to save them in order to read by ITK, the 3D geometry information, what their tags are in dicom file metadata? Thanks again!

What software created the .dcm files and the DICOMDIR file? If ITK cannot load the files then most likely they were created incorrectly. A typical error is that some people think that spacing between slices is a DICOM tag, while it is encoded in the ImagePositionPatient and ImageOrientationPatient tags. Some other people forget to generate correct UIDs. BMP files are most often 8-bit images, while most medical images are 10-12 bits per pixel, so you need make sure you take care of that, too. There are dozens of other tags that all need to be carefully and consistently set, so the best is to not try to handcraft DICOM images, but use tools that are known to be able to write out a 3D image to valid DICOM files. If you are looking for a library that can do that then you can use ITK or VTK. If you prefer to use an application (with a GUI) then you can use 3D Slicer.

1 Like