diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index cb14b1cd73..7bbfe8d866 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -1,65 +1,66 @@ set(MITK_DEFAULT_SUBPROJECTS MITK-Examples) #----------------------------------------------------------------------------- # Set-up example plugins #----------------------------------------------------------------------------- if(MITK_USE_BLUEBERRY) # Specify which plug-ins belong to this project macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin_mitk "^org_mitk_example_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin_mitk OUTPUT_VARIABLE ${varname}) endmacro() include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake") set(mitk_example_plugins_fullpath ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) list(APPEND mitk_example_plugins_fullpath Plugins/${mitk_example_plugin}) endforeach() ctkMacroSetupPlugins(${mitk_example_plugins_fullpath} BUILD_OPTION_PREFIX MITK_BUILD_ COMPACT_OPTIONS) set(MITK_EXAMPLE_PLUGIN_TARGETS ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) ctkFunctionExtractOptionNameAndValue(${mitk_example_plugin} plugin_name plugin_value) string(REPLACE "." "_" _plugin_target ${plugin_name}) list(APPEND MITK_EXAMPLE_PLUGIN_TARGETS ${_plugin_target}) mark_as_advanced(${${_plugin_target}_option_name}) endforeach() endif() #----------------------------------------------------------------------------- # Add example executables #----------------------------------------------------------------------------- set(MITK_DIR ${PROJECT_BINARY_DIR}) set(MITK_EXPORTS_FILE_INCLUDED 1) set(_example_dirs MbiLog QtFreeRender ) if(MITK_USE_QT) list(APPEND _example_dirs Tutorial QtAppExample + mitkdump ) endif() if(MITK_USE_BLUEBERRY) list(APPEND _example_dirs BlueBerryExampleLauncher ) endif() foreach(_example_dir ${_example_dirs}) add_subdirectory(${_example_dir}) endforeach() diff --git a/Examples/mitkdump/CMakeLists.txt b/Examples/mitkdump/CMakeLists.txt new file mode 100644 index 0000000000..ad822a380c --- /dev/null +++ b/Examples/mitkdump/CMakeLists.txt @@ -0,0 +1,25 @@ +project(mitkdump) +find_package(MITK) + +# Check prerequisites for this application. +# We need the Mitk module. +MITK_CHECK_MODULE(result Mitk) +if(result) + message(SEND_ERROR "MITK module(s) \"${result}\" not available from the MITK build at ${MITK_DIR}") +endif() + +# Set-up the build system to use the Mitk module +MITK_USE_MODULE(Mitk) +MITK_USE_MODULE(DICOMReader) +include_directories(${ALL_INCLUDE_DIRECTORIES}) +link_directories(${ALL_LIBRARY_DIRS}) + +add_executable(${PROJECT_NAME} mitkdump.cpp) +target_link_libraries(${PROJECT_NAME} ${ALL_LIBRARIES} ) + +# subproject support +set_property(TARGET ${PROJECT_NAME} PROPERTY LABELS ${MITK_DEFAULT_SUBPROJECTS}) +foreach(subproject ${MITK_DEFAULT_SUBPROJECTS}) + add_dependencies(${subproject} ${PROJECT_NAME}) +endforeach() + diff --git a/Examples/mitkdump/mitkdump.cpp b/Examples/mitkdump/mitkdump.cpp new file mode 100644 index 0000000000..370d04a33b --- /dev/null +++ b/Examples/mitkdump/mitkdump.cpp @@ -0,0 +1,86 @@ +/*=================================================================== + + 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 "mitkDICOMITKSeriesGDCMReader.h" +#include "mitkDICOMTagBasedSorter.h" +#include "mitkDICOMSortByTag.h" + +int main(int argc, char* argv[]) +{ + mitk::StringList inputFiles; // TODO + for (int a = 1; a < argc; ++a) + { + inputFiles.push_back( std::string(argv[a]) ); + } + + // ----------------- Configure reader ------------------- + + mitk::DICOMITKSeriesGDCMReader::Pointer gdcmReader = + mitk::DICOMITKSeriesGDCMReader::New(); + + mitk::DICOMTagBasedSorter::Pointer tagSorter = + mitk::DICOMTagBasedSorter::New(); + + // all the things that split by tag in DicomSeriesReader + tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0010) ); // Number of Rows + tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0011) ); // Number of Columns + tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0030) ); // Pixel Spacing + tagSorter->AddDistinguishingTag( std::make_pair(0x0018, 0x1164) ); // Imager Pixel Spacing + tagSorter->AddDistinguishingTag( std::make_pair(0x0020, 0x0037) ); // Image Orientation (Patient) // TODO add tolerance parameter (l. 1572 of original code) + tagSorter->AddDistinguishingTag( std::make_pair(0x0020, 0x000e) ); // Series Instance UID + tagSorter->AddDistinguishingTag( std::make_pair(0x0018, 0x0050) ); // Slice Thickness + tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0008) ); // Number of Frames + + // a sorter... + // TODO ugly syntax, improve.. + mitk::DICOMSortCriterion::ConstPointer sorting = + mitk::DICOMSortByTag::New( std::make_pair(0x0020, 0x0013), // instance number + mitk::DICOMSortByTag::New( std::make_pair(0x0020, 0x0012), // aqcuisition number + mitk::DICOMSortByTag::New( std::make_pair(0x0008, 0x0032), // aqcuisition time + mitk::DICOMSortByTag::New( std::make_pair(0x0018, 0x1060), // trigger time + mitk::DICOMSortByTag::New( std::make_pair(0x0008, 0x0018) // SOP instance UID (last resort, not really meaningful but decides clearly) + ).GetPointer() + ).GetPointer() + ).GetPointer() + ).GetPointer() + ).GetPointer(); + tagSorter->SetSortCriterion( sorting ); + + gdcmReader->AddSortingElement( tagSorter ); + + // ----------------- Load ------------------- + + gdcmReader->SetInputFiles( inputFiles ); + + MITK_INFO << "Analyzing " << inputFiles.size() << " file ..."; + gdcmReader->AnalyzeInputFiles(); + MITK_INFO << "Loading " << inputFiles.size() << " file ..."; + gdcmReader->LoadImages(); + + unsigned int numberOfOutputs = gdcmReader->GetNumberOfOutputs(); + for (unsigned int o = 0; o < numberOfOutputs; ++o) + { + const mitk::DICOMImageBlockDescriptor block = gdcmReader->GetOutput(o); + + const mitk::DICOMImageFrameList& outputFiles = block.GetImageFrameList(); + mitk::Image::Pointer mitkImage = block.GetMitkImage(); + + MITK_INFO << "-------------------------------------------"; + MITK_INFO << "Output " << o << " at " << (void*) mitkImage.GetPointer(); + MITK_INFO << " Number of files: " << outputFiles.size(); + MITK_INFO << " Dimensions: " << mitkImage->GetDimension(0) << " " << mitkImage->GetDimension(1) << " " << mitkImage->GetDimension(2); + } +} diff --git a/Modules/DICOMReader/Testing/mitkDICOMITKSeriesGDCMReaderBasicsTest.cpp b/Modules/DICOMReader/Testing/mitkDICOMITKSeriesGDCMReaderBasicsTest.cpp index 5574e730d1..d4d0183c2f 100644 --- a/Modules/DICOMReader/Testing/mitkDICOMITKSeriesGDCMReaderBasicsTest.cpp +++ b/Modules/DICOMReader/Testing/mitkDICOMITKSeriesGDCMReaderBasicsTest.cpp @@ -1,84 +1,85 @@ /*=================================================================== 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 "mitkDICOMITKSeriesGDCMReader.h" #include "mitkDICOMFileReaderTestHelper.h" #include "mitkDICOMFilenameSorter.h" #include "mitkDICOMTagBasedSorter.h" #include "mitkDICOMSortByTag.h" #include "mitkTestingMacros.h" int mitkDICOMITKSeriesGDCMReaderBasicsTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkDICOMITKSeriesGDCMReaderBasicsTest"); mitk::DICOMITKSeriesGDCMReader::Pointer gdcmReader = mitk::DICOMITKSeriesGDCMReader::New(); MITK_TEST_CONDITION_REQUIRED(gdcmReader.IsNotNull(), "DICOMITKSeriesGDCMReader can be instantiated."); mitk::DICOMFileReaderTestHelper::SetTestInputFilenames( argc,argv ); // check the Set/GetInput function mitk::DICOMFileReaderTestHelper::TestInputFilenames( gdcmReader ); // check that output is a good reproduction of input (no duplicates, no new elements) mitk::DICOMFileReaderTestHelper::TestOutputsContainInputs( gdcmReader ); // repeat test with filename based sorter in-between mitk::DICOMFilenameSorter::Pointer filenameSorter = mitk::DICOMFilenameSorter::New(); gdcmReader->AddSortingElement( filenameSorter ); mitk::DICOMFileReaderTestHelper::TestOutputsContainInputs( gdcmReader ); // repeat test with some more realistic sorting gdcmReader = mitk::DICOMITKSeriesGDCMReader::New(); // this also tests destruction mitk::DICOMTagBasedSorter::Pointer tagSorter = mitk::DICOMTagBasedSorter::New(); // all the things that split by tag in DicomSeriesReader tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0010) ); // Number of Rows tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0011) ); // Number of Columns tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0030) ); // Pixel Spacing tagSorter->AddDistinguishingTag( std::make_pair(0x0018, 0x1164) ); // Imager Pixel Spacing tagSorter->AddDistinguishingTag( std::make_pair(0x0020, 0x0037) ); // Image Orientation (Patient) // TODO add tolerance parameter (l. 1572 of original code) + // TODO handle as real vectors! cluster with configurable errors! tagSorter->AddDistinguishingTag( std::make_pair(0x0020, 0x000e) ); // Series Instance UID tagSorter->AddDistinguishingTag( std::make_pair(0x0018, 0x0050) ); // Slice Thickness tagSorter->AddDistinguishingTag( std::make_pair(0x0028, 0x0008) ); // Number of Frames // a sorter... // TODO ugly syntax, improve.. mitk::DICOMSortCriterion::ConstPointer sorting = mitk::DICOMSortByTag::New( std::make_pair(0x0020, 0x0013), // instance number mitk::DICOMSortByTag::New( std::make_pair(0x0020, 0x0012), // aqcuisition number mitk::DICOMSortByTag::New( std::make_pair(0x0008, 0x0032), // aqcuisition time mitk::DICOMSortByTag::New( std::make_pair(0x0018, 0x1060), // trigger time mitk::DICOMSortByTag::New( std::make_pair(0x0008, 0x0018) // SOP instance UID (last resort, not really meaningful but decides clearly) ).GetPointer() ).GetPointer() ).GetPointer() ).GetPointer() ).GetPointer(); tagSorter->SetSortCriterion( sorting ); gdcmReader->AddSortingElement( tagSorter ); mitk::DICOMFileReaderTestHelper::TestOutputsContainInputs( gdcmReader ); gdcmReader->PrintOutputs(std::cout, true); // really load images mitk::DICOMFileReaderTestHelper::TestMitkImagesAreLoaded( gdcmReader ); MITK_TEST_END(); }