diff --git a/CMakeExternals/DCMTK.cmake b/CMakeExternals/DCMTK.cmake index 9a510f85..961d13ff 100644 --- a/CMakeExternals/DCMTK.cmake +++ b/CMakeExternals/DCMTK.cmake @@ -28,13 +28,13 @@ if(NOT DEFINED DCMTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) ExternalProject_SetIfNotDefined( ${proj}_GIT_REPOSITORY - "${EP_GIT_PROTOCOL}://github.com/commontk/DCMTK.git" + "${EP_GIT_PROTOCOL}://github.com/michaelonken/dcmtk.git" QUIET ) ExternalProject_SetIfNotDefined( ${proj}_REVISION_TAG - "patched-DCMTK-3.6.6_20210115" + "use_dcmitem_instead_of_dcmdataset" QUIET ) @@ -94,11 +94,14 @@ if(NOT DEFINED DCMTK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) -DDCMTK_WITH_PNG:BOOL=OFF # see github issue #25 -DDCMTK_WITH_TIFF:BOOL=OFF # see github issue #25 -DDCMTK_WITH_XML:BOOL=OFF # see github issue #25 - -DDCMTK_WITH_ICONV:BOOL=OFF # see github issue #178 + -DDCMTK_WITH_ICU:BOOL=OFF # make sure to not include any ICU dependencies + -DDCMTK_WITH_ICONV:BOOL=OFF # make sure to not include any iconv dependencies -DDCMTK_WITH_SNDFILE:BOOL=OFF # see github issue #395 -DDCMTK_FORCE_FPIC_ON_UNIX:BOOL=ON -DDCMTK_OVERWRITE_WIN32_COMPILER_FLAGS:BOOL=OFF - -DDCMTK_ENABLE_BUILTIN_DICTIONARY:BOOL=ON + -DDCMTK_DEFAULT_DICT:STRING=builtin + -DDCMTK_ENABLE_CHARSET_CONVERSION:STRING=oficonv + -DDCMTK_ENABLE_BUILTIN_OFICONV_DATA:BOOL=ON -DDCMTK_ENABLE_PRIVATE_TAGS:BOOL=ON -DDCMTK_COMPILE_WIN32_MULTITHREADED_DLL:BOOL=ON -DDCMTK_ENABLE_STL:BOOL=ON diff --git a/CMakeLists.txt b/CMakeLists.txt index 558a5b9b..26638e01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,6 +274,7 @@ set(export_targets TRUE) if(DCMQI_SUPERBUILD_BINARY_DIR) string(FIND ${ITK_DIR} "${DCMQI_SUPERBUILD_BINARY_DIR}" itk_here) string(FIND ${DCMTK_DIR} "${DCMQI_SUPERBUILD_BINARY_DIR}" dcmtk_here) + message(STATUS "---------------------------------------- DCMTK DIR: ${DCMTK_DIR} ------------------------------------------") if(NOT ${itk_here} EQUAL -1 OR NOT ${dcmtk_here} EQUAL -1) set(export_targets FALSE) diff --git a/apps/paramaps/itkimage2paramap.cxx b/apps/paramaps/itkimage2paramap.cxx index b43daea9..a216f84a 100644 --- a/apps/paramaps/itkimage2paramap.cxx +++ b/apps/paramaps/itkimage2paramap.cxx @@ -45,7 +45,8 @@ int main(int argc, char *argv[]) (std::istreambuf_iterator())); try { - DcmDataset* result = dcmqi::ParaMapConverter::itkimage2paramap(parametricMapImage, dcmDatasets, metadata); + std::vector toItems(dcmDatasets.begin(), dcmDatasets.end()); + DcmDataset* result = dcmqi::ParaMapConverter::itkimage2paramap(parametricMapImage, toItems, metadata); if (result == NULL) { std::cerr << "ERROR: Conversion failed." << std::endl; diff --git a/include/dcmqi/ConverterBase.h b/include/dcmqi/ConverterBase.h index a9fd4010..b93b1fa7 100644 --- a/include/dcmqi/ConverterBase.h +++ b/include/dcmqi/ConverterBase.h @@ -298,8 +298,8 @@ namespace dcmqi { } // AF: I could not quickly figure out how to template this function over image type - suggestions are welcomed! - static vector > getSliceMapForSegmentation2DerivationImage(const vector dcmDatasets, - const ShortImageType::Pointer &labelImage) { + static vector > getSliceMapForSegmentation2DerivationImage(const vector dcmDatasets, + const ShortImageType::Pointer &labelImage) { // Find mapping from the segmentation slice number to the derivation image // Assume that orientation of the segmentation is the same as the source series unsigned numLabelSlices = labelImage->GetLargestPossibleRegion().GetSize()[2]; diff --git a/include/dcmqi/Dicom2ItkConverter.h b/include/dcmqi/Dicom2ItkConverter.h index 9ffa9d38..9141fd14 100644 --- a/include/dcmqi/Dicom2ItkConverter.h +++ b/include/dcmqi/Dicom2ItkConverter.h @@ -97,7 +97,7 @@ class Dicom2ItkConverter : public ConverterBase * * @param segDataset A pointer to the DICOM dataset containing the metadata. */ - void populateMetaInformationFromDICOM(DcmDataset* segDataset); + void populateMetaInformationFromDICOM(DcmItem* segDataset); /** * Helper method that uses the OverlapUtil class to retrieve non-overlapping segment diff --git a/include/dcmqi/Itk2DicomConverter.h b/include/dcmqi/Itk2DicomConverter.h index 2c0c257b..febdf78e 100644 --- a/include/dcmqi/Itk2DicomConverter.h +++ b/include/dcmqi/Itk2DicomConverter.h @@ -39,7 +39,7 @@ namespace dcmqi { /** * @brief Converts itk images data into a DICOM Segmentation object. * - * @param dcmDatasets A vector of DICOM datasets with the images that the segmentation is based on. + * @param dcmDatasets A vector of DICOM items (usually dataset level) with the images that the segmentation is based on. * @param segmentations A vector of itk images to be converted. * @param metaData A string containing the metadata to be used for the DICOM Segmentation object. * @param skipEmptySlices A boolean indicating whether to skip empty slices during the conversion. @@ -59,7 +59,7 @@ namespace dcmqi { * display. * @return A pointer to the resulting DICOM Segmentation object. */ - static DcmDataset* itkimage2dcmSegmentation(vector dcmDatasets, + static DcmDataset* itkimage2dcmSegmentation(vector dcmDatasets, vector segmentations, const string &metaData, bool skipEmptySlices=true, @@ -78,7 +78,7 @@ namespace dcmqi { * @param segNum2Label mapping from segment number (old) to label ID (new) * @return true if successful, false otherwise */ - static bool mapLabelIDsToSegmentNumbers(DcmDataset* dset, map segNum2Label); + static bool mapLabelIDsToSegmentNumbers(DcmItem* dset, map segNum2Label); /** Check whether labels (values in given map) are unique and monotonically increasing by 1 * @param segNum2Label mapping from segment number (old) to label ID (new) diff --git a/include/dcmqi/ParaMapConverter.h b/include/dcmqi/ParaMapConverter.h index fcabbf49..be4c318d 100644 --- a/include/dcmqi/ParaMapConverter.h +++ b/include/dcmqi/ParaMapConverter.h @@ -34,10 +34,10 @@ namespace dcmqi { class ParaMapConverter : public ConverterBase { public: - static DcmDataset* itkimage2paramap(const FloatImageType::Pointer ¶metricMapImage, vector dcmDatasets, + static DcmDataset* itkimage2paramap(const FloatImageType::Pointer ¶metricMapImage, vector dcmDatasets, const string &metaData); - static pair paramap2itkimage(DcmDataset *pmapDataset); + static pair paramap2itkimage(DcmDataset *pmapDataset); //TODO: Check protected: static OFCondition addFrame(DPMParametricMapIOD &map, const FloatImageType::Pointer ¶metricMapImage, const JSONParametricMapMetaInformationHandler &metaInfo, const unsigned long frameNo, OFVector perFrameGroups); diff --git a/libsrc/CMakeLists.txt b/libsrc/CMakeLists.txt index 9307b538..a171ae39 100644 --- a/libsrc/CMakeLists.txt +++ b/libsrc/CMakeLists.txt @@ -72,9 +72,14 @@ set(_dcmtk_libs) set(_dcmtk_includes) if(TARGET DCMTK::DCMTK) set(_dcmtk_libs DCMTK::DCMTK) + # TODO + MESSAGE(STATUS "------------------------------------- DCMTK::DCMTK: _dcmtk_libs1: ${_dcmtk_libs} --------------------------------") else() set(_dcmtk_libs ${DCMTK_LIBRARIES}) set(_dcmtk_includes ${DCMTK_INCLUDE_DIRS}) + # TODO + MESSAGE(STATUS "------------------------------------- DCMTK::DCMTK: ${DCMTK_LIBRARIES} --------------------------------") + MESSAGE(STATUS "------------------------------------- DCMTK::DCMTK: _dcmtk_libs2: ${_dcmtk_libs} --------------------------------") endif() set(${lib_name}_INCLUDE_DIRS @@ -99,6 +104,8 @@ target_link_libraries(${lib_name} PUBLIC ${ITK_LIBRARIES} $<$>:${JsonCpp_LIBRARY}> ) + # TODO + MESSAGE(STATUS "------------------------------------- DCMTK::DCMTK: _dcmtk_libs3: ${_dcmtk_libs} --------------------------------") if(export_targets) install(TARGETS ${lib_name} diff --git a/libsrc/Dicom2ItkConverter.cpp b/libsrc/Dicom2ItkConverter.cpp index 16fa8da0..60578b2e 100644 --- a/libsrc/Dicom2ItkConverter.cpp +++ b/libsrc/Dicom2ItkConverter.cpp @@ -253,7 +253,7 @@ itk::SmartPointer Dicom2ItkConverter::nextResult() // ------------------------------------------------------------------------------------- -void Dicom2ItkConverter::populateMetaInformationFromDICOM(DcmDataset* segDataset) +void Dicom2ItkConverter::populateMetaInformationFromDICOM(DcmItem* segDataset) { OFString creatorName, sessionID, timePointID, seriesDescription, seriesNumber, instanceNumber, bodyPartExamined, coordinatingCenter; diff --git a/libsrc/Itk2DicomConverter.cpp b/libsrc/Itk2DicomConverter.cpp index b6df6d07..fee33531 100644 --- a/libsrc/Itk2DicomConverter.cpp +++ b/libsrc/Itk2DicomConverter.cpp @@ -18,11 +18,11 @@ namespace dcmqi { // ------------------------------------------------------------------------------------- - DcmDataset* Itk2DicomConverter::itkimage2dcmSegmentation(vector dcmDatasets, - vector segmentations, - const string &metaData, - bool skipEmptySlices, - bool useLabelIDAsSegmentNumber) { + DcmDataset* Itk2DicomConverter::itkimage2dcmSegmentation(vector dcmDatasets, + vector segmentations, + const string &metaData, + bool skipEmptySlices, + bool useLabelIDAsSegmentNumber) { ShortImageType::SizeType inputSize = segmentations[0]->GetBufferedRegion().GetSize(); @@ -352,7 +352,7 @@ namespace dcmqi { frameData[framePixelCnt] = 0; } - OFVector siVector; + OFVector siVector; for(size_t derImageInstanceNum=0; derImageInstanceNum segNum2Label) + bool Itk2DicomConverter::mapLabelIDsToSegmentNumbers(DcmItem* dset, map segNum2Label) { cout << "Mapping Label IDs to Segment Numbers" << endl; DcmSequenceOfItems* seq = NULL; diff --git a/libsrc/ParaMapConverter.cpp b/libsrc/ParaMapConverter.cpp index 6a9f4f30..995f413a 100644 --- a/libsrc/ParaMapConverter.cpp +++ b/libsrc/ParaMapConverter.cpp @@ -15,7 +15,7 @@ using namespace std; namespace dcmqi { - DcmDataset* ParaMapConverter::itkimage2paramap(const FloatImageType::Pointer ¶metricMapImage, vector dcmDatasets, + DcmDataset* ParaMapConverter::itkimage2paramap(const FloatImageType::Pointer ¶metricMapImage, vector dcmDatasets, const string &metaData) { MinMaxCalculatorType::Pointer calculator = MinMaxCalculatorType::New(); @@ -56,7 +56,7 @@ namespace dcmqi { DPMParametricMapIOD* pMapDoc = OFget(&obj); - DcmDataset* srcDataset = NULL; + DcmItem* srcDataset = NULL; if(dcmDatasets.size()){ srcDataset = dcmDatasets[0]; } @@ -285,7 +285,7 @@ namespace dcmqi { for (unsigned long sliceNumber = 0; result.good() && (sliceNumber < inputSize[2]); sliceNumber++) { - OFVector siVector; + OFVector siVector; for(size_t derImageInstanceNum=0; derImageInstanceNum