diff --git a/Modules/CommonCommandLineApps/CMakeLists.txt b/Modules/CommonCommandLineApps/CMakeLists.txt new file mode 100644 index 0000000000..bf8b157e06 --- /dev/null +++ b/Modules/CommonCommandLineApps/CMakeLists.txt @@ -0,0 +1,88 @@ +option(BUILD_CommonCommandlineApps "Build common commandline apps for MITK" OFF) + +if(BUILD_CommonCommandlineApps OR MITK_BUILD_ALL_APPS) + + + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + + # list of miniapps + # if an app requires additional dependencies + # they are added after a "^^" and separated by "_" + set( commonMiniApps + ExtractTimeStepFrom4DImage^^ + ) + + + foreach(commonMiniApps ${commonMiniApps}) + # extract mini app name and dependencies + string(REPLACE "^^" "\\;" miniapp_info ${commonMiniApps}) + set(miniapp_info_list ${miniapp_info}) + list(GET miniapp_info_list 0 appname) + list(GET miniapp_info_list 1 raw_dependencies) + string(REPLACE "_" "\\;" dependencies "${raw_dependencies}") + set(dependencies_list ${dependencies}) + + mitk_create_executable(${appname} + DEPENDS MitkCore ${dependencies_list} + PACKAGE_DEPENDS ITK PUBLIC Boost + CPP_FILES ${appname}.cpp mitkCommandLineParser.cpp + ) + + if(EXECUTABLE_IS_ENABLED) + + # On Linux, create a shell script to start a relocatable application + if(UNIX AND NOT APPLE) + install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${EXECUTABLE_TARGET}.sh) + endif() + + get_target_property(_is_bundle ${EXECUTABLE_TARGET} MACOSX_BUNDLE) + + if(APPLE) + if(_is_bundle) + set(_target_locations ${EXECUTABLE_TARGET}.app) + set(${_target_locations}_qt_plugins_install_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS) + set(_bundle_dest_dir ${EXECUTABLE_TARGET}.app/Contents/MacOS) + set(_qt_plugins_for_current_bundle ${EXECUTABLE_TARGET}.app/Contents/MacOS) + set(_qt_conf_install_dirs ${EXECUTABLE_TARGET}.app/Contents/Resources) + install(TARGETS ${EXECUTABLE_TARGET} BUNDLE DESTINATION . ) + else() + if(NOT MACOSX_BUNDLE_NAMES) + set(_qt_conf_install_dirs bin) + set(_target_locations bin/${EXECUTABLE_TARGET}) + set(${_target_locations}_qt_plugins_install_dir bin) + install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin) + else() + foreach(bundle_name ${MACOSX_BUNDLE_NAMES}) + list(APPEND _qt_conf_install_dirs ${bundle_name}.app/Contents/Resources) + set(_current_target_location ${bundle_name}.app/Contents/MacOS/${EXECUTABLE_TARGET}) + list(APPEND _target_locations ${_current_target_location}) + set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) + message( " set(${_current_target_location}_qt_plugins_install_dir ${bundle_name}.app/Contents/MacOS) ") + + install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION ${bundle_name}.app/Contents/MacOS/) + endforeach() + endif() + endif() + else() + set(_target_locations bin/${EXECUTABLE_TARGET}${CMAKE_EXECUTABLE_SUFFIX}) + set(${_target_locations}_qt_plugins_install_dir bin) + set(_qt_conf_install_dirs bin) + install(TARGETS ${EXECUTABLE_TARGET} RUNTIME DESTINATION bin) + endif() + endif() + endforeach() + + + # On Linux, create a shell script to start a relocatable application + if(UNIX AND NOT APPLE) + install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${EXECUTABLE_TARGET}.sh) + endif() + + if(EXECUTABLE_IS_ENABLED) + MITK_INSTALL_TARGETS(EXECUTABLES ${EXECUTABLE_TARGET}) + endif() + +endif() diff --git a/Modules/CommonCommandLineApps/ExtractTimeStepFrom4DImage.cpp b/Modules/CommonCommandLineApps/ExtractTimeStepFrom4DImage.cpp new file mode 100644 index 0000000000..32e6298bb2 --- /dev/null +++ b/Modules/CommonCommandLineApps/ExtractTimeStepFrom4DImage.cpp @@ -0,0 +1,195 @@ +/*=================================================================== + + 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 "mitkCommandLineParser.h" +#include "mitkImage.h" +#include "mitkIOUtil.h" +#include +#include +#include + +#include +#include +#include + + +//Used to check if file exists before trying to open it. +//However, this might get a wrong result if the file exists but the user is not allowed to open it. +bool fileExists(const std::string& filename) +{ + ifstream infile(filename.c_str()); + return infile.good(); +} + +//split the ints for the interval +static vector splitInt(string str, char delimiter) { + vector internal; + stringstream ss(str); // Turn the string into a stream. + string tok; + double val; + while (getline(ss, tok, delimiter)) { + stringstream s2(tok); + s2 >> val; + internal.push_back(val); + } + return internal; +} + +void extractTimeStepFromImage(mitk::Image::Pointer inputImage, + int timeStep, + std::string basePath, + std::string fileType) +{ + bool canExecute = true; + + if(inputImage->GetDimension() != 4) + { + MITK_ERROR << "Input image does not have 4 dimensions. Aborting."; + canExecute = false; + } + + if(inputImage->GetTimeSteps() <= timeStep) + { + MITK_ERROR << "You like to extract t = " << timeStep << ", but the image only contains " << + inputImage->GetTimeSteps() << " (0 indexed) time steps."; + canExecute = false; + } + + if(canExecute) + { + std::stringstream ss; + ss << basePath + << "_t=" + << timeStep + << fileType; + + std::string outputPath = ss.str(); + + mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New(); + timeSelector->SetInput(inputImage); + timeSelector->SetTimeNr(timeStep); + timeSelector->Update(); + + mitk::Image::Pointer outputImage = timeSelector->GetOutput(); + MITK_INFO << " -> Saving image for t = " << timeStep << " to " << outputPath; + mitk::IOUtil::Save(outputImage, outputPath); + } + return; +} + +void extractMultipleImages(std::string inputPath, + int firstStep, + int lastStep, + std::string basePath, + std::string fileType) +{ + mitk::Image::Pointer inputImage = mitk::IOUtil::LoadImage(inputPath); + + if(lastStep < 0) + lastStep = inputImage->GetTimeSteps() - 1; + + for(int i = firstStep; i <= lastStep;i++) + { + extractTimeStepFromImage(inputImage, i, basePath, fileType); + } +} + +int main(int argc, char* argv[]) +{ + mitkCommandLineParser parser; + + parser.setTitle("4D TimeStep Extractor"); + parser.setCategory("Common Commandline Tools"); + parser.setDescription(""); + parser.setContributor("MBI"); + + parser.setArgumentPrefix("--", "-"); + parser.addArgument("help", "h", mitkCommandLineParser::String, "Help:", "Show this help text"); + parser.addArgument("input", "i", mitkCommandLineParser::InputFile, "Input:", "Input image path", us::Any(),false); + parser.addArgument("timestep", "t", mitkCommandLineParser::Int, "Time-Step:", "Desired zero-indexed time-step to be extracted, default: 0", us::Any()); + parser.addArgument("extractAll", "a", mitkCommandLineParser::Bool, "Extract all:", "Extract all timesteps.", us::Any()); + parser.addArgument("range", "r", mitkCommandLineParser::String, "Range:","Provide an interval for the timesteps to be exported. Use 3;5 for example."); + + map parsedArgs = parser.parseArguments(argc, argv); + + if (parsedArgs.size()==0 || parsedArgs.count("help") || parsedArgs.count("h")) + { + std::cout << "MiniApp Description: \nExtract an 3D Image from a 4D Volume" << endl; + std::cout << "The output image will be saved in the same folder as the input image." << endl; + std::cout << "\nParameters:" << endl; + std::cout << parser.helpText(); + return EXIT_SUCCESS; + } + + std::string inputImagePath = us::any_cast(parsedArgs["input"]); + + int timeStep = 0; + if (parsedArgs.count("timestep") || parsedArgs.count("t")) + { + timeStep = us::any_cast(parsedArgs["timestep"]); + } + + bool success = true; + + std::string fileType = itksys::SystemTools::GetFilenameExtension(inputImagePath); + std::size_t found = inputImagePath.rfind(fileType); + + std::string basePath = inputImagePath.substr(0,found); + + if (fileExists(inputImagePath)) + { + //Extract a single timestep + if((parsedArgs.count("range") == 0 || parsedArgs.count("r")) && + (parsedArgs.count("extractAll") == 0 || parsedArgs.count("a"))) + { + MITK_INFO << "Extracting t = " << timeStep << " from Image " << inputImagePath; + extractMultipleImages(inputImagePath, timeStep, timeStep, basePath, fileType); + } + + //Exstract an interval + else if(parsedArgs.count("extractAll") == 0 || parsedArgs.count("a")) + { + std::string interval = us::any_cast(parsedArgs["range"]); + vector intervalValues = splitInt(interval, ';'); + + if(intervalValues.size() != 2 || intervalValues[0] > intervalValues[1]) + { + MITK_WARN << "The interval you provided is invalid. Please specify only 2 values in ascending order."; + success = false; + } + else + { + extractMultipleImages(inputImagePath, intervalValues[0], intervalValues[1], basePath, fileType); + } + } + + //Extract all + else + { + extractMultipleImages(inputImagePath, 0, -1, basePath, fileType); + } + } + else + { + MITK_ERROR << "Input image does not exist."; + success = false; + } + + if(success) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; +} diff --git a/Modules/CommonCommandLineApps/mitkCommandLineParser.cpp b/Modules/CommonCommandLineApps/mitkCommandLineParser.cpp new file mode 100644 index 0000000000..c6d1721d08 --- /dev/null +++ b/Modules/CommonCommandLineApps/mitkCommandLineParser.cpp @@ -0,0 +1,900 @@ +/*=================================================================== + +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. + +===================================================================*/ +/*========================================================================= + + Library: CTK + + Copyright (c) Kitware Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +// STL includes +#include +#include + + +// MITK includes +#include "mitkCommandLineParser.h" + + +using namespace std; + +namespace +{ +// -------------------------------------------------------------------------- +class CommandLineParserArgumentDescription +{ +public: + + + CommandLineParserArgumentDescription( + const string& longArg, const string& longArgPrefix, + const string& shortArg, const string& shortArgPrefix, + mitkCommandLineParser::Type type, const string& argHelp, const string& argLabel, + const us::Any& defaultValue, bool ignoreRest, + bool deprecated, bool optional, string& argGroup, string& groupDescription) + : LongArg(longArg), LongArgPrefix(longArgPrefix), + ShortArg(shortArg), ShortArgPrefix(shortArgPrefix), + ArgHelp(argHelp), ArgLabel(argLabel), IgnoreRest(ignoreRest), NumberOfParametersToProcess(0), + Deprecated(deprecated), DefaultValue(defaultValue), Value(type), ValueType(type), Optional(optional), ArgGroup(argGroup), ArgGroupDescription(groupDescription) + { + Value = defaultValue; + + switch (type) + { + case mitkCommandLineParser::String: + { + NumberOfParametersToProcess = 1; + } + break; + case mitkCommandLineParser::Bool: + { + NumberOfParametersToProcess = 0; + } + break; + case mitkCommandLineParser::StringList: + { + NumberOfParametersToProcess = -1; + } + break; + case mitkCommandLineParser::Int: + { + NumberOfParametersToProcess = 1; + } + break; + case mitkCommandLineParser::Float: + { + NumberOfParametersToProcess = 1; + } + break; + + case mitkCommandLineParser::OutputDirectory: + case mitkCommandLineParser::InputDirectory: + { + NumberOfParametersToProcess = 1; + } + break; + + case mitkCommandLineParser::OutputFile: + case mitkCommandLineParser::InputFile: + { + NumberOfParametersToProcess = 1; + } + break; + case mitkCommandLineParser::InputImage: + { + NumberOfParametersToProcess = 1; + } + break; + + default: + std::cout << "Type not supported: " << static_cast(type); + } + + } + + ~CommandLineParserArgumentDescription(){} + + bool addParameter(const string& value); + + string helpText(); + + string LongArg; + string LongArgPrefix; + string ShortArg; + string ShortArgPrefix; + string ArgHelp; + string ArgLabel; + string ArgGroup; + string ArgGroupDescription; + bool IgnoreRest; + int NumberOfParametersToProcess; + bool Deprecated; + bool Optional; + + us::Any DefaultValue; + us::Any Value; + mitkCommandLineParser::Type ValueType; +}; + +// -------------------------------------------------------------------------- +bool CommandLineParserArgumentDescription::addParameter(const string &value) +{ + switch (ValueType) + { + case mitkCommandLineParser::String: + { + Value = value; + } + break; + case mitkCommandLineParser::Bool: + { + if (value.compare("true")==0) + Value = true; + else + Value = false; + } + break; + case mitkCommandLineParser::StringList: + { + try + { + mitkCommandLineParser::StringContainerType list = us::any_cast(Value); + list.push_back(value); + Value = list; + } + catch(...) + { + mitkCommandLineParser::StringContainerType list; + list.push_back(value); + Value = list; + } + } + break; + case mitkCommandLineParser::Int: + { + stringstream ss(value); + int i; + ss >> i; + Value = i; + } + break; + case mitkCommandLineParser::Float: + { + stringstream ss(value); + float f; + ss >> f; + Value = f; + } + break; + + case mitkCommandLineParser::InputDirectory: + case mitkCommandLineParser::OutputDirectory: + { + Value = value; + } + break; + + case mitkCommandLineParser::InputFile: + case mitkCommandLineParser::InputImage: + case mitkCommandLineParser::OutputFile: + { + Value = value; + } + break; + + default: + return false; + } + + return true; +} + +// -------------------------------------------------------------------------- +string CommandLineParserArgumentDescription::helpText() +{ + string text; + + string shortAndLongArg; + if (!this->ShortArg.empty()) + { + shortAndLongArg = " "; + shortAndLongArg += this->ShortArgPrefix; + shortAndLongArg += this->ShortArg; + } + + if (!this->LongArg.empty()) + { + if (this->ShortArg.empty()) + shortAndLongArg.append(" "); + else + shortAndLongArg.append(", "); + + shortAndLongArg += this->LongArgPrefix; + shortAndLongArg += this->LongArg; + } + + text = text + shortAndLongArg + ", " + this->ArgHelp; + + if (this->Optional) + text += " (optional)"; + + if (!this->DefaultValue.Empty()) + { + text = text + ", (default: " + this->DefaultValue.ToString() + ")"; + } + text += "\n"; + return text; +} + +} + +// -------------------------------------------------------------------------- +// ctkCommandLineParser::ctkInternal class + +// -------------------------------------------------------------------------- +class mitkCommandLineParser::ctkInternal +{ +public: + ctkInternal() + : Debug(false), FieldWidth(0), StrictMode(false) + {} + + ~ctkInternal() { } + + CommandLineParserArgumentDescription* argumentDescription(const string& argument); + + vector ArgumentDescriptionList; + map ArgNameToArgumentDescriptionMap; + map > GroupToArgumentDescriptionListMap; + + StringContainerType UnparsedArguments; + StringContainerType ProcessedArguments; + string ErrorString; + bool Debug; + int FieldWidth; + string LongPrefix; + string ShortPrefix; + string CurrentGroup; + string DisableQSettingsLongArg; + string DisableQSettingsShortArg; + bool StrictMode; +}; + +// -------------------------------------------------------------------------- +// ctkCommandLineParser::ctkInternal methods + +// -------------------------------------------------------------------------- +CommandLineParserArgumentDescription* +mitkCommandLineParser::ctkInternal::argumentDescription(const string& argument) +{ + string unprefixedArg = argument; + + if (!LongPrefix.empty() && argument.compare(0, LongPrefix.size(), LongPrefix)==0) + { + // Case when (ShortPrefix + UnPrefixedArgument) matches LongPrefix + if (argument == LongPrefix && !ShortPrefix.empty() && argument.compare(0, ShortPrefix.size(), ShortPrefix)==0) + { + unprefixedArg = argument.substr(ShortPrefix.size(),argument.size()); + } + else + { + unprefixedArg = argument.substr(LongPrefix.size(),argument.size()); + } + } + else if (!ShortPrefix.empty() && argument.compare(0, ShortPrefix.size(), ShortPrefix)==0) + { + unprefixedArg = argument.substr(ShortPrefix.size(),argument.size()); + } + else if (!LongPrefix.empty() && !ShortPrefix.empty()) + { + return 0; + } + + if (ArgNameToArgumentDescriptionMap.count(unprefixedArg)) + { + return this->ArgNameToArgumentDescriptionMap[unprefixedArg]; + } + return 0; +} + +// -------------------------------------------------------------------------- +// ctkCommandLineParser methods + +// -------------------------------------------------------------------------- +mitkCommandLineParser::mitkCommandLineParser() +{ + this->Internal = new ctkInternal(); + this->Category = string(); + this->Title = string(); + this->Contributor = string(); + this->Description = string(); + this->ParameterGroupName = "Parameters"; + this->ParameterGroupDescription = "Parameters"; +} + +// -------------------------------------------------------------------------- +mitkCommandLineParser::~mitkCommandLineParser() +{ + delete this->Internal; +} + +// -------------------------------------------------------------------------- +map mitkCommandLineParser::parseArguments(const StringContainerType& arguments, + bool* ok) +{ + // Reset + this->Internal->UnparsedArguments.clear(); + this->Internal->ProcessedArguments.clear(); + this->Internal->ErrorString.clear(); + // foreach (CommandLineParserArgumentDescription* desc, this->Internal->ArgumentDescriptionList) + for (unsigned int i=0; iArgumentDescriptionList.size(); i++) + { + CommandLineParserArgumentDescription* desc = Internal->ArgumentDescriptionList.at(i); + desc->Value = us::Any(desc->ValueType); + if (!desc->DefaultValue.Empty()) + { + desc->Value = desc->DefaultValue; + } + } + bool error = false; + bool ignoreRest = false; + CommandLineParserArgumentDescription * currentArgDesc = 0; + vector parsedArgDescriptions; + for(unsigned int i = 1; i < arguments.size(); ++i) + { + string argument = arguments.at(i); + + if (this->Internal->Debug) { std::cout << "Processing" << argument; } + if (!argument.compare("--xml") || !argument.compare("-xml") || !argument.compare("--XML") || !argument.compare("-XML")) + { + this->generateXmlOutput(); + return map(); + } + + // should argument be ignored ? + if (ignoreRest) + { + if (this->Internal->Debug) + { + std::cout << " Skipping: IgnoreRest flag was been set"; + } + this->Internal->UnparsedArguments.push_back(argument); + continue; + } + + // Skip if the argument does not start with the defined prefix + if (!(argument.compare(0, Internal->LongPrefix.size(), Internal->LongPrefix)==0 + || argument.compare(0, Internal->ShortPrefix.size(), Internal->ShortPrefix)==0)) + { + if (this->Internal->StrictMode) + { + this->Internal->ErrorString = "Unknown argument "; + this->Internal->ErrorString += argument; + error = true; + break; + } + if (this->Internal->Debug) + { + std::cout << " Skipping: It does not start with the defined prefix"; + } + this->Internal->UnparsedArguments.push_back(argument); + continue; + } + + // Skip if argument has already been parsed ... + bool alreadyProcessed = false; + for (unsigned int i=0; iProcessedArguments.size(); i++) + if (argument.compare(Internal->ProcessedArguments.at(i))==0) + { + alreadyProcessed = true; + break; + } + + if (alreadyProcessed) + { + if (this->Internal->StrictMode) + { + this->Internal->ErrorString = "Argument "; + this->Internal->ErrorString += argument; + this->Internal->ErrorString += " already processed !"; + error = true; + break; + } + if (this->Internal->Debug) + { + std::cout << " Skipping: Already processed !"; + } + continue; + } + + // Retrieve corresponding argument description + currentArgDesc = this->Internal->argumentDescription(argument); + + // Is there a corresponding argument description ? + if (currentArgDesc) + { + // If the argument is deprecated, print the help text but continue processing + if (currentArgDesc->Deprecated) + { + std::cout << "Deprecated argument " << argument << ": " << currentArgDesc->ArgHelp; + } + else + { + parsedArgDescriptions.push_back(currentArgDesc); + } + + this->Internal->ProcessedArguments.push_back(currentArgDesc->ShortArg); + this->Internal->ProcessedArguments.push_back(currentArgDesc->LongArg); + int numberOfParametersToProcess = currentArgDesc->NumberOfParametersToProcess; + ignoreRest = currentArgDesc->IgnoreRest; + if (this->Internal->Debug && ignoreRest) + { + std::cout << " IgnoreRest flag is True"; + } + + // Is the number of parameters associated with the argument being processed known ? + if (numberOfParametersToProcess == 0) + { + currentArgDesc->addParameter("true"); + } + else if (numberOfParametersToProcess > 0) + { + string missingParameterError = + "Argument %1 has %2 value(s) associated whereas exacly %3 are expected."; + for(int j=1; j <= numberOfParametersToProcess; ++j) + { + if (i + j >= arguments.size()) + { +// this->Internal->ErrorString = +// missingParameterError.arg(argument).arg(j-1).arg(numberOfParametersToProcess); +// if (this->Internal->Debug) { std::cout << this->Internal->ErrorString; } + if (ok) { *ok = false; } + return map(); + } + string parameter = arguments.at(i + j); + if (this->Internal->Debug) + { + std::cout << " Processing parameter" << j << ", value:" << parameter; + } + if (this->argumentAdded(parameter)) + { +// this->Internal->ErrorString = +// missingParameterError.arg(argument).arg(j-1).arg(numberOfParametersToProcess); +// if (this->Internal->Debug) { std::cout << this->Internal->ErrorString; } + if (ok) { *ok = false; } + return map(); + } + if (!currentArgDesc->addParameter(parameter)) + { +// this->Internal->ErrorString = string( +// "Value(s) associated with argument %1 are incorrect. %2"). +// arg(argument).arg(currentArgDesc->ExactMatchFailedMessage); +// if (this->Internal->Debug) { std::cout << this->Internal->ErrorString; } + if (ok) { *ok = false; } + return map(); + } + } + // Update main loop increment + i = i + numberOfParametersToProcess; + } + else if (numberOfParametersToProcess == -1) + { + if (this->Internal->Debug) + { + std::cout << " Proccessing StringList ..."; + } + int j = 1; + while(j + i < arguments.size()) + { + if (this->argumentAdded(arguments.at(j + i))) + { + if (this->Internal->Debug) + { + std::cout << " No more parameter for" << argument; + } + break; + } + string parameter = arguments.at(j + i); + + if (parameter.compare(0, Internal->LongPrefix.size(), Internal->LongPrefix)==0 + || parameter.compare(0, Internal->ShortPrefix.size(), Internal->ShortPrefix)==0) + { + j--; + break; + } + + if (this->Internal->Debug) + { + std::cout << " Processing parameter" << j << ", value:" << parameter; + } + if (!currentArgDesc->addParameter(parameter)) + { +// this->Internal->ErrorString = string( +// "Value(s) associated with argument %1 are incorrect. %2"). +// arg(argument).arg(currentArgDesc->ExactMatchFailedMessage); +// if (this->Internal->Debug) { std::cout << this->Internal->ErrorString; } + if (ok) { *ok = false; } + return map(); + } + j++; + } + // Update main loop increment + i = i + j; + } + } + else + { + if (this->Internal->StrictMode) + { + this->Internal->ErrorString = "Unknown argument "; + this->Internal->ErrorString += argument; + error = true; + break; + } + if (this->Internal->Debug) + { + std::cout << " Skipping: Unknown argument"; + } + this->Internal->UnparsedArguments.push_back(argument); + } + } + + if (ok) + { + *ok = !error; + } + + map parsedArguments; + + int obligatoryArgs = 0; + vector::iterator it; + for(it = Internal->ArgumentDescriptionList.begin(); it != Internal->ArgumentDescriptionList.end();++it) + { + CommandLineParserArgumentDescription* desc = *it; + + if(!desc->Optional) + obligatoryArgs++; + } + + int parsedObligatoryArgs = 0; + for(it = parsedArgDescriptions.begin(); it != parsedArgDescriptions.end();++it) + { + CommandLineParserArgumentDescription* desc = *it; + + string key; + if (!desc->LongArg.empty()) + { + key = desc->LongArg; + } + else + { + key = desc->ShortArg; + } + + if(!desc->Optional) + parsedObligatoryArgs++; + + std::pair elem; elem.first = key; elem.second = desc->Value; + parsedArguments.insert(elem); + } + + if (obligatoryArgs>parsedObligatoryArgs) + { + parsedArguments.clear(); + //cout << helpText(); + } + + return parsedArguments; +} + +// ------------------------------------------------------------------------- +map mitkCommandLineParser::parseArguments(int argc, char** argv, bool* ok) +{ + StringContainerType arguments; + + // Create a StringContainerType of arguments + for(int i = 0; i < argc; ++i) + arguments.push_back(argv[i]); + + return this->parseArguments(arguments, ok); +} + +// ------------------------------------------------------------------------- +string mitkCommandLineParser::errorString() const +{ + return this->Internal->ErrorString; +} + +// ------------------------------------------------------------------------- +const mitkCommandLineParser::StringContainerType& mitkCommandLineParser::unparsedArguments() const +{ + return this->Internal->UnparsedArguments; +} + +// -------------------------------------------------------------------------- +void mitkCommandLineParser::addArgument(const string& longarg, const string& shortarg, + Type type, const string& argLabel, const string& argHelp, + const us::Any &defaultValue, bool optional, bool ignoreRest, + bool deprecated) +{ + if (longarg.empty() && shortarg.empty()) { return; } + + /* Make sure it's not already added */ + bool added = this->Internal->ArgNameToArgumentDescriptionMap.count(longarg); + if (added) { return; } + + added = this->Internal->ArgNameToArgumentDescriptionMap.count(shortarg); + if (added) { return; } + + CommandLineParserArgumentDescription* argDesc = + new CommandLineParserArgumentDescription(longarg, this->Internal->LongPrefix, + shortarg, this->Internal->ShortPrefix, type, + argHelp, argLabel, defaultValue, ignoreRest, deprecated, optional, ParameterGroupName, ParameterGroupDescription); + + int argWidth = 0; + if (!longarg.empty()) + { + this->Internal->ArgNameToArgumentDescriptionMap[longarg] = argDesc; + argWidth += longarg.size() + this->Internal->LongPrefix.size(); + } + if (!shortarg.empty()) + { + this->Internal->ArgNameToArgumentDescriptionMap[shortarg] = argDesc; + argWidth += shortarg.size() + this->Internal->ShortPrefix.size() + 2; + } + argWidth += 5; + + // Set the field width for the arguments + if (argWidth > this->Internal->FieldWidth) + { + this->Internal->FieldWidth = argWidth; + } + + this->Internal->ArgumentDescriptionList.push_back(argDesc); + this->Internal->GroupToArgumentDescriptionListMap[this->Internal->CurrentGroup].push_back(argDesc); +} + +// -------------------------------------------------------------------------- +void mitkCommandLineParser::addDeprecatedArgument( + const string& longarg, const string& shortarg, const string& argLabel, const string& argHelp) +{ + addArgument(longarg, shortarg, StringList, argLabel, argHelp, us::Any(), false, true, false); +} + +// -------------------------------------------------------------------------- +int mitkCommandLineParser::fieldWidth() const +{ + return this->Internal->FieldWidth; +} + +// -------------------------------------------------------------------------- +void mitkCommandLineParser::beginGroup(const string& description) +{ + this->Internal->CurrentGroup = description; +} + +// -------------------------------------------------------------------------- +void mitkCommandLineParser::endGroup() +{ + this->Internal->CurrentGroup.clear(); +} + +// -------------------------------------------------------------------------- +string mitkCommandLineParser::helpText() const +{ + string text; + vector deprecatedArgs; + + // Loop over grouped argument descriptions + map >::iterator it; + for(it = Internal->GroupToArgumentDescriptionListMap.begin(); it != Internal->GroupToArgumentDescriptionListMap.end();++it) + { + if (!(*it).first.empty()) + { + text = text + "\n" + (*it).first + "\n"; + } + + vector::iterator it2; + for(it2 = (*it).second.begin(); it2 != (*it).second.end(); ++it2) + { + CommandLineParserArgumentDescription* argDesc = *it2; + if (argDesc->Deprecated) + { + deprecatedArgs.push_back(argDesc); + } + else + { + text += argDesc->helpText(); + } + } + } + + if (!deprecatedArgs.empty()) + { + text += "\nDeprecated arguments:\n"; + vector::iterator it2; + for(it2 = deprecatedArgs.begin(); it2 != deprecatedArgs.end(); ++it2) + { + CommandLineParserArgumentDescription* argDesc = *it2; + text += argDesc->helpText(); + } + } + + return text; +} + +// -------------------------------------------------------------------------- +bool mitkCommandLineParser::argumentAdded(const string& argument) const +{ + return this->Internal->ArgNameToArgumentDescriptionMap.count(argument); +} + +// -------------------------------------------------------------------------- +bool mitkCommandLineParser::argumentParsed(const string& argument) const +{ + for (unsigned int i=0; iProcessedArguments.size(); i++) + if (argument.compare(Internal->ProcessedArguments.at(i))==0) + return true; + return false; +} + +// -------------------------------------------------------------------------- +void mitkCommandLineParser::setArgumentPrefix(const string& longPrefix, const string& shortPrefix) +{ + this->Internal->LongPrefix = longPrefix; + this->Internal->ShortPrefix = shortPrefix; +} + +// -------------------------------------------------------------------------- +void mitkCommandLineParser::setStrictModeEnabled(bool strictMode) +{ + this->Internal->StrictMode = strictMode; +} + +void mitkCommandLineParser::generateXmlOutput() +{ + std::stringstream xml; + + xml << "" << endl; + xml << "" << Category << "" << endl; + xml << "" << Title <<"" << endl; + xml << "" << Description << "" << endl; + xml << "" << Contributor << "" << endl; + xml << "" << endl; + + std::vector::iterator it; + + std::string lastParameterGroup = ""; + for (it = this->Internal->ArgumentDescriptionList.begin(); it != this->Internal->ArgumentDescriptionList.end(); it++) + { + std::string type; + switch ((*it)->ValueType) + { + case mitkCommandLineParser::String: + type = "string"; + break; + + case mitkCommandLineParser::Bool: + type = "boolean"; + break; + + case mitkCommandLineParser::StringList: + type = "string-vector"; + break; + + case mitkCommandLineParser::Int: + type = "integer"; + break; + + case mitkCommandLineParser::Float: + type = "float"; + break; + + case mitkCommandLineParser::OutputDirectory: + case mitkCommandLineParser::InputDirectory: + type = "directory"; + break; + + case mitkCommandLineParser::InputImage: + type = "image"; + break; + + case mitkCommandLineParser::OutputFile: + case mitkCommandLineParser::InputFile: + type = "file"; + break; + } + + if (lastParameterGroup.compare((*it)->ArgGroup)) + { + if (it != this->Internal->ArgumentDescriptionList.begin()) + { + xml << "" << endl; + xml << "" << endl; + } + xml << "" << endl; + xml << "" << (*it)->ArgGroupDescription << "" << endl; + lastParameterGroup = (*it)->ArgGroup; + } + + // Skip help item, as it's no use in GUI + if ((*it)->ShortArg == "h") + continue; + + xml << "<" << type << ">" << endl; + xml << "" << (*it)->LongArg << "" << endl; + xml << "" << (*it)->ArgHelp << "" << endl; + xml << "" << endl; + if (!(*it)->DefaultValue.Empty()) + xml << "" << (*it)->DefaultValue.ToString() << "" << endl; + + xml << "" << (*it)->LongArg << "" << endl; + xml << "" << (*it)->ShortArg << "" << endl; + + if ((*it)->ValueType == mitkCommandLineParser::InputDirectory || (*it)->ValueType == mitkCommandLineParser::InputFile || (*it)->ValueType == mitkCommandLineParser::InputImage) + { + xml << "input" << endl; + } + else if ((*it)->ValueType == mitkCommandLineParser::OutputDirectory || (*it)->ValueType == mitkCommandLineParser::OutputFile) + { + xml << "output" << endl; + } + xml << "" << endl; + } + + xml << "" << endl; + xml << "" << endl; + + cout << xml.str(); +} + +void mitkCommandLineParser::setTitle(string title) +{ + Title = title; +} +void mitkCommandLineParser::setContributor(string contributor) +{ + Contributor = contributor; +} + +void mitkCommandLineParser::setCategory(string category) +{ + Category = category; +} + +void mitkCommandLineParser::setDescription(string description) +{ + Description = description; +} + +void mitkCommandLineParser::changeParameterGroup(string name, string tooltip) +{ + ParameterGroupName = name; + ParameterGroupDescription = tooltip; +} diff --git a/Modules/CommonCommandLineApps/mitkCommandLineParser.h b/Modules/CommonCommandLineApps/mitkCommandLineParser.h new file mode 100644 index 0000000000..763b43be04 --- /dev/null +++ b/Modules/CommonCommandLineApps/mitkCommandLineParser.h @@ -0,0 +1,475 @@ +/*=================================================================== + +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. + +===================================================================*/ +/*========================================================================= + + Library: CTK + + Copyright (c) Kitware Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +#ifndef __mitkCommandLineParser_h +#define __mitkCommandLineParser_h + +#include +#include + + +/** + * \ingroup Core + * + * The CTK command line parser. + * + * Use this class to add information about the command line arguments + * your program understands and to easily parse them from a given list + * of strings. + * + * This parser provides the following features: + * + *
    + *
  • Add arguments by supplying a long name and/or a short name. + * Arguments are validated using a regular expression. They can have + * a default value and a help string.
  • + *
  • Deprecated arguments.
  • + *
  • Custom regular expressions for argument validation.
  • + *
  • Set different argument name prefixes for native platform look and feel.
  • + *
  • QSettings support. Default values for arguments can be read from + * a QSettings object.
  • + *
  • Create a help text for the command line arguments with support for + * grouping arguments.
  • + *
+ * + * Here is an example how to use this class inside a main function: + * + * \code + * #include + * #include + * #include + * + * int main(int argc, char** argv) + * { + * QCoreApplication app(argc, argv); + * // This is used by QSettings + * QCoreApplication::setOrganizationName("MyOrg"); + * QCoreApplication::setApplicationName("MyApp"); + * + * ctkCommandLineParser parser; + * // Use Unix-style argument names + * parser.setArgumentPrefix("--", "-"); + * // Enable QSettings support + * parser.enableSettings("disable-settings"); + * + * // Add command line argument names + * parser.addArgument("disable-settings", "", us::Any::Bool, "Do not use QSettings"); + * parser.addArgument("help", "h", us::Any::Bool, "Show this help text"); + * parser.addArgument("search-paths", "s", us::Any::StringList, "A list of paths to search"); + * + * // Parse the command line arguments + * bool ok = false; + * map parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok); + * if (!ok) + * { + * QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: " + * << parser.errorString() << "\n"; + * return EXIT_FAILURE; + * } + * + * // Show a help message + * if (parsedArgs.contains("help") || parsedArgs.contains("h")) + * { + * QTextStream(stdout, QIODevice::WriteOnly) << parser.helpText(); + * return EXIT_SUCCESS; + * } + * + * // Do something + * + * return EXIT_SUCCESS; + * } + * \endcode + */ + +using namespace std; + +class mitkCommandLineParser +{ + +public: + + enum Type { + String = 0, + Bool = 1, + StringList = 2, + Int = 3, + Float = 4, + InputDirectory = 5, + InputFile = 6, + OutputDirectory = 7, + OutputFile = 8, + InputImage = 9 + }; + + typedef std::vector< std::string > StringContainerType; + + /** + * Constructs a parser instance. + * + * If QSettings support is enabled by a call to enableSettings() + * a default constructed QSettings instance will be used when parsing + * the command line arguments. Make sure to call QCoreApplication::setOrganizationName() + * and QCoreApplication::setApplicationName() before using default + * constructed QSettings objects. + * + * @param newParent The QObject parent. + */ + mitkCommandLineParser(); + + ~mitkCommandLineParser(); + + /** + * Parse a given list of command line arguments. + * + * This method parses a list of string elements considering the known arguments + * added by calls to addArgument(). If any one of the argument + * values does not match the corresponding regular expression, + * ok is set to false and an empty map object is returned. + * + * The keys in the returned map object correspond to the long argument string, + * if it is not empty. Otherwise, the short argument string is used as key. The + * us::Any values can safely be converted to the type specified in the + * addArgument() method call. + * + * @param arguments A StringContainerType containing command line arguments. Usually + * given by QCoreApplication::arguments(). + * @param ok A pointer to a boolean variable. Will be set to true + * if all regular expressions matched, false otherwise. + * @return A map object mapping the long argument (if empty, the short one) + * to a us::Any containing the value. + */ + + map parseArguments(const StringContainerType &arguments, bool* ok = 0); + + /** + * Convenient method allowing to parse a given list of command line arguments. + * @see parseArguments(const StringContainerType &, bool*) + */ + map parseArguments(int argc, char** argv, bool* ok = 0); + + /** + * Returns a detailed error description if a call to parseArguments() + * failed. + * + * @return The error description, empty if no error occured. + * @see parseArguments(const StringContainerType&, bool*) + */ + string errorString() const; + + /** + * This method returns all unparsed arguments, i.e. all arguments + * for which no long or short name has been registered via a call + * to addArgument(). + * + * @see addArgument() + * + * @return A list containing unparsed arguments. + */ + const StringContainerType& unparsedArguments() const; + + /** + * Checks if the given argument has been added via a call + * to addArgument(). + * + * @see addArgument() + * + * @param argument The argument to be checked. + * @return true if the argument was added, false + * otherwise. + */ + bool argumentAdded(const string& argument) const; + + /** + * Checks if the given argument has been parsed successfully by a previous + * call to parseArguments(). + * + * @param argument The argument to be checked. + * @return true if the argument was parsed, false + * otherwise. + */ + bool argumentParsed(const string& argument) const; + + /** + * Adds a command line argument. An argument can have a long name + * (like --long-argument-name), a short name (like -l), or both. The type + * of the argument can be specified by using the type parameter. + * The following types are supported: + * + * + * + * + * + * + * + * + *
Type# of parametersDefault regular exprExample
us::Any::String1.*--test-string StringParameter
us::Any::Bool0does not apply--enable-something
us::Any::StringList-1.*--test-list string1 string2
us::Any::Int1-?[0-9]+--test-int -5
+ * + * The regular expressions are used to validate the parameters of command line + * arguments. You can restrict the valid set of parameters by calling + * setExactMatchRegularExpression() for your argument. + * + * Optionally, a help string and a default value can be provided for the argument. If + * the us::Any type of the default value does not match type, an + * exception is thrown. Arguments with default values are always returned by + * parseArguments(). + * + * You can also declare an argument deprecated, by setting deprecated + * to true. Alternatively you can add a deprecated argument by calling + * addDeprecatedArgument(). + * + * If the long or short argument has already been added, or if both are empty strings, + * the method call has no effect. + * + * @param longarg The long argument name. + * @param shortarg The short argument name. + * @param type The argument type (see the list above for supported types). + * @param argLabel The label of this argument, when auto generated interface is used. + * @param argHelp A help string describing the argument. + * @param defaultValue A default value for the argument. + * @param ignoreRest All arguments after the current one will be ignored. + * @param deprecated Declares the argument deprecated. + * + * @see setExactMatchRegularExpression() + * @see addDeprecatedArgument() + * @throws std::logic_error If the us::Any type of defaultValue + * does not match type, a std::logic_error is thrown. + */ + void addArgument(const string& longarg, const string& shortarg, + Type type, const string& argLabel, const string& argHelp = string(), + const us::Any& defaultValue = us::Any(), bool optional=true, + bool ignoreRest = false, bool deprecated = false); + + /** + * Adds a deprecated command line argument. If a deprecated argument is provided + * on the command line, argHelp is displayed in the console and + * processing continues with the next argument. + * + * Deprecated arguments are grouped separately at the end of the help text + * returned by helpText(). + * + * @param longarg The long argument name. + * @param shortarg The short argument name. + * @param argHelp A help string describing alternatives to the deprecated argument. + */ + void addDeprecatedArgument(const string& longarg, const string& shortarg, const string& argLabel, + const string& argHelp); + + /** + * Sets a custom regular expression for validating argument parameters. The method + * errorString() can be used the get the last error description. + * + * @param argument The previously added long or short argument name. + * @param expression A regular expression which the arugment parameters must match. + * @param exactMatchFailedMessage An error message explaining why the parameter did + * not match. + * + * @return true if the argument was found and the regular expression was set, + * false otherwise. + * + * @see errorString() + */ + bool setExactMatchRegularExpression(const string& argument, const string& expression, + const string& exactMatchFailedMessage); + + /** + * The field width for the argument names without the help text. + * + * @return The argument names field width in the help text. + */ + int fieldWidth() const; + + /** + * Creates a help text containing properly formatted argument names and help strings + * provided by calls to addArgument(). The arguments can be grouped by + * using beginGroup() and endGroup(). + * + * @param charPad The padding character. + * @return The formatted help text. + */ + string helpText() const; + + /** + * Sets the argument prefix for long and short argument names. This can be used + * to create native command line arguments without changing the calls to + * addArgument(). For example on Unix-based systems, long argument + * names start with "--" and short names with "-", while on Windows argument names + * always start with "/". + * + * Note that all methods in ctkCommandLineParser which take an argument name + * expect the name as it was supplied to addArgument. + * + * Example usage: + * + * \code + * ctkCommandLineParser parser; + * parser.setArgumentPrefix("--", "-"); + * parser.addArgument("long-argument", "l", us::Any::String); + * StringContainerType args; + * args << "program name" << "--long-argument Hi"; + * parser.parseArguments(args); + * \endcode + * + * @param longPrefix The prefix for long argument names. + * @param shortPrefix The prefix for short argument names. + */ + void setArgumentPrefix(const string& longPrefix, const string& shortPrefix); + + /** + * Begins a new group for documenting arguments. All newly added arguments via + * addArgument() will be put in the new group. You can close the + * current group by calling endGroup() or be opening a new group. + * + * Note that groups cannot be nested and all arguments which do not belong to + * a group will be listed at the top of the text created by helpText(). + * + * @param description The description of the group + */ + void beginGroup(const string& description); + + /** + * Ends the current group. + * + * @see beginGroup(const string&) + */ + void endGroup(); + + /** + * Enables QSettings support in ctkCommandLineParser. If an argument name is found + * in the QSettings instance with a valid us::Any, the value is considered as + * a default value and overwrites default values registered with + * addArgument(). User supplied values on the command line overwrite + * values in the QSettings instance, except for arguments with multiple parameters + * which are merged with QSettings values. Call mergeSettings(false) + * to disable merging. + * + * See ctkCommandLineParser(QSettings*) for information about how to + * supply a QSettings instance. + * + * Additionally, a long and short argument name can be specified which will disable + * QSettings support if supplied on the command line. The argument name must be + * registered as a regular argument via addArgument(). + * + * @param disableLongArg Long argument name. + * @param disableShortArg Short argument name. + * + * @see ctkCommandLineParser(QSettings*) + */ + void enableSettings(const string& disableLongArg = "", + const string& disableShortArg = ""); + + /** + * Controlls the merging behavior of user values and QSettings values. + * + * If merging is on (the default), user supplied values for an argument + * which can take more than one parameter are merged with values stored + * in the QSettings instance. If merging is off, the user values overwrite + * the QSettings values. + * + * @param merge true enables QSettings merging, false + * disables it. + */ + void mergeSettings(bool merge); + + /** + * Can be used to check if QSettings support has been enabled by a call to + * enableSettings(). + * + * @return true if QSettings support is enabled, false + * otherwise. + */ + bool settingsEnabled() const; + + + /** + * Can be used to teach the parser to stop parsing the arguments and return False when + * an unknown argument is encountered. By default StrictMode is disabled. + * + * @see parseArguments(const StringContainerType &, bool*) + */ + void setStrictModeEnabled(bool strictMode); + + /** + * Is used to generate an XML output for any commandline program. + */ + void generateXmlOutput(); + + /** + * Is used to set the title of the auto generated interface. + * + * @param title The title of the app. + */ + void setTitle(std::string title); + /** + * Is used to set the contributor for the help view in the auto generated interface. + * + * @param contributor Contributor of the app. + */ + void setContributor(std::string contributor); + /** + * Is used to categorize the apps in the commandline module. + * + * @param category The category of the app. + */ + void setCategory(std::string category); + /** + * Is used as the help text in the auto generated interface. + * + * @param description A short description for the app. + */ + void setDescription(std::string description); + /** + * Is used to group several Parameters in one groupbox in the auto generated interface. + * Default name is "Parameters", with the tooltip: "Groupbox containing parameters." + * + * To change the group of several arguments, call this method before the arguments are added. + * + * @param name The name of the groupbox. + * @param tooltip The tooltip of the groupbox. + */ + void changeParameterGroup(std::string name, std::string tooltip); + +private: + class ctkInternal; + ctkInternal * Internal; + + string Title; + string Contributor; + string Category; + string Description; + string ParameterGroupName; + string ParameterGroupDescription; +}; + +#endif diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index 73d7eeed9c..dd27a58c23 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,78 +1,79 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(mitk_modules Core CommandLine + CommonCommandLineApps AppUtil DCMTesting RDF LegacyIO DataTypesExt Overlays LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction ImageStatistics LegacyAdaptors SceneSerialization Gizmo GraphAlgorithms Multilabel ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QtWidgets QtWidgetsExt QmlItems SegmentationUI DiffusionImaging GPGPU OpenIGTLink IGTBase IGT CameraCalibration RigidRegistration RigidRegistrationUI DeformableRegistration DeformableRegistrationUI OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI US USUI DicomUI Simulation Python QtPython Persistence OpenIGTLinkUI IGTUI VtkShaders DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware Classification TumorInvasionAnalysis Remeshing Radiomics ) if(MITK_ENABLE_PIC_READER) list(APPEND mitk_modules IpPicSupportIO) endif()