diff --git a/Modules/DICOMReader/src/mitkDICOMIOHelper.cpp b/Modules/DICOMReader/src/mitkDICOMIOHelper.cpp index 59f29af021..477d032bb3 100644 --- a/Modules/DICOMReader/src/mitkDICOMIOHelper.cpp +++ b/Modules/DICOMReader/src/mitkDICOMIOHelper.cpp @@ -1,69 +1,75 @@ /*=================================================================== 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 "mitkDICOMIOHelper.h" #include #include #include #include namespace mitk { mitk::IDICOMTagsOfInterest *GetDicomTagsOfInterestService() { mitk::IDICOMTagsOfInterest *result = nullptr; + us::ModuleContext *context = us::GetModuleContext(); + if (context == nullptr) + { + MITK_WARN << "No dicom context found."; + return result; + } std::vector> toiRegisters = - us::GetModuleContext()->GetServiceReferences(); + context->GetServiceReferences(); if (!toiRegisters.empty()) { if (toiRegisters.size() > 1) { MITK_WARN << "Multiple DICOM tags of interest services found. Using just one."; } result = us::GetModuleContext()->GetService(toiRegisters.front()); } return result; } FindingsListVectorType ExtractPathsOfInterest(const DICOMTagPathList &pathsOfInterest, const DICOMDatasetAccessingImageFrameList &frames) { std::vector findings; for (const auto &entry : pathsOfInterest) { findings.push_back(frames.front()->GetTagValueAsString(entry)); } return findings; } void SetProperties(BaseDataPointer image, const FindingsListVectorType &findings) { for (const auto &finding : findings) { for (const auto &entry : finding) { const std::string propertyName = mitk::DICOMTagPathToPropertyName(entry.path); auto property = mitk::TemporoSpatialStringProperty::New(); property->SetValue(entry.value); image->SetProperty(propertyName.c_str(), property); } } } }