13 #ifndef __mitkDICOMPMIO__cpp 14 #define __mitkDICOMPMIO__cpp 26 #include <dcmqi/ParaMapConverter.h> 60 if (modalityProperty.IsNotNull())
62 std::string modality = modalityProperty->GetValueAsString();
82 if (PMinput ==
nullptr)
83 mitkThrow() <<
"Cannot write non-image data";
86 vector<std::unique_ptr<DcmDataset>> dcmDatasetsSourceImage;
87 std::unique_ptr<DcmFileFormat> readFileFormat(
new DcmFileFormat());
96 if (filesProp.IsNull())
98 mitkThrow() <<
"No property with dicom file path.";
106 for (
auto it : lookUpTableMap)
108 const char *fileName = (it.second).c_str();
109 if (readFileFormat->loadFile(fileName, EXS_Unknown).good())
111 std::unique_ptr<DcmDataset> readDCMDataset(readFileFormat->getAndRemoveDataset());
112 dcmDatasetsSourceImage.push_back(std::move(readDCMDataset));
116 catch (
const std::exception &e)
118 MITK_ERROR <<
"An error occurred while getting the dicom information: " << e.what() << endl;
125 PMimageToItkFilter->SetInput(mitkPMImage);
128 typedef itk::CastImageFilter<PMitkInputImageType, PMitkInternalImageType> castItkImageFilterType;
129 castItkImageFilterType::Pointer castFilter = castItkImageFilterType::New();
130 castFilter->SetInput(PMimageToItkFilter->GetOutput());
131 castFilter->Update();
132 PMitkInternalImageType::Pointer itkParamapImage = castFilter->GetOutput();
135 const std::string tmpMetaInfoFile = this->CreateMetaDataJsonFilePM();
137 MITK_INFO <<
"Writing PM image: " << path << std::endl;
141 vector<DcmDataset*> rawVecDataset;
142 for (
const auto& dcmDataSet : dcmDatasetsSourceImage ) { rawVecDataset.push_back( dcmDataSet.get() ); }
144 std::unique_ptr<dcmqi::ParaMapConverter> PMconverter(
new dcmqi::ParaMapConverter());
145 std::unique_ptr<DcmDataset> PMresult (PMconverter->itkimage2paramap(itkParamapImage, rawVecDataset, tmpMetaInfoFile));
147 DcmFileFormat dcmFileFormat(PMresult.get());
148 std::string filePath = path.substr(0, path.find_last_of(
"."));
149 filePath = filePath +
".dcm";
150 dcmFileFormat.saveFile(filePath.c_str(), EXS_LittleEndianExplicit);
153 catch (
const std::exception &e)
155 MITK_ERROR <<
"An error occurred during writing the DICOM Paramap: " << e.what() << endl;
161 const std::string mitk::DICOMPMIO::CreateMetaDataJsonFilePM()
const 164 dcmqi::JSONParametricMapMetaInformationHandler PMhandler;
168 std::string parameterName;
176 auto pmType_parameterName = pmPresets->
GetType(parameterName);
177 auto pmType_modelName = pmPresets->
GetType(modelName);
180 PMhandler.setDerivedPixelContrast(
"TCS");
181 PMhandler.setFrameLaterality(
"U");
182 PMhandler.setQuantityValueCode(pmType_parameterName.codeValue, pmType_parameterName.codeScheme, parameterName);
183 PMhandler.setMeasurementMethodCode(pmType_modelName.codeValue, pmType_modelName.codeScheme, modelName);
184 PMhandler.setMeasurementUnitsCode(
"/min",
"UCUM",
"/m");
185 PMhandler.setSeriesNumber(
"1");
186 PMhandler.setInstanceNumber(
"1");
187 PMhandler.setDerivationCode(
"129104",
"DCM",
"Perfusion image analysis");
188 PMhandler.setRealWorldValueSlope(
"1");
190 return PMhandler.getJSONOutputAsString();
197 std::vector<BaseData::Pointer> result;
217 #endif //__mitkDICOMPMIO__cpp std::map< IdentifierType, ValueType > LookupTableType
std::string GetFileName()
Provides the custom mime types for dicom qi objects loaded with DCMQI.
std::string MITKCORE_EXPORT GeneratePropertyNameForDICOMTag(unsigned int group, unsigned int element)
DataCollection - Class to facilitate loading/accessing structured data.
static const std::string MODEL_NAME_PROPERTY_NAME()
void SetRanking(int ranking)
Set the service ranking for this file writer.
const LookupTableType & GetLookupTable() const
ConfidenceLevel GetReaderConfidenceLevel() const override
std::vector< BaseData::Pointer > Read() override
Reads a DICOM parametric maps from the file system.
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
Convenience class to temporarily change the current locale.
std::pair< us::ServiceRegistration< IFileReader >, us::ServiceRegistration< IFileWriter > > RegisterService(us::ModuleContext *context=us::GetModuleContext())
const BaseData * GetInput() const override
Get the input data set via SetInput().
Image class for storing images.
A local file representation for streams.
void Write() override
Write the base data to the specified location or output stream.
void ValidateOutputLocation() const
void SetRanking(int ranking)
Set the service ranking for this file reader.
mitk::PropertyList::Pointer GetPropertyList() const
Get the data's property list.
static ParamapPresetsParser * New()
mitk::BaseProperty::Pointer GetProperty(const char *propertyKey) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList, and set it to this, respectively;.
ConfidenceLevel GetWriterConfidenceLevel() const override
ConfidenceLevel GetWriterConfidenceLevel() const override
Abstract class for implementing a reader and writer.
static const std::string PARAMETER_NAME_PROPERTY_NAME()
Type GetType(const std::string &name)