32 #include "dcmtk/dcmrt/drtdose.h"
34 #include <itkShiftScaleImageFilter.h>
35 #include <itkCastImageFilter.h>
51 template<
typename TPixel,
unsigned int VImageDimension>
52 void RTDoseReader::MultiplyGridScaling(itk::Image<TPixel, VImageDimension>* image,
float gridscale)
54 typedef itk::Image<Float32, VImageDimension> OutputImageType;
57 typedef itk::CastImageFilter<InputImageType, OutputImageType> CastFilterType;
58 typedef itk::ShiftScaleImageFilter<OutputImageType, OutputImageType> ScaleFilterType;
62 castFilter->SetInput(image);
63 scaleFilter->SetInput(castFilter->GetOutput());
64 scaleFilter->SetScale(gridscale);
65 scaleFilter->Update();
77 if (!toiRegisters.empty())
79 if (toiRegisters.size() > 1)
81 MITK_WARN <<
"Multiple DICOM tags of interest services found. Using just one.";
91 std::vector<itk::SmartPointer<mitk::BaseData> > result;
93 DICOMTag referencedRTPlan(0x300c, 0x0002);
102 selector->LoadBuiltIn3DConfigs();
103 selector->SetInputFiles({ location });
108 reader->SetInputFiles({ location });
109 reader->AnalyzeInputFiles();
110 reader->LoadImages();
112 if (reader->GetNumberOfOutputs() == 0){
113 MITK_ERROR <<
"Could not determine a DICOM reader for this file" << std::endl;
121 if (originalImage.IsNull())
123 MITK_ERROR <<
"Error reading the RTDOSE file in mitk::DicomFileReader" << std::endl;
127 DcmFileFormat fileformat;
128 OFCondition outp = fileformat.loadFile(location.c_str(), EXS_Unknown);
131 MITK_ERROR <<
"Error reading the RTDOSE file in DCMTK" << std::endl;
134 DcmDataset *dataset = fileformat.getDataset();
136 DRTDoseIOD doseObject;
137 OFCondition DCMTKresult = doseObject.read(*dataset);
139 if (DCMTKresult.bad())
141 MITK_ERROR <<
"Error reading the RTDOSE file in DCMTK" << std::endl;
145 OFString gridScaling;
148 doseObject.getDoseGridScaling(gridScaling);
149 gridscale = OFStandard::atof(gridScaling.c_str());
151 AccessByItk_1(originalImage, MultiplyGridScaling, gridscale);
153 auto statistics = this->scaledDoseImage->GetStatistics();
154 double maxDose = statistics->GetScalarValueMax();
156 this->scaledDoseImage->SetPropertyList(originalImage->GetPropertyList());
159 result.push_back(this->scaledDoseImage.GetPointer());
itk::SmartPointer< Self > Pointer
RTDoseReader reads DICOM files of modality RTDOSE.
Representation of a DICOM tag.
DataCollection - Class to facilitate loading/accessing structured data.
#define AccessByItk_1(mitkImage, itkImageTypeFunction, arg1)
void * GetService(const ServiceReferenceBase &reference)
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
itk::Image< double, 3 > InputImageType
Output descriptor for DICOMFileReader.
virtual std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
std::vector< ServiceReferenceU > GetServiceReferences(const std::string &clazz, const std::string &filter=std::string())
Image::Pointer GetMitkImage() const
the 3D mitk::Image that is loaded from the DICOM files of a DICOMImageFrameList
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.
virtual ~RTDoseReader()
Reads a dicom dataset from a RTDOSE file.
static const std::string PRESCRIBED_DOSE_PROPERTY_NAME
virtual std::string GetInputLocation() const override
Get the current input location.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.