diff --git a/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIO.cpp b/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIO.cpp index 50260efb74..5429af4e2d 100644 --- a/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIO.cpp +++ b/Modules/Pharmacokinetics/autoload/DICOMPMIO/mitkDICOMPMIO.cpp @@ -1,249 +1,249 @@ /*=================================================================== 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 __mitkDICOMPharmacokineticsIO__cpp #define __mitkDICOMPharmacokineticsIO__cpp #include "mitkDICOMPMIO.h" #include "mitkDICOMQIIOMimeTypes.h" #include "mitkDICOMPMConstants.h" #include #include #include #include #include #include #include #include #include -#include "mitkParamapPresets.h" +#include "mitkParamapPresetsParser.h" // us #include #include // model fit parameters #include "mitkModelFitConstants.h" namespace mitk { DICOMPMIO::DICOMPMIO() : AbstractFileIO(Image::GetStaticNameOfClass(), mitk::MitkDICOMQIIOMimeTypes::DICOMPM_MIMETYPE_NAME(), "DICOM PM") { AbstractFileWriter::SetRanking(10); AbstractFileReader::SetRanking(10); this->RegisterService(); this->AddDICOMTagsToService(); } void DICOMPMIO::AddDICOMTagsToService() { IDICOMTagsOfInterest *toiService = GetDicomTagsOfInterestService(); if (toiService != nullptr) { toiService->AddTagOfInterest(DICOMPMConstants::RWVM_SEQUENCE_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::UNITS_SEQUENCE_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::UNITS_CODE_VALUE_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::UNITS_CODE_SCHEME_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::UNITS_CODE_MEANING_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::QUANTITY_DEFINITION_SEQUENCE_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::QUANTITY_DEFINITION_VALUE_TYPE_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::QUANTITY_DEFINITION_CONCEPT_CODE_SEQUENCE_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::QUANTITY_DEFINITION_CONCEPT_CODE_VALUE_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::QUANTITY_DEFINITION_CONCEPT_CODE_SCHEME_PATH()); toiService->AddTagOfInterest(DICOMPMConstants::QUANTITY_DEFINITION_CONCEPT_CODE_MEANING_PATH()); } } IFileIO::ConfidenceLevel DICOMPMIO::GetWriterConfidenceLevel() const { if (AbstractFileIO::GetWriterConfidenceLevel() == Unsupported) return Unsupported; const Image *PMinput = static_cast(this->GetInput()); if (PMinput) return Supported; else return Unsupported; } void DICOMPMIO::Write() { ValidateOutputLocation(); mitk::LocaleSwitch localeSwitch("C"); LocalFile localFile(this); const std::string path = localFile.GetFileName(); auto PMinput = dynamic_cast(this->GetInput()); if (PMinput == nullptr) mitkThrow() << "Cannot write non-image data"; // Get DICOM information from referenced image vector dcmDatasets; DcmFileFormat *readFileFormat = new DcmFileFormat(); try { // Generate dcmdataset witk DICOM tags from property list; ATM the source are the filepaths from the // property list mitk::StringLookupTableProperty::Pointer filesProp = dynamic_cast(PMinput->GetProperty("referenceFiles").GetPointer()); if (filesProp.IsNull()) { mitkThrow() << "No property with dicom file path."; return; } // returns a list of all referenced files StringLookupTable filesLut = filesProp->GetValue(); const StringLookupTable::LookupTableType &lookUpTableMap = filesLut.GetLookupTable(); for (auto it : lookUpTableMap) { const char *fileName = (it.second).c_str(); if (readFileFormat->loadFile(fileName, EXS_Unknown).good()) dcmDatasets.push_back(readFileFormat->getAndRemoveDataset()); } } catch (const std::exception &e) { MITK_ERROR << "An error occurred while getting the dicom information: " << e.what() << endl; return; } mitk::Image *mitkPMImage = const_cast(PMinput); // Cast input PMinput to itk image ImageToItk::Pointer PMimageToItkFilter = ImageToItk::New(); PMimageToItkFilter->SetInput(mitkPMImage); PMimageToItkFilter->Update(); // Cast from original itk type to dcmqi input itk image type typedef itk::CastImageFilter castItkImageFilterType; castItkImageFilterType::Pointer castFilter = castItkImageFilterType::New(); castFilter->SetInput(PMimageToItkFilter->GetOutput()); castFilter->Update(); PMitkInternalImageType::Pointer itkParamapImage = castFilter->GetOutput(); itkParamapImage->DisconnectPipeline(); // Create PM meta information const std::string &tmpMetaInfoFile = this->CreateMetaDataJsonFilePM(); // Convert itk PM images to dicom image MITK_INFO << "Writing PM image: " << path << std::endl; try { dcmqi::ParaMapConverter *PMconverter = new dcmqi::ParaMapConverter(); DcmDataset *PMresult = PMconverter->itkimage2paramap(itkParamapImage, dcmDatasets, tmpMetaInfoFile); // Write dicom file DcmFileFormat dcmFileFormat(PMresult); std::string filePath = path.substr(0, path.find_last_of(".")); filePath = filePath + ".dcm"; dcmFileFormat.saveFile(filePath.c_str(), EXS_LittleEndianExplicit); // Clean up if (PMconverter != nullptr) delete PMconverter; if (PMresult != nullptr) delete PMresult; } catch (const std::exception &e) { MITK_ERROR << "An error occurred during writing the DICOM Paramap: " << e.what() << endl; return; } //-------------------------------------------------------------// // End of image writing; clean up if (readFileFormat) delete readFileFormat; for (auto obj : dcmDatasets) delete obj; dcmDatasets.clear(); } const std::string mitk::DICOMPMIO::CreateMetaDataJsonFilePM() const { const mitk::Image *PMimage = dynamic_cast(this->GetInput()); dcmqi::JSONParametricMapMetaInformationHandler PMhandler; // Get Metadata from modelFitConstants std::string parameterName; PMimage->GetPropertyList()->GetStringProperty(ModelFitConstants::PARAMETER_NAME_PROPERTY_NAME().c_str(), parameterName); std::string modelName; PMimage->GetPropertyList()->GetStringProperty(ModelFitConstants::MODEL_NAME_PROPERTY_NAME().c_str(), modelName); - - mitk::ParamapPresets* pmPresets = mitk::ParamapPresets::New(); - // Here the mitkParamapPresets.xml file containing the Coding Schmeme Designator and Code Value are parsed and the relevant values extracted - pmPresets->LoadPreset(); + + mitk::ParamapPresetsParser* pmPresets = mitk::ParamapPresetsParser::New(); + // Here the mitkParamapPresets.xml file containing the Coding Schmeme Designator and Code Value are parsed and the relevant values extracted + pmPresets->LoadPreset(); auto pmType_parameterName = pmPresets->GetType(parameterName); auto pmType_modelName = pmPresets->GetType(modelName); // Here some other // mandatory // TODO: where to get these from? // TODO: AnatomicRegionSequence from Segmentation? PMhandler.setAnatomicRegionSequence("T-9200B", "SRT", "Prostate"); PMhandler.setDerivedPixelContrast("TCS"); PMhandler.setFrameLaterality("U"); // optional PMhandler.setQuantityValueCode(pmType_parameterName.codeValue, pmType_parameterName.codeScheme, parameterName); PMhandler.setMeasurementMethodCode(pmType_modelName.codeValue, pmType_modelName.codeScheme, modelName); PMhandler.setSeriesNumber("1"); PMhandler.setInstanceNumber("1"); PMhandler.setDerivationCode("110816", "DCM", "Time Course of Signal"); PMhandler.setMeasurementUnitsCode("/min", "UCUM", "/m"); PMhandler.setRealWorldValueSlope(1); return PMhandler.getJSONOutputAsString(); } // IKO: not yet implemented, TO DO: write DICOMPMReader std::vector DICOMPMIO::Read() { mitk::LocaleSwitch localeSwitch("C"); std::vector result; return result; } // IKO: not yet implemented TO DO: write DICOMPMReaderConfidenceLevel IFileIO::ConfidenceLevel DICOMPMIO::GetReaderConfidenceLevel() const { return Unsupported; } DICOMPMIO *DICOMPMIO::IOClone() const { return new DICOMPMIO(*this); } } // namespace #endif //__mitkDICOMPharmacokineticsIO__cpp diff --git a/Modules/Pharmacokinetics/files.cmake b/Modules/Pharmacokinetics/files.cmake index 0289a227c1..bf1c5722b6 100644 --- a/Modules/Pharmacokinetics/files.cmake +++ b/Modules/Pharmacokinetics/files.cmake @@ -1,70 +1,70 @@ file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") set(CPP_FILES Common/mitkAterialInputFunctionGenerator.cpp Common/mitkAIFParametrizerHelper.cpp Common/mitkConcentrationCurveGenerator.cpp Common/mitkDescriptionParameterImageGeneratorBase.cpp Common/mitkPixelBasedDescriptionParameterImageGenerator.cpp Common/mitkDICOMPMConstants.cpp Common/mitkDICOMPMPropertyHelper.cpp - Common/mitkParamapPresets.cpp + Common/mitkParamapPresetsParser.cpp DescriptionParameters/mitkCurveDescriptionParameterBase.cpp DescriptionParameters/mitkAreaUnderTheCurveDescriptionParameter.cpp DescriptionParameters/mitkAreaUnderFirstMomentDescriptionParameter.cpp DescriptionParameters/mitkMeanResidenceTimeDescriptionParameter.cpp DescriptionParameters/mitkTimeToPeakCurveDescriptionParameter.cpp DescriptionParameters/mitkMaximumCurveDescriptionParameter.cpp Functors/mitkCurveParameterFunctor.cpp Models/mitkAIFBasedModelBase.cpp Models/mitkDescriptivePharmacokineticBrixModel.cpp Models/mitkDescriptivePharmacokineticBrixModelFactory.cpp Models/mitkDescriptivePharmacokineticBrixModelValueBasedParameterizer.cpp Models/mitkDescriptivePharmacokineticBrixModelParameterizer.cpp Models/mitkThreeStepLinearModel.cpp Models/mitkThreeStepLinearModelFactory.cpp Models/mitkThreeStepLinearModelParameterizer.cpp Models/mitkTwoCompartmentExchangeModel.cpp Models/mitkTwoCompartmentExchangeModelFactory.cpp Models/mitkTwoCompartmentExchangeModelParameterizer.cpp Models/mitkNumericTwoCompartmentExchangeModel.cpp Models/mitkNumericTwoCompartmentExchangeModelFactory.cpp Models/mitkNumericTwoCompartmentExchangeModelParameterizer.cpp Models/mitkExtendedToftsModel.cpp Models/mitkExtendedToftsModelFactory.cpp Models/mitkExtendedToftsModelParameterizer.cpp Models/mitkStandardToftsModel.cpp Models/mitkStandardToftsModelFactory.cpp Models/mitkStandardToftsModelParameterizer.cpp Models/mitkOneTissueCompartmentModel.cpp Models/mitkOneTissueCompartmentModelFactory.cpp Models/mitkOneTissueCompartmentModelParameterizer.cpp Models/mitkExtendedOneTissueCompartmentModel.cpp Models/mitkExtendedOneTissueCompartmentModelFactory.cpp Models/mitkExtendedOneTissueCompartmentModelParameterizer.cpp Models/mitkTwoTissueCompartmentModel.cpp Models/mitkTwoTissueCompartmentModelFactory.cpp Models/mitkTwoTissueCompartmentModelParameterizer.cpp Models/mitkTwoTissueCompartmentFDGModel.cpp Models/mitkTwoTissueCompartmentFDGModelFactory.cpp Models/mitkTwoTissueCompartmentFDGModelParameterizer.cpp Models/mitkNumericTwoTissueCompartmentModel.cpp Models/mitkNumericTwoTissueCompartmentModelFactory.cpp Models/mitkNumericTwoTissueCompartmentModelParameterizer.cpp SimulationFramework/mitkPerfusionDataGenerator.cpp SimulationFramework/mitkImageGenerationHelper.cpp ) set(HXX_FILES mitkDICOMSegmentationConstants.h ) set(MOC_H_FILES ) set(RESOURCE_FILES mitkParamapPresets.xml ) diff --git a/Modules/Pharmacokinetics/include/mitkParamapPresets.h b/Modules/Pharmacokinetics/include/mitkParamapPresetsParser.h similarity index 87% rename from Modules/Pharmacokinetics/include/mitkParamapPresets.h rename to Modules/Pharmacokinetics/include/mitkParamapPresetsParser.h index cb7b114a6f..cb2583e50c 100644 --- a/Modules/Pharmacokinetics/include/mitkParamapPresets.h +++ b/Modules/Pharmacokinetics/include/mitkParamapPresetsParser.h @@ -1,73 +1,73 @@ /*=================================================================== 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 PARAMAPRPRESETS_H_HEADER #define PARAMAPPRESETS_H_HEADER #include #include #include #include #include namespace mitk { -class MITKPHARMACOKINETICS_EXPORT ParamapPresets : public vtkXMLParser +class MITKPHARMACOKINETICS_EXPORT ParamapPresetsParser : public vtkXMLParser { public: struct Type { std::string codeValue; std::string codeScheme; Type() = default; Type(std::string value, std::string scheme) : codeValue(value), codeScheme(scheme){} }; - static ParamapPresets *New(); - vtkTypeMacro(ParamapPresets,vtkXMLParser); + static ParamapPresetsParser *New(); + vtkTypeMacro(ParamapPresetsParser,vtkXMLParser); bool LoadPreset(); bool LoadPreset(const std::string& fileName); Type GetType(const std::string& name); std::map const GetTypePresets(); void NewPresets(std::map& newType); protected: - ParamapPresets() = default; - ~ParamapPresets() override = default; + ParamapPresetsParser() = default; + ~ParamapPresetsParser() override = default; private: //##Documentation //## @brief method used in XLM-Reading; gets called when a start-tag is read void StartElement (const char *elementName, const char **atts) override; //##Documentation //## @brief reads an XML-String-Attribute std::string ReadXMLStringAttribute(const std::string& name, const char **atts); static const std::string PRESET; static const std::string TYPE; static const std::string CODE_VALUE; static const std::string CODE_SCHEME; std::string m_presetName; std::map m_Type; std::string m_XmlFileName; }; } #endif diff --git a/Modules/Pharmacokinetics/src/Common/mitkParamapPresets.cpp b/Modules/Pharmacokinetics/src/Common/mitkParamapPresetsParser.cpp similarity index 65% rename from Modules/Pharmacokinetics/src/Common/mitkParamapPresets.cpp rename to Modules/Pharmacokinetics/src/Common/mitkParamapPresetsParser.cpp index c7234a6893..753d943fb8 100644 --- a/Modules/Pharmacokinetics/src/Common/mitkParamapPresets.cpp +++ b/Modules/Pharmacokinetics/src/Common/mitkParamapPresetsParser.cpp @@ -1,129 +1,129 @@ /*=================================================================== 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 "mitkParamapPresets.h" +#include "mitkParamapPresetsParser.h" #include #include "usGetModuleContext.h" #include "usModuleContext.h" #include "usModule.h" #include "usModuleResource.h" #include "usModuleResourceStream.h" namespace mitk { - const std::string ParamapPresets::PRESET = "preset"; - const std::string ParamapPresets::TYPE = "type"; - const std::string ParamapPresets::CODE_VALUE = "code_value"; - const std::string ParamapPresets::CODE_SCHEME = "coding_scheme"; + const std::string ParamapPresetsParser::PRESET = "preset"; + const std::string ParamapPresetsParser::TYPE = "type"; + const std::string ParamapPresetsParser::CODE_VALUE = "code_value"; + const std::string ParamapPresetsParser::CODE_SCHEME = "coding_scheme"; - vtkStandardNewMacro(ParamapPresets); + vtkStandardNewMacro(ParamapPresetsParser); - bool ParamapPresets::LoadPreset() + bool ParamapPresetsParser::LoadPreset() { us::ModuleResource presetResource = us::GetModuleContext()->GetModule()->GetResource("mitkParamapPresets.xml"); if (!presetResource) return false; us::ModuleResourceStream presetStream(presetResource); vtkXMLParser::SetStream(&presetStream); if (!vtkXMLParser::Parse()) { #ifdef INTERDEBUG - MITK_INFO<<"ParamapPresets::LoadPreset xml file cannot parse!"< const ParamapPresets::GetTypePresets() + std::map const ParamapPresetsParser::GetTypePresets() { return m_Type; } - void ParamapPresets::NewPresets(std::map& newType) + void ParamapPresetsParser::NewPresets(std::map& newType) { m_Type = newType; //this->Save(); } }