diff --git a/Applications/Diffusion/CMakeLists.txt b/Applications/Diffusion/CMakeLists.txt index c9b7b0c..7d4acd2 100644 --- a/Applications/Diffusion/CMakeLists.txt +++ b/Applications/Diffusion/CMakeLists.txt @@ -1,101 +1,102 @@ project(MitkDiffusion) set(DIFFUSIONAPP_NAME MitkDiffusion) # Create a cache entry for the provisioning file which is used to export # the file name in the MITKConfig.cmake file. This will keep external projects # which rely on this file happy. set(DIFFUSIONIMAGINGAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DIFFUSIONAPP_NAME}.provisioning" CACHE INTERNAL "${DIFFUSIONAPP_NAME} provisioning file" FORCE) # should be identical to the list in /CMake/mitkBuildConfigurationmitkDiffusion.cmake # remember to set plugins which should be automatically toggled in target_libraries.cmake set(_plugins org.commontk.configadmin org.commontk.eventadmin org.blueberry.core.runtime org.blueberry.core.expressions org.blueberry.core.commands org.blueberry.ui.qt org.blueberry.ui.qt.log org.blueberry.ui.qt.help org.mitk.core.services org.mitk.gui.common org.mitk.planarfigure org.mitk.core.ext org.mitk.gui.qt.application org.mitk.gui.qt.ext org.mitk.gui.qt.diffusionimagingapp org.mitk.gui.qt.common org.mitk.gui.qt.stdmultiwidgeteditor org.mitk.gui.qt.datamanager org.mitk.gui.qt.measurementtoolbox org.mitk.gui.qt.segmentation org.mitk.gui.qt.python org.mitk.gui.qt.volumevisualization org.mitk.gui.qt.diffusionimaging org.mitk.gui.qt.diffusionimaging.connectomics org.mitk.gui.qt.diffusionimaging.fiberfox org.mitk.gui.qt.diffusionimaging.fiberprocessing org.mitk.gui.qt.diffusionimaging.ivim org.mitk.gui.qt.diffusionimaging.odfpeaks org.mitk.gui.qt.diffusionimaging.preprocessing org.mitk.gui.qt.diffusionimaging.reconstruction org.mitk.gui.qt.diffusionimaging.tractography org.mitk.gui.qt.diffusionimaging.registration org.mitk.gui.qt.diffusionimaging.python org.mitk.gui.qt.diffusionimaging.denoising org.mitk.gui.qt.diffusionimaging.partialvolume org.mitk.gui.qt.matchpoint.algorithm.browser org.mitk.gui.qt.matchpoint.algorithm.control org.mitk.gui.qt.matchpoint.mapper org.mitk.gui.qt.imagenavigator org.mitk.gui.qt.moviemaker org.mitk.gui.qt.basicimageprocessing org.mitk.gui.qt.properties org.mitk.gui.qt.viewnavigator org.mitk.gui.qt.renderwindowmanager + org.mitk.gui.qt.pixelvalue ) if(NOT MITK_USE_Python3) list(REMOVE_ITEM _plugins org.mitk.gui.qt.diffusionimaging.python) list(REMOVE_ITEM _plugins org.mitk.gui.qt.python) endif() # Plug-ins listed below will not be # - added as a build-time dependency to the executable # - listed in the provisioning file for the executable # - installed if they are external plug-ins set(_exclude_plugins org.blueberry.test org.blueberry.uitest org.mitk.gui.qt.coreapplication org.mitk.gui.qt.extapplication ) set(_src_files MitkDiffusion.cpp ) qt5_add_resources(_src_files splashscreen.qrc) mitkFunctionCreateBlueBerryApplication( NAME ${DIFFUSIONAPP_NAME} DESCRIPTION "MITK Diffusion" PLUGINS ${_plugins} EXCLUDE_PLUGINS ${_exclude_plugins} SOURCES ${_src_files} ) # Add meta dependencies (e.g. on auto-load modules from depending modules) if(TARGET ${CMAKE_PROJECT_NAME}-autoload) add_dependencies(${DIFFUSIONAPP_NAME} ${CMAKE_PROJECT_NAME}-autoload) endif() # Add a build time dependency to legacy BlueBerry bundles. if(MITK_MODULES_ENABLED_PLUGINS) add_dependencies(${DIFFUSIONAPP_NAME} ${MITK_MODULES_ENABLED_PLUGINS}) endif() diff --git a/Modules/DiffusionCmdApps/FiberProcessing/FiberColoring.cpp b/Modules/DiffusionCmdApps/FiberProcessing/FiberColoring.cpp index 53ab3b0..7b85d1a 100644 --- a/Modules/DiffusionCmdApps/FiberProcessing/FiberColoring.cpp +++ b/Modules/DiffusionCmdApps/FiberProcessing/FiberColoring.cpp @@ -1,114 +1,127 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center. 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 #include #include #include #include #include #include #include #include #include "mitkDiffusionCommandLineParser.h" #include #include #include #include #include #include mitk::FiberBundle::Pointer LoadFib(std::string filename) { std::vector fibInfile = mitk::IOUtil::Load(filename); if( fibInfile.empty() ) std::cout << "File " << filename << " could not be read!"; mitk::BaseData::Pointer baseData = fibInfile.at(0); return dynamic_cast(baseData.GetPointer()); } /*! \brief Modify input tractogram: fiber resampling, compression, pruning and transformation. */ int main(int argc, char* argv[]) { mitkDiffusionCommandLineParser parser; parser.setTitle("Fiber Coloring"); parser.setCategory("Fiber Tracking and Processing Methods"); parser.setDescription("Color tractogram."); parser.setContributor("MIC"); parser.setArgumentPrefix("--", "-"); parser.beginGroup("1. Mandatory arguments:"); parser.addArgument("", "i", mitkDiffusionCommandLineParser::String, "Input:", "Input fiber bundle (.fib, .trk, .tck)", us::Any(), false, false, false, mitkDiffusionCommandLineParser::Input); parser.addArgument("", "o", mitkDiffusionCommandLineParser::String, "Output:", "Output fiber bundle (.fib)", us::Any(), false, false, false, mitkDiffusionCommandLineParser::Output); parser.addArgument("resample", "", mitkDiffusionCommandLineParser::Float, "", ""); parser.endGroup(); parser.beginGroup("2. Color by scalar map:"); parser.addArgument("scalar_map", "", mitkDiffusionCommandLineParser::String, "", "", us::Any(), true, false, false, mitkDiffusionCommandLineParser::Input); + parser.addArgument("lookup", "", mitkDiffusionCommandLineParser::String, "", "JET, MULTILABEL", us::Any(), true, false, false); + parser.addArgument("interpolate", "", mitkDiffusionCommandLineParser::Bool, "", ""); parser.endGroup(); std::map parsedArgs = parser.parseArguments(argc, argv); if (parsedArgs.size()==0) return EXIT_FAILURE; std::string inFileName = us::any_cast(parsedArgs["i"]); std::string outFileName = us::any_cast(parsedArgs["o"]); float resample = -1; if (parsedArgs.count("resample")) resample = us::any_cast(parsedArgs["resample"]); + std::string lookup = "JET"; + if (parsedArgs.count("lookup")) + lookup = us::any_cast(parsedArgs["lookup"]); + + bool interpolate = false; + if (parsedArgs.count("interpolate")) + interpolate = us::any_cast(parsedArgs["interpolate"]); + try { mitk::FiberBundle::Pointer fib = LoadFib(inFileName); if (resample>0) fib->ResampleSpline(resample); if (parsedArgs.count("scalar_map")) { auto scalar_map = mitk::IOUtil::Load(us::any_cast(parsedArgs["scalar_map"])); - fib->ColorFibersByScalarMap(scalar_map, false, false, mitk::LookupTable::MULTILABEL, 1.0); + if (lookup == "JET") + fib->ColorFibersByScalarMap(scalar_map, false, false, mitk::LookupTable::JET, 1.0, interpolate); + else + fib->ColorFibersByScalarMap(scalar_map, false, false, mitk::LookupTable::MULTILABEL, 1.0, false); } mitk::IOUtil::Save(fib.GetPointer(), outFileName ); } catch (const itk::ExceptionObject& e) { std::cout << e.what(); return EXIT_FAILURE; } catch (std::exception& e) { std::cout << e.what(); return EXIT_FAILURE; } catch (...) { std::cout << "ERROR!?!"; return EXIT_FAILURE; } return EXIT_SUCCESS; } diff --git a/Modules/DiffusionIO/ReaderWriter/mitkFiberBundleTrackVisReader.cpp b/Modules/DiffusionIO/ReaderWriter/mitkFiberBundleTrackVisReader.cpp index 1b22f33..dfa927c 100644 --- a/Modules/DiffusionIO/ReaderWriter/mitkFiberBundleTrackVisReader.cpp +++ b/Modules/DiffusionIO/ReaderWriter/mitkFiberBundleTrackVisReader.cpp @@ -1,100 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center. 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 "mitkFiberBundleTrackVisReader.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mitkDiffusionIOMimeTypes.h" mitk::FiberBundleTrackVisReader::FiberBundleTrackVisReader() : mitk::AbstractFileReader( mitk::DiffusionIOMimeTypes::FIBERBUNDLE_TRK_MIMETYPE_NAME(), "TrackVis Fiber Bundle Reader" ) { Options defaultOptions; defaultOptions["Apply index to world transform stored in the TRK header"] = true; defaultOptions["Print header"] = true; - defaultOptions["Flip x"] = false; + defaultOptions["Flip x"] = true; defaultOptions["Flip y"] = false; defaultOptions["Flip z"] = false; this->SetDefaultOptions(defaultOptions); m_ServiceReg = this->RegisterService(); } mitk::FiberBundleTrackVisReader::FiberBundleTrackVisReader(const FiberBundleTrackVisReader &other) :mitk::AbstractFileReader(other) { } mitk::FiberBundleTrackVisReader * mitk::FiberBundleTrackVisReader::Clone() const { return new FiberBundleTrackVisReader(*this); } std::vector > mitk::FiberBundleTrackVisReader::DoRead() { std::vector > result; try { const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, nullptr ); setlocale(LC_ALL, locale.c_str()); std::string filename = this->GetInputLocation(); MITK_INFO << "Loading tractogram (TrackVis format): " << itksys::SystemTools::GetFilenameName(filename); std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); ext = itksys::SystemTools::LowerCase(ext); if (ext==".trk") { Options options = this->GetOptions(); bool apply_matrix = us::any_cast(options["Apply index to world transform stored in the TRK header"]); bool flip_x = us::any_cast(options["Flip x"]); bool flip_y = us::any_cast(options["Flip y"]); bool flip_z = us::any_cast(options["Flip z"]); bool print_header = us::any_cast(options["Print header"]); FiberBundle::Pointer mitk_fib = FiberBundle::New(); TrackVisFiberReader reader; reader.open(this->GetInputLocation().c_str()); reader.read(mitk_fib.GetPointer(), apply_matrix, flip_x, flip_y, flip_z, print_header); result.push_back(mitk_fib.GetPointer()); return result; } setlocale(LC_ALL, currLocale.c_str()); MITK_INFO << "Fiber bundle read"; } catch(...) { throw; } return result; }