29 #include "dcmtk/dcmrt/drtdose.h" 31 #include <itkShiftScaleImageFilter.h> 32 #include <itkCastImageFilter.h> 48 template<
typename TPixel,
unsigned int VImageDimension>
49 void RTDoseReaderService::MultiplyGridScaling(itk::Image<TPixel, VImageDimension>*
image,
float gridscale)
51 typedef itk::Image<Float32, VImageDimension> OutputImageType;
54 typedef itk::CastImageFilter<InputImageType, OutputImageType> CastFilterType;
55 typedef itk::ShiftScaleImageFilter<OutputImageType, OutputImageType> ScaleFilterType;
56 typename CastFilterType::Pointer castFilter = CastFilterType::New();
57 typename ScaleFilterType::Pointer scaleFilter = ScaleFilterType::New();
59 castFilter->SetInput(image);
60 scaleFilter->SetInput(castFilter->GetOutput());
61 scaleFilter->SetScale(gridscale);
62 scaleFilter->Update();
63 typename OutputImageType::Pointer scaledOutput = scaleFilter->GetOutput();
71 std::vector<itk::SmartPointer<mitk::BaseData> > result;
79 for (
const auto& tag : tagsOfInterest) {
80 tagsOfInterestList.push_back(tag.first);
85 selector->LoadBuiltIn3DConfigs();
86 selector->SetInputFiles({ location });
88 mitk::DICOMFileReader::Pointer reader = selector->GetFirstReaderWithMinimumNumberOfOutputImages();
91 reader->SetInputFiles({ location });
92 reader->AnalyzeInputFiles();
95 if (reader->GetNumberOfOutputs() == 0) {
96 MITK_ERROR <<
"Could not determine a DICOM reader for this file" << std::endl;
101 scanner->SetInputFiles({ location });
102 scanner->AddTagPaths(tagsOfInterestList);
106 if (frames.empty()) {
107 MITK_ERROR <<
"Error reading the RTDOSE file" << std::endl;
115 if (originalImage.IsNull())
117 MITK_ERROR <<
"Error reading the RTDOSE file in mitk::DicomFileReader" << std::endl;
121 DcmFileFormat fileformat;
122 OFCondition outp = fileformat.loadFile(location.c_str(), EXS_Unknown);
125 MITK_ERROR <<
"Error reading the RTDOSE file in DCMTK" << std::endl;
128 DcmDataset *dataset = fileformat.getDataset();
130 DRTDoseIOD doseObject;
131 OFCondition DCMTKresult = doseObject.read(*dataset);
133 if (DCMTKresult.bad())
135 MITK_ERROR <<
"Error reading the RTDOSE file in DCMTK" << std::endl;
139 auto findingsGridScaling = frames.front()->GetTagValueAsString(
DICOMTagPath(0x3004, 0x000e));
142 if (findingsGridScaling.empty()) {
143 MITK_ERROR <<
"Could not find DoseGridScaling tag" << std::endl;
150 AccessByItk_1(originalImage, MultiplyGridScaling, gridScaling);
152 auto statistics = this->scaledDoseImage->GetStatistics();
153 double maxDose = statistics->GetScalarValueMax();
155 this->scaledDoseImage->SetPropertyList(originalImage->GetPropertyList());
160 result.push_back(this->scaledDoseImage.GetPointer());
MITKDICOMREADER_EXPORT FindingsListVectorType ExtractPathsOfInterest(const DICOMTagPathList &pathsOfInterest, const DICOMDatasetAccessingImageFrameList &frames)
Class is used to identify (nested) attributes in a DICOM dataset. In contrast to the class DICOMTag...
std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a dicom dataset from a RTDOSE file The method reads the PixelData from the DicomRT dose file an...
~RTDoseReaderService() override
::mitk::Image InputImageType
Image::Pointer GetMitkImage() const
the 3D mitk::Image that is loaded from the DICOM files of a DICOMImageFrameList
DataCollection - Class to facilitate loading/accessing structured data.
#define AccessByItk_1(mitkImage, itkImageTypeFunction, arg1)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
Target lexical_cast(const std::string &arg)
Output descriptor for DICOMFileReader.
mitk::Image::Pointer image
std::vector< DICOMTagPath > DICOMTagPathList
MITKDICOMREADER_EXPORT void SetProperties(BaseDataPointer image, const FindingsListVectorType &findings)
std::vector< DICOMDatasetAccessingImageFrameInfo::Pointer > DICOMDatasetAccessingImageFrameList
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
Base class for creating mitk::BaseData objects from files or streams.
RTDoseReaderService reads DICOM files of modality RTDOSE.
static const std::string PRESCRIBED_DOSE_PROPERTY_NAME
MITKDICOMREADER_EXPORT mitk::IDICOMTagsOfInterest * GetDicomTagsOfInterestService()
std::string GetInputLocation() const override
Get the current input location.