Esempio n. 1
0
    std::vector<itk::SmartPointer<BaseData> > RTDoseReader::Read()
    {
        std::vector<itk::SmartPointer<mitk::BaseData> > result;

        DICOMTag referencedRTPlan(0x300c, 0x0002);
        mitk::IDICOMTagsOfInterest* toiSrv = GetDicomTagsOfInterestService();
        if (toiSrv)
        {
            toiSrv->AddTagOfInterest(referencedRTPlan);
        }

        std::string location = GetInputLocation();
        mitk::DICOMFileReaderSelector::Pointer selector = mitk::DICOMFileReaderSelector::New();
        selector->LoadBuiltIn3DConfigs();
        selector->SetInputFiles({ location });

        mitk::DICOMFileReader::Pointer reader = selector->GetFirstReaderWithMinimumNumberOfOutputImages();
        reader->SetAdditionalTagsOfInterest(toiSrv->GetTagsOfInterest());

        reader->SetInputFiles({ location });
        reader->AnalyzeInputFiles();
        reader->LoadImages();

        if (reader->GetNumberOfOutputs() == 0){
            MITK_ERROR << "Could not determine a DICOM reader for this file" << std::endl;
            return result;
        }

        const mitk::DICOMImageBlockDescriptor& desc = reader->GetOutput(0);

        mitk::Image::Pointer originalImage = desc.GetMitkImage();

        if (originalImage.IsNull())
        {
            MITK_ERROR << "Error reading the RTDOSE file in mitk::DicomFileReader" << std::endl;
            return result;
        }

        DcmFileFormat fileformat;
        OFCondition outp = fileformat.loadFile(location.c_str(), EXS_Unknown);
        if (outp.bad())
        {
            MITK_ERROR << "Error reading the RTDOSE file in DCMTK" << std::endl;
            return result;
        }
        DcmDataset *dataset = fileformat.getDataset();

        DRTDoseIOD doseObject;
        OFCondition DCMTKresult = doseObject.read(*dataset);

        if (DCMTKresult.bad())
        {
            MITK_ERROR << "Error reading the RTDOSE file in DCMTK" << std::endl;
            return result;
        }

        OFString gridScaling;
        Float32 gridscale;

        doseObject.getDoseGridScaling(gridScaling);
        gridscale = OFStandard::atof(gridScaling.c_str());

        AccessByItk_1(originalImage, MultiplyGridScaling, gridscale);

        auto statistics = this->scaledDoseImage->GetStatistics();
        double maxDose = statistics->GetScalarValueMax();

        this->scaledDoseImage->SetPropertyList(originalImage->GetPropertyList());
        this->scaledDoseImage->SetProperty(mitk::RTConstants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str(), mitk::GenericProperty<double>::New(0.8*maxDose));

        result.push_back(this->scaledDoseImage.GetPointer());
        return result;
    }
Esempio n. 2
0
    mitk::DataNode::Pointer RTDoseReader::LoadRTDose(const char* filename)
    {
        DICOMTag referencedRTPlan(0x300c, 0x0002);
        mitk::IDICOMTagsOfInterest* toiSrv = GetDicomTagsOfInterestService();
        if (toiSrv)
        {
            toiSrv->AddTagOfInterest(referencedRTPlan);
        }

        mitk::StringList oneFile = { filename };
        mitk::DICOMFileReaderSelector::Pointer selector = mitk::DICOMFileReaderSelector::New();
        selector->LoadBuiltIn3DConfigs();
        selector->SetInputFiles(oneFile);

        mitk::DICOMFileReader::Pointer reader = selector->GetFirstReaderWithMinimumNumberOfOutputImages();
        reader->SetAdditionalTagsOfInterest(toiSrv->GetTagsOfInterest());

        reader->SetInputFiles(oneFile);
        reader->AnalyzeInputFiles();
        reader->LoadImages();

        if (reader->GetNumberOfOutputs() == 0){
            MITK_ERROR << "Error reading the dicom file" << std::endl;
            return nullptr;
        }

        const mitk::DICOMImageBlockDescriptor& desc = reader->GetOutput(0);

        mitk::Image::Pointer originalImage = desc.GetMitkImage();

        if (originalImage.IsNull())
        {
            MITK_ERROR << "Error reading the dcm file" << std::endl;
            return nullptr;
        }

        DcmFileFormat fileformat;
        OFCondition outp = fileformat.loadFile(filename, EXS_Unknown);
        if (outp.bad())
        {
            MITK_ERROR << "Can't read the RTDOSE file" << std::endl;
        }
        DcmDataset *dataset = fileformat.getDataset();

        DRTDoseIOD doseObject;
        OFCondition result = doseObject.read(*dataset);

        if(result.bad())
        {
            MITK_ERROR << "Error reading the Dataset" << std::endl;
            return nullptr;
        }

        OFString gridScaling;
        Float32 gridscale;

        doseObject.getDoseGridScaling(gridScaling);
        gridscale = OFStandard::atof(gridScaling.c_str());

        AccessByItk_1(originalImage, MultiplyGridScaling, gridscale);

        auto statistics = this->scaledDoseImage->GetStatistics();
        double maxDose = statistics->GetScalarValueMax();

        this->scaledDoseImage->SetPropertyList(originalImage->GetPropertyList());
        this->scaledDoseImage->SetProperty(mitk::RTConstants::PRESCRIBED_DOSE_PROPERTY_NAME.c_str(), mitk::GenericProperty<double>::New(0.8*maxDose));

        mitk::DataNode::Pointer originalNode = mitk::DataNode::New();

        originalNode->SetName("RT Dose");
        originalNode->SetData(this->scaledDoseImage);
        originalNode->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), 40.0);

        return originalNode;
  }