diff --git a/Modules/DicomRT/files.cmake b/Modules/DicomRT/files.cmake index dedcb7a47d..bbb35f627c 100644 --- a/Modules/DicomRT/files.cmake +++ b/Modules/DicomRT/files.cmake @@ -1,20 +1,21 @@ file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") SET(CPP_FILES mitkRTDoseReader.cpp + mitkRTPlanReader.cpp mitkRTConstants.cpp mitkIsoDoseLevel.cpp mitkIsoDoseLevelCollections.cpp mitkIsoDoseLevelSetProperty.cpp mitkIsoDoseLevelVectorProperty.cpp mitkRTStructureSetReader.cpp mitkDoseImageVtkMapper2D.cpp mitkIsoLevelsGenerator.cpp mitkDoseNodeHelper.cpp ) set(TPP_FILES ) set(MOC_H_FILES ) diff --git a/Modules/DicomRT/include/mitkRTPlanReader.h b/Modules/DicomRT/include/mitkRTPlanReader.h new file mode 100644 index 0000000000..c1c3bb1fcf --- /dev/null +++ b/Modules/DicomRT/include/mitkRTPlanReader.h @@ -0,0 +1,62 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#ifndef mitkDicomRTPlanReader_h +#define mitkDicomRTPlanReader_h + +#include "mitkAbstractFileReader.h" + +#include +#include +#include + +#include "mitkImage.h" +#include "mitkDICOMDatasetAccessingImageFrameInfo.h" + +#include "MitkDicomRTExports.h" + +namespace mitk +{ + struct DICOMDatasetFinding; + class DICOMTagPath; + + class MITKDICOMRT_EXPORT RTPlanReader : public mitk::AbstractFileReader + { + + public: + RTPlanReader(); + RTPlanReader(const RTPlanReader& other); + + using AbstractFileReader::Read; + virtual std::vector > Read() override; + + virtual ~RTPlanReader(); + + private: + RTPlanReader* Clone() const override; + + DICOMTagPath GenerateDicomTagPath(unsigned int tag1, unsigned int tag2, unsigned int sqTag1, unsigned int sqTag2) const; + std::vector > GeneratePathsOfInterest() const; + std::vector ExtractDicomPathList(const std::vector >& pathsOfInterestInformation) const; + std::vector > > ReadPathsOfInterest(const std::vector >& pathsOfInterestInformation, const DICOMDatasetAccessingImageFrameList& frames) const; + void SetProperties(Image::Pointer dummyImage, const std::vector > >& findings) const; + + us::ServiceRegistration m_ServiceReg; + }; +} + +#endif diff --git a/Modules/DicomRT/src/mitkRTPlanReader.cpp b/Modules/DicomRT/src/mitkRTPlanReader.cpp new file mode 100644 index 0000000000..222d1ca20f --- /dev/null +++ b/Modules/DicomRT/src/mitkRTPlanReader.cpp @@ -0,0 +1,166 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + + +#include "mitkRTPlanReader.h" + +#include "mitkDICOMDCMTKTagScanner.h" +#include "mitkImage.h" +#include "mitkIOMimeTypes.h" +#include "mitkDICOMTagPath.h" + +#include + +namespace mitk +{ + + RTPlanReader::RTPlanReader() : AbstractFileReader(IOMimeTypes::DICOM_MIMETYPE_NAME(), "DICOM RTPlan File Reader") { + m_ServiceReg = RegisterService(); + } + + RTPlanReader::RTPlanReader(const RTPlanReader& other) : mitk::AbstractFileReader(other) + { + + } + + RTPlanReader::~RTPlanReader(){} + + std::vector > RTPlanReader::Read() + { + std::vector > result; + + auto pathsOfInterestInformation = GeneratePathsOfInterest(); + auto pathsOfInterest = ExtractDicomPathList(pathsOfInterestInformation); + + std::string location = GetInputLocation(); + mitk::StringList files = { location }; + mitk::DICOMDCMTKTagScanner::Pointer scanner = mitk::DICOMDCMTKTagScanner::New(); + scanner->SetInputFiles(files); + scanner->AddTagPaths(pathsOfInterest); + scanner->Scan(); + + mitk::DICOMDatasetAccessingImageFrameList frames = scanner->GetFrameInfoList(); + if (frames.empty()){ + MITK_ERROR << "Error reading the RTPLAN file" << std::endl; + return result; + } + + auto findings = ReadPathsOfInterest(pathsOfInterestInformation, frames); + + //just create empty image. No image information available in RTPLAN. But properties will be attached. + Image::Pointer dummyImage = Image::New(); + SetProperties(dummyImage, findings); + + result.push_back(dummyImage.GetPointer()); + + return result; + } + + mitk::DICOMTagPath RTPlanReader::GenerateDicomTagPath(unsigned int tag1, unsigned int tag2, unsigned int sqTag1, unsigned int sqTag2) const + { + mitk::DICOMTagPath aTagPath; + aTagPath.AddAnySelection(tag1, tag2).AddElement(sqTag1, sqTag2); + return aTagPath; + } + + RTPlanReader* RTPlanReader::Clone() const + { + return new RTPlanReader(*this); + } + + std::vector > RTPlanReader::GeneratePathsOfInterest() const + { + std::vector > pathsOfInterestInformation; + + //dose reference UID + auto tagPath = GenerateDicomTagPath(0x300A, 0x0010, 0x300A, 0x0013); + pathsOfInterestInformation.push_back(std::make_tuple(mitk::DICOMTagPathToPropertyName(tagPath), "string", tagPath)); + + //dose reference description + tagPath = GenerateDicomTagPath(0x300A, 0x0010, 0x300A, 0x0016); + pathsOfInterestInformation.push_back(std::make_tuple(mitk::DICOMTagPathToPropertyName(tagPath), "string", tagPath)); + + //target prescription dose + tagPath = GenerateDicomTagPath(0x300A, 0x0010, 0x300A, 0x0026); + pathsOfInterestInformation.push_back(std::make_tuple(mitk::DICOMTagPathToPropertyName(tagPath), "double", tagPath)); + + //planned number of fractions + tagPath = GenerateDicomTagPath(0x300A, 0x0070, 0x300A, 0x0078); + pathsOfInterestInformation.push_back(std::make_tuple(mitk::DICOMTagPathToPropertyName(tagPath), "int", tagPath)); + + //number of beams + tagPath = GenerateDicomTagPath(0x300A, 0x0070, 0x300A, 0x0080); + pathsOfInterestInformation.push_back(std::make_tuple(mitk::DICOMTagPathToPropertyName(tagPath), "int", tagPath)); + + //radiation type + tagPath = GenerateDicomTagPath(0x300A, 0x00B0, 0x300A, 0x00C6); + pathsOfInterestInformation.push_back(std::make_tuple(mitk::DICOMTagPathToPropertyName(tagPath), "string", tagPath)); + + //structure set UID + tagPath = GenerateDicomTagPath(0x300C, 0x0060, 0x0008, 0x1155); + pathsOfInterestInformation.push_back(std::make_tuple(mitk::DICOMTagPathToPropertyName(tagPath), "string", tagPath)); + + return pathsOfInterestInformation; + } + + mitk::DICOMTagPathList RTPlanReader::ExtractDicomPathList(const std::vector >& pathsOfInterestInformation) const + { + mitk::DICOMTagPathList list; + for (auto element : pathsOfInterestInformation){ + list.push_back(std::get<2>(element)); + } + return list; + } + + std::vector > RTPlanReader::ReadPathsOfInterest(const std::vector > & pathsOfInterestInformation, const mitk::DICOMDatasetAccessingImageFrameList& frames) const + { + std::vector > findings; + for (auto& entry : pathsOfInterestInformation){ + std::string name, type; + mitk::DICOMTagPath dicomTag; + std::tie(name, type, dicomTag) = entry; + findings.push_back(std::make_tuple(name, type, frames.front()->GetTagValueAsString(dicomTag))); + } + return findings; + } + + void RTPlanReader::SetProperties(Image::Pointer dummyImage, const std::vector >& findings) const + { + for (const auto& finding : findings){ + unsigned int count = 0; + std::string name, type; + mitk::DICOMDatasetAccess::FindingsListType foundValues; + std::tie(name, type, foundValues) = finding; + for (auto& entry : foundValues){ + std::string nameWithNumber = name + "." + std::to_string(count); + if (type == "string"){ + auto genericProperty = mitk::GenericProperty::New(entry.value); + dummyImage->SetProperty(nameWithNumber.c_str(), genericProperty); + } + else if (type == "double"){ + auto genericProperty = mitk::GenericProperty::New(boost::lexical_cast(entry.value)); + dummyImage->SetProperty(nameWithNumber.c_str(), genericProperty); + } + else if (type == "int"){ + auto genericProperty = mitk::GenericProperty::New(boost::lexical_cast(entry.value)); + dummyImage->SetProperty(nameWithNumber.c_str(), genericProperty); + } + count++; + } + } + } + +} diff --git a/Modules/DicomRT/test/files.cmake b/Modules/DicomRT/test/files.cmake index f9c7fa5d99..e589e7598e 100644 --- a/Modules/DicomRT/test/files.cmake +++ b/Modules/DicomRT/test/files.cmake @@ -1,4 +1,5 @@ SET(MODULE_TESTS mitkRTStructureSetReaderTest.cpp mitkRTDoseReaderTest.cpp + mitkRTPlanReaderTest.cpp ) diff --git a/Modules/DicomRT/test/mitkRTPlanReaderTest.cpp b/Modules/DicomRT/test/mitkRTPlanReaderTest.cpp new file mode 100644 index 0000000000..59d447695d --- /dev/null +++ b/Modules/DicomRT/test/mitkRTPlanReaderTest.cpp @@ -0,0 +1,100 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkTestingMacros.h" +#include "mitkTestFixture.h" + +#include "mitkRTPlanReader.h" +#include "mitkImage.h" +#include "mitkGenericProperty.h" +#include "mitkBaseProperty.h" + +class mitkRTPlanReaderTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkRTPlanReaderTestSuite); + MITK_TEST(TestProperties); + CPPUNIT_TEST_SUITE_END(); + +private: + mitk::Image::ConstPointer m_image; + +public: + + void setUp() override + { + auto rtPlanReader = mitk::RTPlanReader(); + rtPlanReader.SetInput(GetTestDataFilePath("RT/Plan/rtplan.dcm")); + auto readerOutput = rtPlanReader.Read(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("reader output should have one entry.", static_cast(1), static_cast(readerOutput.size())); + + m_image = dynamic_cast(readerOutput.at(0).GetPointer()); + CPPUNIT_ASSERT_EQUAL(m_image.IsNotNull(), true); + } + + void TestProperties() + { + CheckStringProperty("DICOM.300A.0010.[*].300A.0013.0", "1.2.246.352.72.11.320687012.17740.20090508173031"); + CheckStringProperty("DICOM.300A.0010.[*].300A.0013.1", "1.2.246.352.72.11.320687012.17741.20090508173031"); + + CheckStringProperty("DICOM.300A.0010.[*].300A.0016.0", "Breast"); + CheckStringProperty("DICOM.300A.0010.[*].300A.0016.1", "CALC POINT"); + + CheckDoubleProperty("DICOM.300A.0010.[*].300A.0026.0", 14.0); + CheckDoubleProperty("DICOM.300A.0010.[*].300A.0026.1", 11.3113869239676); + + CheckIntProperty("DICOM.300A.0070.[*].300A.0078.0", 7); + + CheckIntProperty("DICOM.300A.0070.[*].300A.0080.0", 4); + + CheckStringProperty("DICOM.300A.00B0.[*].300A.00C6.0", "PHOTON"); + + CheckStringProperty("DICOM.300C.0060.[*].0008.1155.0", "1.2.246.352.71.4.320687012.3190.20090511122144"); + } + + void CheckStringProperty(std::string propertyName, std::string expectedPropertyValue) + { + auto actualProperty = m_image->GetProperty(propertyName.c_str()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Property not found: " + propertyName, actualProperty.IsNotNull(), true); + auto actualGenericStringProperty = dynamic_cast*>(actualProperty.GetPointer()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Property has not type string: " + propertyName, actualGenericStringProperty != nullptr, true); + std::string actualStringProperty = actualGenericStringProperty->GetValue(); + CPPUNIT_ASSERT_EQUAL_MESSAGE(propertyName + " is not as expected", actualStringProperty, expectedPropertyValue); + } + + void CheckDoubleProperty(std::string propertyName, double expectedPropertyValue) + { + auto actualProperty = m_image->GetProperty(propertyName.c_str()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Property not found: " + propertyName, actualProperty.IsNotNull(), true); + auto actualGenericDoubleProperty = dynamic_cast*>(actualProperty.GetPointer()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Property has not type string: " + propertyName, actualGenericDoubleProperty != nullptr, true); + double actualDoubleProperty = actualGenericDoubleProperty->GetValue(); + CPPUNIT_ASSERT_EQUAL_MESSAGE(propertyName + " is not as expected", actualDoubleProperty, expectedPropertyValue); + } + + void CheckIntProperty(std::string propertyName, int expectedPropertyValue) + { + auto actualProperty = m_image->GetProperty(propertyName.c_str()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Property not found: " + propertyName, actualProperty.IsNotNull(), true); + auto actualGenericIntProperty = dynamic_cast*>(actualProperty.GetPointer()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Property has not type string: " + propertyName, actualGenericIntProperty != nullptr, true); + int actualIntProperty = actualGenericIntProperty->GetValue(); + CPPUNIT_ASSERT_EQUAL_MESSAGE(propertyName + " is not as expected", actualIntProperty, expectedPropertyValue); + } + + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkRTPlanReader) diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/DicomEventHandler.cpp b/Plugins/org.mitk.gui.qt.dicom/src/internal/DicomEventHandler.cpp index a4f2577b2d..3b465dd276 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/DicomEventHandler.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/DicomEventHandler.cpp @@ -1,395 +1,418 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPluginActivator.h" #include "DicomEventHandler.h" #include #include #include #include #include #include #include #include #include #include "mitkImage.h" #include #include #include #include #include #include #include #include #include +#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include DicomEventHandler::DicomEventHandler() { } DicomEventHandler::~DicomEventHandler() { } void DicomEventHandler::OnSignalAddSeriesToDataManager(const ctkEvent& ctkEvent) { QStringList listOfFilesForSeries; listOfFilesForSeries = ctkEvent.getProperty("FilesForSeries").toStringList(); if (!listOfFilesForSeries.isEmpty()) { //for rt data, if the modality tag isn't defined or is "CT" the image is handled like before if(ctkEvent.containsProperty("Modality") && (ctkEvent.getProperty("Modality").toString().compare("RTDOSE",Qt::CaseInsensitive) == 0 || - ctkEvent.getProperty("Modality").toString().compare("RTSTRUCT",Qt::CaseInsensitive) == 0)) + ctkEvent.getProperty("Modality").toString().compare("RTSTRUCT",Qt::CaseInsensitive) == 0 || + ctkEvent.getProperty("Modality").toString().compare("RTPLAN", Qt::CaseInsensitive) == 0)) { QString modality = ctkEvent.getProperty("Modality").toString(); if(modality.compare("RTDOSE",Qt::CaseInsensitive) == 0) { auto doseReader = mitk::RTDoseReader(); - doseReader.SetInput(listOfFilesForSeries.at(0).toStdString()); + doseReader.SetInput(listOfFilesForSeries.front().toStdString()); std::vector > readerOutput = doseReader.Read(); if (!readerOutput.empty()){ mitk::Image::Pointer doseImage = dynamic_cast(readerOutput.at(0).GetPointer()); mitk::DataNode::Pointer doseImageNode = mitk::DataNode::New(); doseImageNode->SetData(doseImage); doseImageNode->SetName("RTDose"); mitk::DataNode::Pointer doseOutlineNode = mitk::DataNode::New(); doseOutlineNode->SetData(doseImage); if (doseImage != nullptr) { auto sopUIDProperty = doseImage->GetProperty("dicomseriesreader.SOPClassUID"); if (sopUIDProperty.IsNotNull()){ auto sopUIDStringProperty = dynamic_cast(sopUIDProperty.GetPointer()); if (sopUIDStringProperty != nullptr){ std::string sopUID = sopUIDStringProperty->GetValue(); doseImageNode->SetName(sopUID); } } berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_ISO_PRESETS_PREFERENCE_NODE_ID.c_str()); typedef QStringList NamesType; NamesType names = prefNode->ChildrenNames(); std::map presetMap; for (NamesType::const_iterator pos = names.begin(); pos != names.end(); ++pos) { berry::IPreferences::Pointer aPresetNode = prefNode->Node(*pos); if (aPresetNode.IsNull()) { mitkThrow() << "Error in preference interface. Cannot find preset node under given name. Name: " << (*pos).toStdString(); } mitk::IsoDoseLevelSet::Pointer levelSet = mitk::IsoDoseLevelSet::New(); NamesType levelNames = aPresetNode->ChildrenNames(); for (NamesType::const_iterator levelName = levelNames.begin(); levelName != levelNames.end(); ++levelName) { berry::IPreferences::Pointer levelNode = aPresetNode->Node(*levelName); if (aPresetNode.IsNull()) { mitkThrow() << "Error in preference interface. Cannot find level node under given preset name. Name: " << (*pos).toStdString() << "; Level id: " << (*levelName).toStdString(); } mitk::IsoDoseLevel::Pointer isoLevel = mitk::IsoDoseLevel::New(); isoLevel->SetDoseValue(levelNode->GetDouble(mitk::RTUIConstants::ISO_LEVEL_DOSE_VALUE_ID.c_str(), 0.0)); mitk::IsoDoseLevel::ColorType color; color.SetRed(levelNode->GetFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_RED_ID.c_str(), 1.0)); color.SetGreen(levelNode->GetFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_GREEN_ID.c_str(), 1.0)); color.SetBlue(levelNode->GetFloat(mitk::RTUIConstants::ISO_LEVEL_COLOR_BLUE_ID.c_str(), 1.0)); isoLevel->SetColor(color); isoLevel->SetVisibleIsoLine(levelNode->GetBool(mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_ISOLINES_ID.c_str(), true)); isoLevel->SetVisibleColorWash(levelNode->GetBool(mitk::RTUIConstants::ISO_LEVEL_VISIBILITY_COLORWASH_ID.c_str(), true)); levelSet->SetIsoDoseLevel(isoLevel); } presetMap.insert(std::make_pair((*pos).toStdString(), levelSet)); } if (presetMap.size() == 0) { presetMap.insert(std::make_pair(std::string("Virtuos"), mitk::GeneratIsoLevels_Virtuos())); } prefNode = prefService->GetSystemPreferences()->Node(mitk::RTUIConstants::ROOT_DOSE_VIS_PREFERENCE_NODE_ID.c_str()); if (prefNode.IsNull()) { mitkThrow() << "Error in preference interface. Cannot find preset node under given name. Name: " << prefNode->ToString().toStdString(); } //set some specific colorwash and isoline properties bool showColorWashGlobal = prefNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_COLORWASH_ID.c_str(), true); doseImageNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_COLORWASH_PROPERTY_NAME.c_str(), showColorWashGlobal); bool showIsolinesGlobal = prefNode->GetBool(mitk::RTUIConstants::GLOBAL_VISIBILITY_ISOLINES_ID.c_str(), true); doseOutlineNode->SetBoolProperty(mitk::RTConstants::DOSE_SHOW_ISOLINES_PROPERTY_NAME.c_str(), showIsolinesGlobal); //Set reference dose property double referenceDose = prefNode->GetDouble(mitk::RTUIConstants::REFERENCE_DOSE_ID.c_str(), mitk::RTUIConstants::DEFAULT_REFERENCE_DOSE_VALUE); doseImageNode->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), referenceDose); doseOutlineNode->SetFloatProperty(mitk::RTConstants::REFERENCE_DOSE_PROPERTY_NAME.c_str(), referenceDose); QString presetName = prefNode->Get(mitk::RTUIConstants::SELECTED_ISO_PRESET_ID.c_str(), "Virtuos"); mitk::IsoDoseLevelSet::Pointer isoDoseLevelPreset = presetMap[presetName.toStdString()]; mitk::IsoDoseLevelSetProperty::Pointer levelSetProp = mitk::IsoDoseLevelSetProperty::New(isoDoseLevelPreset); doseImageNode->SetProperty(mitk::RTConstants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str(), levelSetProp); doseOutlineNode->SetProperty(mitk::RTConstants::DOSE_ISO_LEVELS_PROPERTY_NAME.c_str(), levelSetProp); mitk::IsoDoseLevelVector::Pointer levelVector = mitk::IsoDoseLevelVector::New(); mitk::IsoDoseLevelVectorProperty::Pointer levelVecProp = mitk::IsoDoseLevelVectorProperty::New(levelVector); doseImageNode->SetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(), levelVecProp); doseOutlineNode->SetProperty(mitk::RTConstants::DOSE_FREE_ISO_VALUES_PROPERTY_NAME.c_str(), levelVecProp); mitk::RenderingModeProperty::Pointer renderingModeProp = mitk::RenderingModeProperty::New(); if (showColorWashGlobal) { //Generating the Colorwash vtkSmartPointer transferFunction = vtkSmartPointer::New(); for (mitk::IsoDoseLevelSet::ConstIterator itIsoDoseLevel = isoDoseLevelPreset->Begin(); itIsoDoseLevel != isoDoseLevelPreset->End(); ++itIsoDoseLevel) { float *hsv = new float[3]; //used for transfer rgb to hsv vtkSmartPointer cCalc = vtkSmartPointer::New(); if (itIsoDoseLevel->GetVisibleColorWash()){ cCalc->RGBToHSV(itIsoDoseLevel->GetColor()[0], itIsoDoseLevel->GetColor()[1], itIsoDoseLevel->GetColor()[2], &hsv[0], &hsv[1], &hsv[2]); transferFunction->AddHSVPoint(itIsoDoseLevel->GetDoseValue()*referenceDose, hsv[0], hsv[1], hsv[2], 1.0, 1.0); } } mitk::TransferFunction::Pointer mitkTransFunc = mitk::TransferFunction::New(); mitk::TransferFunctionProperty::Pointer mitkTransFuncProp = mitk::TransferFunctionProperty::New(); mitkTransFunc->SetColorTransferFunction(transferFunction); mitkTransFuncProp->SetValue(mitkTransFunc); doseImageNode->SetProperty("Image Rendering.Transfer Function", mitkTransFuncProp); renderingModeProp->SetValue(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_COLOR); } else { //Set rendering mode to levelwindow color mode renderingModeProp->SetValue(mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR); } doseImageNode->SetProperty("Image Rendering.Mode", renderingModeProp); doseImageNode->SetProperty("opacity", mitk::FloatProperty::New(0.5)); //set the outline properties doseOutlineNode->SetBoolProperty("outline binary", true); doseOutlineNode->SetProperty("helper object", mitk::BoolProperty::New(true)); doseOutlineNode->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false)); ctkServiceReference serviceReference = mitk::PluginActivator::getContext()->getServiceReference(); mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService(serviceReference); mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); dataStorage->Add(doseImageNode); dataStorage->Add(doseOutlineNode, doseImageNode); //set the dose mapper for outline drawing; the colorwash is realized by the imagevtkmapper2D mitk::DoseImageVtkMapper2D::Pointer contourMapper = mitk::DoseImageVtkMapper2D::New(); doseOutlineNode->SetMapper(1, contourMapper); mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage); } }//END DOSE } else if(modality.compare("RTSTRUCT",Qt::CaseInsensitive) == 0) { mitk::RTStructureSetReader::Pointer structreader = mitk::RTStructureSetReader::New(); std::deque modelVector = structreader->ReadStructureSet(listOfFilesForSeries.at(0).toStdString().c_str()); if(modelVector.empty()) { MITK_ERROR << "No structuresets were created" << endl; } else { ctkServiceReference serviceReference =mitk::PluginActivator::getContext()->getServiceReference(); mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService(serviceReference); mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); for(int i=0; iAdd(modelVector.at(i)); } mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(dataStorage); } } + else if (modality.compare("RTPLAN", Qt::CaseInsensitive) == 0) + { + std::cout << "RTPLAN" << std::endl; + auto planReader = mitk::RTPlanReader(); + planReader.SetInput(listOfFilesForSeries.front().toStdString()); + std::vector > readerOutput = planReader.Read(); + if (!readerOutput.empty()){ + //there is no image, only the properties are interesting + mitk::Image::Pointer planDummyImage = dynamic_cast(readerOutput.at(0).GetPointer()); + + mitk::DataNode::Pointer planImageNode = mitk::DataNode::New(); + planImageNode->SetData(planDummyImage); + planImageNode->SetName("RTPlan"); + + ctkServiceReference serviceReference = mitk::PluginActivator::getContext()->getServiceReference(); + mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService(serviceReference); + mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); + + dataStorage->Add(planImageNode); + } + } } else { mitk::StringList seriesToLoad; QStringListIterator it(listOfFilesForSeries); while (it.hasNext()) { seriesToLoad.push_back(it.next().toStdString()); } //Get Reference for default data storage. ctkServiceReference serviceReference = mitk::PluginActivator::getContext()->getServiceReference(); mitk::IDataStorageService* storageService = mitk::PluginActivator::getContext()->getService(serviceReference); mitk::DataStorage* dataStorage = storageService->GetDefaultDataStorage().GetPointer()->GetDataStorage(); //special handling of Philips 3D US DICOM. //Copied from DICOMSeriesReaderService if (!seriesToLoad.empty() && mitk::DicomSeriesReader::IsPhilips3DDicom(seriesToLoad.front())) { MITK_INFO << "it is a Philips3D US Dicom file" << std::endl; mitk::LocaleSwitch localeSwitch("C"); std::locale previousCppLocale(std::cin.getloc()); std::locale l("C"); std::cin.imbue(l); mitk::DataNode::Pointer node = mitk::DataNode::New(); mitk::DicomSeriesReader::StringContainer stringvec; stringvec.push_back(seriesToLoad.front()); if (mitk::DicomSeriesReader::LoadDicomSeries(stringvec, *node)) { mitk::BaseData::Pointer data = node->GetData(); mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New(itksys::SystemTools::GetFilenameName(seriesToLoad.front())); data->GetPropertyList()->SetProperty("name", nameProp); node->SetProperty("name", nameProp); dataStorage->Add(node); } std::cin.imbue(previousCppLocale); return; } //Normal DICOM handling (It wasn't a Philips 3D US) mitk::DICOMFileReaderSelector::Pointer selector = mitk::DICOMFileReaderSelector::New(); selector->LoadBuiltIn3DConfigs(); selector->LoadBuiltIn3DnTConfigs(); selector->SetInputFiles(seriesToLoad); mitk::DICOMFileReader::Pointer reader = selector->GetFirstReaderWithMinimumNumberOfOutputImages(); reader->SetAdditionalTagsOfInterest(mitk::GetCurrentDICOMTagsOfInterest()); reader->SetTagLookupTableToPropertyFunctor(mitk::GetDICOMPropertyForDICOMValuesFunctor); reader->SetInputFiles(seriesToLoad); mitk::DICOMDCMTKTagScanner::Pointer scanner = mitk::DICOMDCMTKTagScanner::New(); scanner->AddTagPaths(reader->GetTagsOfInterest()); scanner->SetInputFiles(seriesToLoad); scanner->Scan(); reader->SetTagCache(scanner->GetScanCache()); reader->AnalyzeInputFiles(); reader->LoadImages(); for (unsigned int i = 0; i < reader->GetNumberOfOutputs(); ++i) { const mitk::DICOMImageBlockDescriptor& desc = reader->GetOutput(i); mitk::BaseData::Pointer data = desc.GetMitkImage().GetPointer(); std::string nodeName = "Unnamed_DICOM"; std::string studyDescription = desc.GetPropertyAsString("studyDescription"); std::string seriesDescription = desc.GetPropertyAsString("seriesDescription"); if (!studyDescription.empty()) { nodeName = studyDescription; } if (!seriesDescription.empty()) { if (!studyDescription.empty()) { nodeName += "/"; } nodeName += seriesDescription; } mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New(nodeName); data->SetProperty("name", nameProp); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(data); nameProp = mitk::StringProperty::New(nodeName); node->SetProperty("name", nameProp); dataStorage->Add(node); } if (reader->GetNumberOfOutputs() < 1) { MITK_ERROR << "Error loading series: " << ctkEvent.getProperty("SeriesName").toString().toStdString() << " id: " << ctkEvent.getProperty("SeriesUID").toString().toStdString(); } } } else { MITK_INFO << "There are no files for the current series"; } } void DicomEventHandler::OnSignalRemoveSeriesFromStorage(const ctkEvent& /*ctkEvent*/) { } void DicomEventHandler::SubscribeSlots() { ctkServiceReference ref = mitk::PluginActivator::getContext()->getServiceReference(); if (ref) { ctkEventAdmin* eventAdmin = mitk::PluginActivator::getContext()->getService(ref); ctkDictionary properties; properties[ctkEventConstants::EVENT_TOPIC] = "org/mitk/gui/qt/dicom/ADD"; eventAdmin->subscribeSlot(this, SLOT(OnSignalAddSeriesToDataManager(ctkEvent)), properties); properties[ctkEventConstants::EVENT_TOPIC] = "org/mitk/gui/qt/dicom/DELETED"; eventAdmin->subscribeSlot(this, SLOT(OnSignalRemoveSeriesFromStorage(ctkEvent)), properties); } }