diff --git a/CMake/NSIS.template.in b/CMake/NSIS.template.in
index f111eadbc1..47f5d675ff 100644
--- a/CMake/NSIS.template.in
+++ b/CMake/NSIS.template.in
@@ -1,1086 +1,1014 @@
 ; CPack install script designed for a nmake build
 
 ;--------------------------------
 ; You must define these values
 
   !define VERSION "@CPACK_PACKAGE_VERSION@"
   !define PATCH  "@CPACK_PACKAGE_VERSION_PATCH@"
   !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
 
 ;--------------------------------
 ;Variables
 
   Var MUI_TEMP
   Var STARTMENU_FOLDER
   Var SV_ALLUSERS
   Var START_MENU
   Var DO_NOT_ADD_TO_PATH
   Var ADD_TO_PATH_ALL_USERS
   Var ADD_TO_PATH_CURRENT_USER
   Var INSTALL_DESKTOP
   Var IS_DEFAULT_INSTALLDIR
 ;--------------------------------
 ;Include Modern UI
 
   !include "MUI.nsh"
 
   ;Default installation folder
   InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
 
   ;Allow for very long title on the welcome page
   !define MUI_WELCOMEPAGE_TITLE_3LINES
 
 ;--------------------------------
 ;General
 
   ;Name and file
   Name "@CPACK_NSIS_PACKAGE_NAME@"
   OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
 
   ;Set compression
   SetCompressor @CPACK_NSIS_COMPRESSOR@
 
   RequestExecutionLevel user
 
 @CPACK_NSIS_DEFINES@
 
   !include Sections.nsh
 
 ;--- Component support macros: ---
 ; The code for the add/remove functionality is from:
 ;   http://nsis.sourceforge.net/Add/Remove_Functionality
 ; It has been modified slightly and extended to provide
 ; inter-component dependencies.
 Var AR_SecFlags
 Var AR_RegFlags
 @CPACK_NSIS_SECTION_SELECTED_VARS@
 
 ; Loads the "selected" flag for the section named SecName into the
 ; variable VarName.
 !macro LoadSectionSelectedIntoVar SecName VarName
  SectionGetFlags ${${SecName}} $${VarName}
  IntOp $${VarName} $${VarName} & ${SF_SELECTED}  ;Turn off all other bits
 !macroend
 
 ; Loads the value of a variable... can we get around this?
 !macro LoadVar VarName
   IntOp $R0 0 + $${VarName}
 !macroend
 
 ; Sets the value of a variable
 !macro StoreVar VarName IntValue
   IntOp $${VarName} 0 + ${IntValue}
 !macroend
 
 !macro InitSection SecName
   ;  This macro reads component installed flag from the registry and
   ;changes checked state of the section on the components page.
   ;Input: section index constant name specified in Section command.
 
   ClearErrors
   ;Reading component status from registry
   ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" "Installed"
   IfErrors "default_${SecName}"
     ;Status will stay default if registry value not found
     ;(component was never installed)
   IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
   SectionGetFlags ${${SecName}} $AR_SecFlags  ;Reading default section flags
   IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE  ;Turn lowest (enabled) bit off
   IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags      ;Change lowest bit
 
   ; Note whether this component was installed before
   !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
   IntOp $R0 $AR_RegFlags & $AR_RegFlags
 
   ;Writing modified flags
   SectionSetFlags ${${SecName}} $AR_SecFlags
 
  "default_${SecName}:"
  !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
 !macroend
 
 !macro FinishSection SecName
   ;  This macro reads section flag set by user and removes the section
   ;if it is not selected.
   ;Then it writes component installed flag to registry
   ;Input: section index constant name specified in Section command.
 
   SectionGetFlags ${${SecName}} $AR_SecFlags  ;Reading section flags
   ;Checking lowest bit:
   IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
   IntCmp $AR_SecFlags 1 "leave_${SecName}"
     ;Section is not selected:
     ;Calling Section uninstall macro and writing zero installed flag
     !insertmacro "Remove_${${SecName}}"
     WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" \
   "Installed" 0
     Goto "exit_${SecName}"
 
  "leave_${SecName}:"
     ;Section is selected:
     WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" \
   "Installed" 1
 
  "exit_${SecName}:"
 !macroend
 
 ; NSIS example code to only include some code if a file exists at compile time (whereas IfFileExists works at runtime)
 ; See http://nsis.sourceforge.net/Check_if_a_file_exists_at_compile_time for documentation
 !macro !defineifexist _VAR_NAME _FILE_NAME
   !tempfile _TEMPFILE
   !system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
   !include '${_TEMPFILE}'
   !delfile '${_TEMPFILE}'
   !undef _TEMPFILE
 !macroend
 !define !defineifexist "!insertmacro !defineifexist"
 
 ; Determine whether the selection of SecName changed
 !macro MaybeSelectionChanged SecName
   !insertmacro LoadVar ${SecName}_selected
   SectionGetFlags ${${SecName}} $R1
   IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
 
   ; See if the status has changed:
   IntCmp $R0 $R1 "${SecName}_unchanged"
   !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
 
   IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
   !insertmacro "Deselect_required_by_${SecName}"
   goto "${SecName}_unchanged"
 
   "${SecName}_was_selected:"
   !insertmacro "Select_${SecName}_depends"
 
   "${SecName}_unchanged:"
 !macroend
 ;--- End of Add/Remove macros ---
 
 ;--------------------------------
 ;Interface Settings
 
   !define MUI_HEADERIMAGE
   !define MUI_ABORTWARNING
 
 ;--------------------------------
 ; path functions
 
 !verbose 3
 !include "WinMessages.NSH"
 !verbose 4
 
 ;----------------------------------------
 ; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
 ;----------------------------------------
 !verbose 3
 !include "WinMessages.NSH"
 !verbose 4
 ;====================================================
 ; get_NT_environment
 ;     Returns: the selected environment
 ;     Output : head of the stack
 ;====================================================
 !macro select_NT_profile UN
 Function ${UN}select_NT_profile
    StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
       DetailPrint "Selected environment for all users"
       Push "all"
       Return
    environment_single:
       DetailPrint "Selected environment for current user only."
       Push "current"
       Return
 FunctionEnd
 !macroend
 !insertmacro select_NT_profile ""
 !insertmacro select_NT_profile "un."
 ;----------------------------------------------------
 !define NT_current_env 'HKCU "Environment"'
 !define NT_all_env     'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
 
 !ifndef WriteEnvStr_RegKey
   !ifdef ALL_USERS
     !define WriteEnvStr_RegKey \
        'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
   !else
     !define WriteEnvStr_RegKey 'HKCU "Environment"'
   !endif
 !endif
 
 ; AddToPath - Adds the given dir to the search path.
 ;        Input - head of the stack
 ;        Note - Win9x systems requires reboot
 
 Function AddToPath
   Exch $0
   Push $1
   Push $2
   Push $3
 
   # don't add if the path doesn't exist
   IfFileExists "$0\*.*" "" AddToPath_done
 
   ReadEnvStr $1 PATH
   ; if the path is too long for a NSIS variable NSIS will return a 0
   ; length string.  If we find that, then warn and skip any path
   ; modification as it will trash the existing path.
   StrLen $2 $1
   IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
     CheckPathLength_ShowPathWarning:
     DetailPrint "Warning: Could not modify PATH variable - current PATH is too long.\n\
 This does not impact the functionality of MITK itself, but you will not be able to start\
 it from anywhere via command line."
     ; The message box is probably too much of an escalation, most users won't care or notice
     ;Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!"
     Goto AddToPath_done
   CheckPathLength_Done:
   Push "$1;"
   Push "$0;"
   Call StrStr
   Pop $2
   StrCmp $2 "" "" AddToPath_done
   Push "$1;"
   Push "$0\;"
   Call StrStr
   Pop $2
   StrCmp $2 "" "" AddToPath_done
   GetFullPathName /SHORT $3 $0
   Push "$1;"
   Push "$3;"
   Call StrStr
   Pop $2
   StrCmp $2 "" "" AddToPath_done
   Push "$1;"
   Push "$3\;"
   Call StrStr
   Pop $2
   StrCmp $2 "" "" AddToPath_done
 
   Call IsNT
   Pop $1
   StrCmp $1 1 AddToPath_NT
     ; Not on NT
     StrCpy $1 $WINDIR 2
     FileOpen $1 "$1\autoexec.bat" a
     FileSeek $1 -1 END
     FileReadByte $1 $2
     IntCmp $2 26 0 +2 +2 # DOS EOF
       FileSeek $1 -1 END # write over EOF
     FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
     FileClose $1
     SetRebootFlag true
     Goto AddToPath_done
 
   AddToPath_NT:
     StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
       ReadRegStr $1 ${NT_current_env} "PATH"
       Goto DoTrim
     ReadAllKey:
       ReadRegStr $1 ${NT_all_env} "PATH"
     DoTrim:
     StrCmp $1 "" AddToPath_NTdoIt
       Push $1
       Call Trim
       Pop $1
       StrCpy $0 "$1;$0"
     AddToPath_NTdoIt:
       StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
         WriteRegExpandStr ${NT_current_env} "PATH" $0
         Goto DoSend
       WriteAllKey:
         WriteRegExpandStr ${NT_all_env} "PATH" $0
       DoSend:
       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
 
   AddToPath_done:
     Pop $3
     Pop $2
     Pop $1
     Pop $0
 FunctionEnd
 
 
 ; RemoveFromPath - Remove a given dir from the path
 ;     Input: head of the stack
 
 Function un.RemoveFromPath
   Exch $0
   Push $1
   Push $2
   Push $3
   Push $4
   Push $5
   Push $6
 
   IntFmt $6 "%c" 26 # DOS EOF
 
   Call un.IsNT
   Pop $1
   StrCmp $1 1 unRemoveFromPath_NT
     ; Not on NT
     StrCpy $1 $WINDIR 2
     FileOpen $1 "$1\autoexec.bat" r
     GetTempFileName $4
     FileOpen $2 $4 w
     GetFullPathName /SHORT $0 $0
     StrCpy $0 "SET PATH=%PATH%;$0"
     Goto unRemoveFromPath_dosLoop
 
     unRemoveFromPath_dosLoop:
       FileRead $1 $3
       StrCpy $5 $3 1 -1 # read last char
       StrCmp $5 $6 0 +2 # if DOS EOF
         StrCpy $3 $3 -1 # remove DOS EOF so we can compare
       StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
       StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
       StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
       StrCmp $3 "" unRemoveFromPath_dosLoopEnd
       FileWrite $2 $3
       Goto unRemoveFromPath_dosLoop
       unRemoveFromPath_dosLoopRemoveLine:
         SetRebootFlag true
         Goto unRemoveFromPath_dosLoop
 
     unRemoveFromPath_dosLoopEnd:
       FileClose $2
       FileClose $1
       StrCpy $1 $WINDIR 2
       Delete "$1\autoexec.bat"
       CopyFiles /SILENT $4 "$1\autoexec.bat"
       Delete $4
       Goto unRemoveFromPath_done
 
   unRemoveFromPath_NT:
     StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
       ReadRegStr $1 ${NT_current_env} "PATH"
       Goto unDoTrim
     unReadAllKey:
       ReadRegStr $1 ${NT_all_env} "PATH"
     unDoTrim:
     StrCpy $5 $1 1 -1 # copy last char
     StrCmp $5 ";" +2 # if last char != ;
       StrCpy $1 "$1;" # append ;
     Push $1
     Push "$0;"
     Call un.StrStr ; Find `$0;` in $1
     Pop $2 ; pos of our dir
     StrCmp $2 "" unRemoveFromPath_done
       ; else, it is in path
       # $0 - path to add
       # $1 - path var
       StrLen $3 "$0;"
       StrLen $4 $2
       StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
       StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
       StrCpy $3 $5$6
 
       StrCpy $5 $3 1 -1 # copy last char
       StrCmp $5 ";" 0 +2 # if last char == ;
         StrCpy $3 $3 -1 # remove last char
 
       StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
         WriteRegExpandStr ${NT_current_env} "PATH" $3
         Goto unDoSend
       unWriteAllKey:
         WriteRegExpandStr ${NT_all_env} "PATH" $3
       unDoSend:
       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
 
   unRemoveFromPath_done:
     Pop $6
     Pop $5
     Pop $4
     Pop $3
     Pop $2
     Pop $1
     Pop $0
 FunctionEnd
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Uninstall stuff
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ###########################################
 #            Utility Functions            #
 ###########################################
 
 ;====================================================
 ; IsNT - Returns 1 if the current system is NT, 0
 ;        otherwise.
 ;     Output: head of the stack
 ;====================================================
 ; IsNT
 ; no input
 ; output, top of the stack = 1 if NT or 0 if not
 ;
 ; Usage:
 ;   Call IsNT
 ;   Pop $R0
 ;  ($R0 at this point is 1 or 0)
 
 !macro IsNT un
 Function ${un}IsNT
   Push $0
   ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
   StrCmp $0 "" 0 IsNT_yes
   ; we are not NT.
   Pop $0
   Push 0
   Return
 
   IsNT_yes:
     ; NT!!!
     Pop $0
     Push 1
 FunctionEnd
 !macroend
 !insertmacro IsNT ""
 !insertmacro IsNT "un."
 
 ; StrStr
 ; input, top of stack = string to search for
 ;        top of stack-1 = string to search in
 ; output, top of stack (replaces with the portion of the string remaining)
 ; modifies no other variables.
 ;
 ; Usage:
 ;   Push "this is a long ass string"
 ;   Push "ass"
 ;   Call StrStr
 ;   Pop $R0
 ;  ($R0 at this point is "ass string")
 
 !macro StrStr un
 Function ${un}StrStr
 Exch $R1 ; st=haystack,old$R1, $R1=needle
   Exch    ; st=old$R1,haystack
   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
   Push $R3
   Push $R4
   Push $R5
   StrLen $R3 $R1
   StrCpy $R4 0
   ; $R1=needle
   ; $R2=haystack
   ; $R3=len(needle)
   ; $R4=cnt
   ; $R5=tmp
   loop:
     StrCpy $R5 $R2 $R3 $R4
     StrCmp $R5 $R1 done
     StrCmp $R5 "" done
     IntOp $R4 $R4 + 1
     Goto loop
 done:
   StrCpy $R1 $R2 "" $R4
   Pop $R5
   Pop $R4
   Pop $R3
   Pop $R2
   Exch $R1
 FunctionEnd
 !macroend
 !insertmacro StrStr ""
 !insertmacro StrStr "un."
 
 Function Trim ; Added by Pelaca
   Exch $R1
   Push $R2
 Loop:
   StrCpy $R2 "$R1" 1 -1
   StrCmp "$R2" " " RTrim
   StrCmp "$R2" "$\n" RTrim
   StrCmp "$R2" "$\r" RTrim
   StrCmp "$R2" ";" RTrim
   GoTo Done
 RTrim:
   StrCpy $R1 "$R1" -1
   Goto Loop
 Done:
   Pop $R2
   Exch $R1
 FunctionEnd
 
 Function ConditionalAddToRegisty
   Pop $0
   Pop $1
   StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
     WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" \
     "$1" "$0"
     ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
     DetailPrint "Set install registry entry: '$1' to '$0'"
   ConditionalAddToRegisty_EmptyString:
 FunctionEnd
 
 ;--------------------------------
 
 !ifdef CPACK_USES_DOWNLOAD
 Function DownloadFile
     IfFileExists $INSTDIR\* +2
     CreateDirectory $INSTDIR
     Pop $0
 
     ; Skip if already downloaded
     IfFileExists $INSTDIR\$0 0 +2
     Return
 
     StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
 
   try_again:
     NSISdl::download "$1/$0" "$INSTDIR\$0"
 
     Pop $1
     StrCmp $1 "success" success
     StrCmp $1 "Cancelled" cancel
     MessageBox MB_OK "Download failed: $1"
   cancel:
     Return
   success:
 FunctionEnd
 !endif
 
 ;--------------------------------
 ; Installation types
 @CPACK_NSIS_INSTALLATION_TYPES@
 
 ;--------------------------------
 ; Component sections
 @CPACK_NSIS_COMPONENT_SECTIONS@
 
 ;--------------------------------
 ; Define some macro setting for the gui
 @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
 @CPACK_NSIS_INSTALLER_ICON_CODE@
 @CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
 @CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
 
 ;--------------------------------
 ;Pages
   !insertmacro MUI_PAGE_WELCOME
 
   !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
   Page custom InstallOptionsPage
   !insertmacro MUI_PAGE_DIRECTORY
 
   ;Start Menu Folder Page Configuration
   !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
   !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
   !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
   !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
 
   @CPACK_NSIS_PAGE_COMPONENTS@
 
   !insertmacro MUI_PAGE_INSTFILES
   !insertmacro MUI_PAGE_FINISH
 
   !insertmacro MUI_UNPAGE_CONFIRM
   !insertmacro MUI_UNPAGE_INSTFILES
 
 ;--------------------------------
 ;Languages
 
   !insertmacro MUI_LANGUAGE "English" ;first language is the default language
   !insertmacro MUI_LANGUAGE "Albanian"
   !insertmacro MUI_LANGUAGE "Arabic"
   !insertmacro MUI_LANGUAGE "Basque"
   !insertmacro MUI_LANGUAGE "Belarusian"
   !insertmacro MUI_LANGUAGE "Bosnian"
   !insertmacro MUI_LANGUAGE "Breton"
   !insertmacro MUI_LANGUAGE "Bulgarian"
   !insertmacro MUI_LANGUAGE "Croatian"
   !insertmacro MUI_LANGUAGE "Czech"
   !insertmacro MUI_LANGUAGE "Danish"
   !insertmacro MUI_LANGUAGE "Dutch"
   !insertmacro MUI_LANGUAGE "Estonian"
   !insertmacro MUI_LANGUAGE "Farsi"
   !insertmacro MUI_LANGUAGE "Finnish"
   !insertmacro MUI_LANGUAGE "French"
   !insertmacro MUI_LANGUAGE "German"
   !insertmacro MUI_LANGUAGE "Greek"
   !insertmacro MUI_LANGUAGE "Hebrew"
   !insertmacro MUI_LANGUAGE "Hungarian"
   !insertmacro MUI_LANGUAGE "Icelandic"
   !insertmacro MUI_LANGUAGE "Indonesian"
   !insertmacro MUI_LANGUAGE "Irish"
   !insertmacro MUI_LANGUAGE "Italian"
   !insertmacro MUI_LANGUAGE "Japanese"
   !insertmacro MUI_LANGUAGE "Korean"
   !insertmacro MUI_LANGUAGE "Kurdish"
   !insertmacro MUI_LANGUAGE "Latvian"
   !insertmacro MUI_LANGUAGE "Lithuanian"
   !insertmacro MUI_LANGUAGE "Luxembourgish"
   !insertmacro MUI_LANGUAGE "Macedonian"
   !insertmacro MUI_LANGUAGE "Malay"
   !insertmacro MUI_LANGUAGE "Mongolian"
   !insertmacro MUI_LANGUAGE "Norwegian"
   !insertmacro MUI_LANGUAGE "Polish"
   !insertmacro MUI_LANGUAGE "Portuguese"
   !insertmacro MUI_LANGUAGE "PortugueseBR"
   !insertmacro MUI_LANGUAGE "Romanian"
   !insertmacro MUI_LANGUAGE "Russian"
   !insertmacro MUI_LANGUAGE "Serbian"
   !insertmacro MUI_LANGUAGE "SerbianLatin"
   !insertmacro MUI_LANGUAGE "SimpChinese"
   !insertmacro MUI_LANGUAGE "Slovak"
   !insertmacro MUI_LANGUAGE "Slovenian"
   !insertmacro MUI_LANGUAGE "Spanish"
   !insertmacro MUI_LANGUAGE "Swedish"
   !insertmacro MUI_LANGUAGE "Thai"
   !insertmacro MUI_LANGUAGE "TradChinese"
   !insertmacro MUI_LANGUAGE "Turkish"
   !insertmacro MUI_LANGUAGE "Ukrainian"
   !insertmacro MUI_LANGUAGE "Welsh"
 
 
 ;--------------------------------
 ;Reserve Files
 
   ;These files should be inserted before other files in the data block
   ;Keep these lines before any File command
   ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
 
   ReserveFile "NSIS.InstallOptions.ini"
   !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
 
 ;--------------------------------
 ;Installer Sections
 
 Section "-Core installation"
   ;Use the entire tree produced by the INSTALL target.  Keep the
   ;list of directories here in sync with the RMDir commands below.
   SetOutPath "$INSTDIR"
   @CPACK_NSIS_FULL_INSTALL@
 
-  ; Check whether redistributables need to be installed
-  Call RedistributablePage
-
   ;Store installation folder
   WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
 
   ;Create uninstaller
   WriteUninstaller "$INSTDIR\Uninstall.exe"
   Push "DisplayName"
   Push "@CPACK_NSIS_DISPLAY_NAME@"
   Call ConditionalAddToRegisty
   Push "DisplayVersion"
   Push "@CPACK_PACKAGE_VERSION@"
   Call ConditionalAddToRegisty
   Push "Publisher"
   Push "@CPACK_PACKAGE_VENDOR@"
   Call ConditionalAddToRegisty
   Push "UninstallString"
   Push "$INSTDIR\Uninstall.exe"
   Call ConditionalAddToRegisty
   Push "NoRepair"
   Push "1"
   Call ConditionalAddToRegisty
 
   !ifdef CPACK_NSIS_ADD_REMOVE
   ;Create add/remove functionality
   Push "ModifyPath"
   Push "$INSTDIR\AddRemove.exe"
   Call ConditionalAddToRegisty
   !else
   Push "NoModify"
   Push "1"
   Call ConditionalAddToRegisty
   !endif
 
   ; Optional registration
   Push "DisplayIcon"
   Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
   Call ConditionalAddToRegisty
   Push "HelpLink"
   Push "@CPACK_NSIS_HELP_LINK@"
   Call ConditionalAddToRegisty
   Push "URLInfoAbout"
   Push "@CPACK_NSIS_URL_INFO_ABOUT@"
   Call ConditionalAddToRegisty
   Push "Contact"
   Push "@CPACK_NSIS_CONTACT@"
   Call ConditionalAddToRegisty
   !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
 
   ;Create shortcuts
   CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
 @CPACK_NSIS_CREATE_ICONS@
 @CPACK_NSIS_CREATE_ICONS_EXTRA@
   CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
 
   ;Read a value from an InstallOptions INI file
   !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
   !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
   !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
 
   ; Write special uninstall registry entries
   Push "StartMenu"
   Push "$STARTMENU_FOLDER"
   Call ConditionalAddToRegisty
   Push "DoNotAddToPath"
   Push "$DO_NOT_ADD_TO_PATH"
   Call ConditionalAddToRegisty
   Push "AddToPathAllUsers"
   Push "$ADD_TO_PATH_ALL_USERS"
   Call ConditionalAddToRegisty
   Push "AddToPathCurrentUser"
   Push "$ADD_TO_PATH_CURRENT_USER"
   Call ConditionalAddToRegisty
   Push "InstallToDesktop"
   Push "$INSTALL_DESKTOP"
   Call ConditionalAddToRegisty
 
   !insertmacro MUI_STARTMENU_WRITE_END
 
 @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
 
 SectionEnd
 
 Section "-Add to path"
   Push $INSTDIR\bin
   StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
   StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
     Call AddToPath
   doNotAddToPath:
 SectionEnd
 
 ;--------------------------------
 ; Create custom pages
 Function InstallOptionsPage
   !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
 
 FunctionEnd
 
 ; Author: Lilla (lilla@earthlink.net) 2003-06-13
 ; function IsUserAdmin uses plugin \NSIS\PlusgIns\UserInfo.dll
 ; This function is based upon code in \NSIS\Contrib\UserInfo\UserInfo.nsi
 ; This function was tested under NSIS 2 beta 4 (latest CVS as of this writing).
 ;
 ; Usage:
 ;   Call IsUserAdmin
 ;   Pop $R0   ; at this point $R0 is "true" or "false"
 ;
 Function IsUserAdmin
 Push $R0
 Push $R1
 Push $R2
 
 ClearErrors
 UserInfo::GetName
 IfErrors Win9x
 Pop $R1
 UserInfo::GetAccountType
 Pop $R2
 
 StrCmp $R2 "Admin" 0 Continue
 ; Observation: I get here when running Win98SE. (Lilla)
 ; The functions UserInfo.dll looks for are there on Win98 too,
 ; but just don't work. So UserInfo.dll, knowing that admin isn't required
 ; on Win98, returns admin anyway. (per kichik)
 ; MessageBox MB_OK 'User "$R1" is in the Administrators group'
 StrCpy $R0 "true"
 Goto Done
 
 Continue:
 ; You should still check for an empty string because the functions
 ; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
 StrCmp $R2 "" Win9x
 StrCpy $R0 "false"
 ;MessageBox MB_OK 'User "$R1" is in the "$R2" group'
 Goto Done
 
 Win9x:
 ; comment/message below is by UserInfo.nsi author:
 ; This one means you don't need to care about admin or
 ; not admin because Windows 9x doesn't either
 ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
 StrCpy $R0 "true"
 
 Done:
 ;MessageBox MB_OK 'User= "$R1"  AccountType= "$R2"  IsUserAdmin= "$R0"'
 
 Pop $R2
 Pop $R1
 Exch $R0
 FunctionEnd
 
-Function RedistributablePage
-  ; Check whether the appropriate redistributable for this installer has been installed
-  StrCmp '@CPACK_LIBRARY_ARCHITECTURE@' 'x64' 0 +3
-    SetRegView 64
-    Goto done
-  StrCmp '@CPACK_LIBRARY_ARCHITECTURE@' 'x86' 0 +3
-    SetRegView 32
-    Goto done
-  ; The following line should not be reached, use for debugging
-  ; MessageBox MB_OK "Could not determine x86/x64 architecture during CPack installer configuration."
-  done:
-  ReadRegDword $1 HKLM "SOFTWARE\Microsoft\DevDiv\vc\Servicing\@CPACK_VISUAL_STUDIO_VERSION_MAJOR@.0\RuntimeMinimum" "Install"
-
-  ; If installed show installed, else offer installation
-  StrCmp $1 1 RedistInstalled
-
-  ; Offer Installation
-  ; MessageBox MB_YESNO "MITK requires the @CPACK_VISUAL_STUDIO_PRODUCT_NAME@ Redistributable to function. Do you wish to install it?" /SD IDYES IDNO endInstallationMissingRedist
-
-  ; Verify that user has admin privileges
-  ; Otherwise they are not able to install the redistributable
-  Call IsUserAdmin
-  Exch $R0
-  StrCmp $R0 "false" NoAdminRights
-  Pop $R0
-
-  SetOutPath $INSTDIR\thirdpartyinstallers
-
-  ; We need compile time information on whether the redistributable installer exists.
-  ; If it does not exist using the "File" command will lead to errors.
-  ${!defineifexist} REDIST_INSTALLER_PRESENT @CPACK_PACKAGE_FILE_NAME@\thirdpartyinstallers\@CPACK_REDISTRIBUTABLE_FILE_NAME@
-
-  !ifdef REDIST_INSTALLER_PRESENT
-    ; Check at runtime whether the redistributable installer is available
-    IfFileExists $INSTDIR\thirdpartyinstallers\@CPACK_REDISTRIBUTABLE_FILE_NAME@ InstallRedist NoRedistInstaller
-
-    InstallRedist:
-
-    ClearErrors
-    File "@CPACK_PACKAGE_FILE_NAME@\thirdpartyinstallers\@CPACK_REDISTRIBUTABLE_FILE_NAME@"
-    ExecWait '"$INSTDIR\thirdpartyinstallers\@CPACK_REDISTRIBUTABLE_FILE_NAME@" /passive /norestart'
-    IfErrors endInstallationMissingRedist
-
-    Goto RedistInstalled
-
-    endInstallationMissingRedist:
-    Abort "Installation aborted. Missing required @CPACK_VISUAL_STUDIO_PRODUCT_NAME@ @CPACK_LIBRARY_ARCHITECTURE@ Redistributable"
-  !endif
-
-  ; We are missing the redistributable installer, inform the user
-  NoRedistInstaller:
-  MessageBox MB_OK "Missing required @CPACK_VISUAL_STUDIO_PRODUCT_NAME@ @CPACK_LIBRARY_ARCHITECTURE@ Redistributable. You need to install it to use MITK."
-  Goto End
-
-  ; The user does not have the required rights to install redistributables
-  NoAdminRights:
-  MessageBox MB_OK|MB_ICONSTOP "This MITK version requires the @CPACK_VISUAL_STUDIO_PRODUCT_NAME@ @CPACK_LIBRARY_ARCHITECTURE@ Redistributable.$\r$\n\
-                    Your user account does not have administrator privileges.$\r$\n\
-                    Please ask your system administrator to install the @CPACK_VISUAL_STUDIO_PRODUCT_NAME@ @CPACK_LIBRARY_ARCHITECTURE@ Redistributable."
-  Pop $R0
-  Goto End
-
-  ; No need to do anything
-  RedistInstalled:
-  Goto End
-
-  End:
-FunctionEnd
-
 ;--------------------------------
 ; determine admin versus local install
 Function un.onInit
 
   ClearErrors
   UserInfo::GetName
   IfErrors noLM
   Pop $0
   UserInfo::GetAccountType
   Pop $1
   StrCmp $1 "Admin" 0 +3
     SetShellVarContext all
     ;MessageBox MB_OK 'User "$0" is in the Admin group'
     Goto done
   StrCmp $1 "Power" 0 +3
     SetShellVarContext all
     ;MessageBox MB_OK 'User "$0" is in the Power Users group'
     Goto done
 
   noLM:
     ;Get installation folder from registry if available
 
   done:
 
 FunctionEnd
 
 ;--- Add/Remove callback functions: ---
 !macro SectionList MacroName
   ;This macro used to perform operation on multiple sections.
   ;List all of your components in following manner here.
 @CPACK_NSIS_COMPONENT_SECTION_LIST@
 !macroend
 
 Section -FinishComponents
   ;Removes unselected components and writes component status to registry
   !insertmacro SectionList "FinishSection"
 
 !ifdef CPACK_NSIS_ADD_REMOVE
   ; Get the name of the installer executable
   System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
   StrCpy $R3 $R0
 
   ; Strip off the last 13 characters, to see if we have AddRemove.exe
   StrLen $R1 $R0
   IntOp $R1 $R0 - 13
   StrCpy $R2 $R0 13 $R1
   StrCmp $R2 "AddRemove.exe" addremove_installed
 
   ; We're not running AddRemove.exe, so install it
   CopyFiles $R3 $INSTDIR\AddRemove.exe
 
   addremove_installed:
 !endif
 SectionEnd
 ;--- End of Add/Remove callback functions ---
 
 ;--------------------------------
 ; Component dependencies
 Function .onSelChange
   !insertmacro SectionList MaybeSelectionChanged
 FunctionEnd
 
 ;--------------------------------
 ;Uninstaller Section
 
 Section "Uninstall"
   ReadRegStr $START_MENU SHCTX \
    "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "StartMenu"
   ;MessageBox MB_OK "Start menu is in: $START_MENU"
   ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
     "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "DoNotAddToPath"
   ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
     "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathAllUsers"
   ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
     "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathCurrentUser"
   ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
   ReadRegStr $INSTALL_DESKTOP SHCTX \
     "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "InstallToDesktop"
   ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
 
 @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
 
   ;Remove files we installed.
   ;Keep the list of directories here in sync with the File commands above.
 @CPACK_NSIS_DELETE_FILES@
 @CPACK_NSIS_DELETE_DIRECTORIES@
 
 !ifdef CPACK_NSIS_ADD_REMOVE
   ;Remove the add/remove program
   Delete "$INSTDIR\AddRemove.exe"
 !endif
 
   ;Remove the uninstaller itself.
   Delete "$INSTDIR\Uninstall.exe"
   DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@"
 
   ;Remove the installation directory if it is empty.
   RMDir "$INSTDIR"
 
   ; Remove the registry entries.
   DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
 
   ; Removes all optional components
   !insertmacro SectionList "RemoveSection"
 
   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
 
   Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
 @CPACK_NSIS_DELETE_ICONS@
 @CPACK_NSIS_DELETE_ICONS_EXTRA@
 
   ;Delete empty start menu parent diretories
   StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
 
   startMenuDeleteLoop:
     ClearErrors
     RMDir $MUI_TEMP
     GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
 
     IfErrors startMenuDeleteLoopDone
 
     StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
   startMenuDeleteLoopDone:
 
   ; If the user changed the shortcut, then untinstall may not work. This should
   ; try to fix it.
   StrCpy $MUI_TEMP "$START_MENU"
   Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
 @CPACK_NSIS_DELETE_ICONS_EXTRA@
 
   ;Delete empty start menu parent diretories
   StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
 
   secondStartMenuDeleteLoop:
     ClearErrors
     RMDir $MUI_TEMP
     GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
 
     IfErrors secondStartMenuDeleteLoopDone
 
     StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
   secondStartMenuDeleteLoopDone:
 
   DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
 
   Push $INSTDIR\bin
   StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
     Call un.RemoveFromPath
   doNotRemoveFromPath:
 SectionEnd
 
 ;--------------------------------
 ; determine admin versus local install
 ; Is install for "AllUsers" or "JustMe"?
 ; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
 ; This function is used for the very first "custom page" of the installer.
 ; This custom page does not show up visibly, but it executes prior to the
 ; first visible page and sets up $INSTDIR properly...
 ; Choose different default installation folder based on SV_ALLUSERS...
 ; "Program Files" for AllUsers, "My Documents" for JustMe...
 
 Function .onInit
   ; Reads components status for registry
   !insertmacro SectionList "InitSection"
 
   ; check to see if /D has been used to change
   ; the install directory by comparing it to the
   ; install directory that is expected to be the
   ; default
   StrCpy $IS_DEFAULT_INSTALLDIR 0
   StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
     StrCpy $IS_DEFAULT_INSTALLDIR 1
 
   StrCpy $SV_ALLUSERS "JustMe"
   ; if default install dir then change the default
   ; if it is installed for JustMe
   StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
     StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
 
   ClearErrors
   UserInfo::GetName
   IfErrors noLM
   Pop $0
   UserInfo::GetAccountType
   Pop $1
   StrCmp $1 "Admin" 0 +3
     SetShellVarContext all
     ;MessageBox MB_OK 'User "$0" is in the Admin group'
     StrCpy $SV_ALLUSERS "AllUsers"
     Goto done
   StrCmp $1 "Power" 0 +3
     SetShellVarContext all
     ;MessageBox MB_OK 'User "$0" is in the Power Users group'
     StrCpy $SV_ALLUSERS "AllUsers"
     Goto done
 
   noLM:
     StrCpy $SV_ALLUSERS "AllUsers"
     ;Get installation folder from registry if available
 
   done:
   StrCmp $SV_ALLUSERS "AllUsers" 0 +3
     StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
       StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
 
   StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
     !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
 
   noOptionsPage:
 FunctionEnd
diff --git a/CMake/RunInstalledApp.bat b/CMake/RunInstalledApp.bat
new file mode 100644
index 0000000000..8ca0361f5c
--- /dev/null
+++ b/CMake/RunInstalledApp.bat
@@ -0,0 +1 @@
+start "" /B /D bin bin/%~n0.exe %*
diff --git a/CMake/mitkFunctionCreateBlueBerryApplication.cmake b/CMake/mitkFunctionCreateBlueBerryApplication.cmake
index 9f4001b778..8869470500 100644
--- a/CMake/mitkFunctionCreateBlueBerryApplication.cmake
+++ b/CMake/mitkFunctionCreateBlueBerryApplication.cmake
@@ -1,229 +1,231 @@
 #!
 #! Create a BlueBerry application.
 #!
 #! \brief This function will create a BlueBerry application together with all
 #! necessary provisioning and configuration data and install support.
 #!
 #! \param NAME (required) The name of the executable.
 #! \param DESCRIPTION (optional) A human-readable description of your application.
 #!        The usage depends on the CPack generator (on Windows, this is a descriptive
 #!        text for the created shortcuts).
 #! \param SOURCES (optional) A list of source files to compile into your executable. Defaults
 #!        to <name>.cpp.
 #! \param PLUGINS (optional) A list of required plug-ins. Defaults to all known plug-ins.
 #! \param EXCLUDE_PLUGINS (optional) A list of plug-ins which should not be used. Mainly
 #!        useful if PLUGINS was not used.
 #! \param LINK_LIBRARIES A list of libraries to be linked with the executable.
 #! \param LIBRARY_DIRS A list of directories to pass through to MITK_INSTALL_TARGETS
 #! \param NO_PROVISIONING (option) Do not create provisioning files.
 #! \param NO_INSTALL (option) Do not install this executable
 #!
 #! Assuming that there exists a file called <code>MyApp.cpp</code>, an example call looks like:
 #! \code
 #! mitkFunctionCreateBlueBerryApplication(
 #!   NAME MyApp
 #!   DESCRIPTION "MyApp - New ways to explore medical data"
 #!   EXCLUDE_PLUGINS org.mitk.gui.qt.extapplication
 #! )
 #! \endcode
 #!
 function(mitkFunctionCreateBlueBerryApplication)
 
 cmake_parse_arguments(_APP "NO_PROVISIONING;NO_INSTALL" "NAME;DESCRIPTION" "SOURCES;PLUGINS;EXCLUDE_PLUGINS;LINK_LIBRARIES;LIBRARY_DIRS" ${ARGN})
 
 if(NOT _APP_NAME)
   message(FATAL_ERROR "NAME argument cannot be empty.")
 endif()
 
 if(NOT _APP_SOURCES)
   set(_APP_SOURCES ${_APP_NAME}.cpp)
 endif()
 
 if(NOT _APP_PLUGINS)
   ctkFunctionGetAllPluginTargets(_APP_PLUGINS)
 else()
   set(_plugins ${_APP_PLUGINS})
   set(_APP_PLUGINS)
   foreach(_plugin ${_plugins})
     string(REPLACE "." "_" _plugin_target ${_plugin})
     list(APPEND _APP_PLUGINS ${_plugin_target})
   endforeach()
 
   # get all plug-in dependencies
   ctkFunctionGetPluginDependencies(_plugin_deps PLUGINS ${_APP_PLUGINS} ALL)
   # add the dependencies to the list of application plug-ins
   list(APPEND _APP_PLUGINS ${_plugin_deps})
 endif()
 
 # -----------------------------------------------------------------------
 # Set up include and link dirs for the executable
 # -----------------------------------------------------------------------
 
 include_directories(
   ${org_blueberry_core_runtime_INCLUDE_DIRS}
 )
 
 # -----------------------------------------------------------------------
 # Add executable icon (Windows)
 # -----------------------------------------------------------------------
 set(WINDOWS_ICON_RESOURCE_FILE "")
 if(WIN32)
   if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc")
     set(WINDOWS_ICON_RESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/icons/${_APP_NAME}.rc")
   endif()
 endif()
 
 # -----------------------------------------------------------------------
 # Create the executable and link libraries
 # -----------------------------------------------------------------------
 
 set(_app_compile_flags )
 if(WIN32)
   set(_app_compile_flags "${_app_compile_flags} -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN")
 endif()
 
 if(MITK_SHOW_CONSOLE_WINDOW)
   add_executable(${_APP_NAME} MACOSX_BUNDLE ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
 else()
   add_executable(${_APP_NAME} MACOSX_BUNDLE WIN32 ${_APP_SOURCES} ${WINDOWS_ICON_RESOURCE_FILE})
 endif()
 
 if(NOT CMAKE_CURRENT_SOURCE_DIR MATCHES "^${CMAKE_SOURCE_DIR}.*")
   foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS})
     if(CMAKE_CURRENT_SOURCE_DIR MATCHES "^${MITK_EXTENSION_DIR}.*")
       get_filename_component(MITK_EXTENSION_ROOT_FOLDER "${MITK_EXTENSION_DIR}" NAME)
       set_property(TARGET ${_APP_NAME} PROPERTY FOLDER "${MITK_EXTENSION_ROOT_FOLDER}/Applications")
       break()
     endif()
   endforeach()
 else()
   set_property(TARGET ${_APP_NAME} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Applications")
 endif()
 
 mitk_use_modules(TARGET ${_APP_NAME} MODULES MitkAppUtil)
 
 set_target_properties(${_APP_NAME} PROPERTIES
                       COMPILE_FLAGS "${_app_compile_flags}")
 
 target_link_libraries(${_APP_NAME} PRIVATE org_blueberry_core_runtime ${_APP_LINK_LIBRARIES})
 if(WIN32)
   target_link_libraries(${_APP_NAME} PRIVATE ${QT_QTMAIN_LIBRARY})
 endif()
 
 # -----------------------------------------------------------------------
 # Add executable icon and bundle name (Mac)
 # -----------------------------------------------------------------------
 if(APPLE)
   if( _APP_DESCRIPTION)
     set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_DESCRIPTION}")
   else()
     set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_NAME "${_APP_NAME}")
   endif()
   set(icon_name "icon.icns")
   set(icon_full_path "${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon_name}")
   if(EXISTS "${icon_full_path}")
     set_target_properties(${_APP_NAME} PROPERTIES MACOSX_BUNDLE_ICON_FILE "${icon_name}")
     file(COPY ${icon_full_path} DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.app/Contents/Resources/")
     INSTALL (FILES ${icon_full_path} DESTINATION "${_APP_NAME}.app/Contents/Resources/")
   endif()
 endif()
 
 # -----------------------------------------------------------------------
 # Set build time dependencies
 # -----------------------------------------------------------------------
 
 # This ensures that all enabled plug-ins are up-to-date when the
 # executable is build.
 if(_APP_PLUGINS)
   ctkMacroGetAllProjectTargetLibraries("${_APP_PLUGINS}" _project_plugins)
   if(_APP_EXCLUDE_PLUGINS AND _project_plugins)
     set(_exclude_targets)
     foreach(_exclude_plugin ${_APP_EXCLUDE_PLUGINS})
       string(REPLACE "." "_" _exclude_target ${_exclude_plugin})
       list(APPEND _exclude_targets ${_exclude_target})
     endforeach()
     list(REMOVE_ITEM _project_plugins ${_exclude_targets})
   endif()
   if(_project_plugins)
     add_dependencies(${_APP_NAME} ${_project_plugins})
   endif()
 endif()
 
 # -----------------------------------------------------------------------
 # Additional files needed for the executable
 # -----------------------------------------------------------------------
 
 if(NOT _APP_NO_PROVISIONING)
 
   # Create a provisioning file, listing all plug-ins
   set(_prov_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.provisioning")
   mitkFunctionCreateProvisioningFile(FILE ${_prov_file}
                                      PLUGINS ${_APP_PLUGINS}
                                      EXCLUDE_PLUGINS ${_APP_EXCLUDE_PLUGINS}
                                     )
 
 endif()
 
 # Create a .ini file for initial parameters
 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_APP_NAME}.ini")
   configure_file(${_APP_NAME}.ini
                  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_APP_NAME}.ini)
 endif()
 
 # Create batch and VS user files for Windows platforms
 include(mitkFunctionCreateWindowsBatchScript)
 
 if(WIN32)
   set(template_name "start${_APP_NAME}.bat.in")
   if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${template_name}")
     foreach(BUILD_TYPE debug release)
       mitkFunctionCreateWindowsBatchScript(${template_name}
         ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/start${_APP_NAME}_${BUILD_TYPE}.bat
         ${BUILD_TYPE})
     endforeach()
   endif()
   mitkFunctionConfigureVisualStudioUserProjectFile(
     NAME ${_APP_NAME}
   )
 endif(WIN32)
 
 # -----------------------------------------------------------------------
 # Install support
 # -----------------------------------------------------------------------
 
 if(NOT _APP_NO_INSTALL)
 
   # This installs all third-party CTK plug-ins
   mitkFunctionInstallThirdPartyCTKPlugins(${_APP_PLUGINS} EXCLUDE ${_APP_EXCLUDE_PLUGINS})
 
   if(COMMAND BlueBerryApplicationInstallHook)
     set(_real_app_plugins ${_APP_PLUGINS})
     if(_APP_EXCLUDE_PLUGINS)
       list(REMOVE_ITEM _real_app_plugins ${_APP_EXCLUDE_PLUGINS})
     endif()
     BlueBerryApplicationInstallHook(APP_NAME ${_APP_NAME} PLUGINS ${_real_app_plugins})
   endif()
 
   # Install the executable
   MITK_INSTALL_TARGETS(EXECUTABLES ${_APP_NAME} LIBRARY_DIRS ${_APP_LIBRARY_DIRS} GLOB_PLUGINS )
 
   if(NOT _APP_NO_PROVISIONING)
     # Install the provisioning file
     mitkFunctionInstallProvisioningFiles(${_prov_file})
   endif()
 
   # 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 ${_APP_NAME}.sh)
+    install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME "${_APP_NAME}.sh")
+  elseif(WIN32)
+    install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.bat" DESTINATION "." RENAME "${_APP_NAME}.bat")
   endif()
 
   # Tell cpack the executables that you want in the start menu as links
   set(MITK_CPACK_PACKAGE_EXECUTABLES ${MITK_CPACK_PACKAGE_EXECUTABLES} "${_APP_NAME};${_APP_DESCRIPTION}" CACHE INTERNAL "Collecting windows shortcuts to executables")
 
 endif()
 
 endfunction()
 
 function(FunctionCreateBlueBerryApplication)
   message(SEND_ERROR "The function FunctionCreateBlueBerryApplication was renamed to mitkFunctionCreateBlueBerryApplication in MITK 2015.05")
 endfunction()
diff --git a/CMake/mitkInstallRules.cmake b/CMake/mitkInstallRules.cmake
index 5ce1789fdc..c9ae3f0b51 100644
--- a/CMake/mitkInstallRules.cmake
+++ b/CMake/mitkInstallRules.cmake
@@ -1,170 +1,172 @@
 # Install MITK icon and logo
 
 MITK_INSTALL(FILES
   "${MITK_SOURCE_DIR}/mitk.ico"
   "${MITK_SOURCE_DIR}/mitk.bmp")
 
 # Helper vars
 
 if(WIN32)
   set(_prefix "")
   set(_ext ".dll")
 elseif(UNIX)
   set(_prefix "lib")
   if(APPLE)
     set(_ext ".dylib")
   else()
     set(_ext ".so")
   endif()
 endif()
 
 # Install MITK executables including auto-load modules
 
 get_property(_mitk_executable_targets GLOBAL PROPERTY MITK_EXECUTABLE_TARGETS)
 if(_mitk_executable_targets)
   get_property(_mitk_module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS)
   foreach(_mitk_module_target ${_mitk_module_targets})
     if(TARGET ${_mitk_module_target})
       get_target_property(_mitk_autoload_targets ${_mitk_module_target} MITK_AUTOLOAD_TARGETS)
       if (_mitk_autoload_targets)
         foreach(_mitk_autoload_target ${_mitk_autoload_targets})
           get_target_property(_mitk_autoload_directory ${_mitk_autoload_target} MITK_AUTOLOAD_DIRECTORY)
           if (_mitk_autoload_directory)
             if(WIN32)
               get_target_property(_target_location ${_mitk_autoload_target} RUNTIME_OUTPUT_DIRECTORY)
             else()
               get_target_property(_target_location ${_mitk_autoload_target} LIBRARY_OUTPUT_DIRECTORY)
             endif()
             if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
               set(_target_location "${_target_location}/Release")
             endif()
             set(_mitk_autoload_target_filename "${_prefix}${_mitk_autoload_target}${_ext}")
             set(_mitk_autoload_target_filepath "${_target_location}/${_mitk_autoload_target_filename}")
             set(_install_DESTINATION "${_mitk_autoload_directory}")
             MITK_INSTALL(FILES ${_mitk_autoload_target_filepath})
             if(UNIX AND NOT APPLE)
               install(CODE "file(RPATH_REMOVE FILE \"\${CMAKE_INSTALL_PREFIX}/bin/${_mitk_autoload_directory}/${_mitk_autoload_target_filename}\")")
             endif()
           endif()
         endforeach()
       endif()
     endif()
   endforeach()
 
   set(_install_DESTINATION "")
 
   foreach(_mitk_executable_target ${_mitk_executable_targets})
     get_target_property(_no_install ${_mitk_executable_target} NO_INSTALL)
     if(_no_install)
       continue()
     endif()
     MITK_INSTALL_TARGETS(EXECUTABLES ${_mitk_executable_target} GLOB_PLUGINS)
     if(UNIX AND NOT APPLE)
-      install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME ${_mitk_executable_target}.sh)
+      install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.sh" DESTINATION "." RENAME "${_mitk_executable_target}.sh")
+    elseif(WIN32)
+      install(PROGRAMS "${MITK_SOURCE_DIR}/CMake/RunInstalledApp.bat" DESTINATION "." RENAME "${_mitk_executable_target}.bat")
     endif()
   endforeach()
 endif()
 
 # Install PythonQt
 
 if(MITK_USE_Python3 AND PythonQt_DIR)
   set(_python_qt_lib "${PythonQt_DIR}/")
   if(WIN32)
     set(_python_qt_lib "${_python_qt_lib}bin")
   else()
     set(_python_qt_lib "${_python_qt_lib}lib")
   endif()
   set(_python_qt_lib "${_python_qt_lib}/${_prefix}PythonQt${_ext}")
   MITK_INSTALL(FILES ${_python_qt_lib})
 endif()
 
 # Install Qt plugins
 
 if(MITK_USE_Qt5)
   get_property(_qmake_location TARGET ${Qt5Core_QMAKE_EXECUTABLE} PROPERTY IMPORT_LOCATION)
   get_filename_component(_qmake_path ${_qmake_location} DIRECTORY)
 
   set(_install_DESTINATION "plugins/sqldrivers")
   MITK_INSTALL(FILES "${_qmake_path}/../plugins/sqldrivers/${_prefix}qsqlite${_ext}")
 
   set(_install_DESTINATION "plugins/imageformats")
   MITK_INSTALL(FILES "${_qmake_path}/../plugins/imageformats/${_prefix}qsvg${_ext}")
 
   set(_install_DESTINATION "plugins/iconengines")
   MITK_INSTALL(FILES "${_qmake_path}/../plugins/iconengines/${_prefix}qsvgicon${_ext}")
 
   # Install platform-specific Qt plugins
 
   set(_install_DESTINATION "plugins/platforms")
 
   if(WIN32)
     MITK_INSTALL(FILES "${_qmake_path}/../plugins/platforms/qwindows.dll")
   elseif(APPLE)
     MITK_INSTALL(FILES "${_qmake_path}/../plugins/platforms/libqcocoa.dylib")
   elseif(UNIX)
     MITK_INSTALL(FILES "${_qmake_path}/../plugins/platforms/libqxcb.so")
 
     set(_install_DESTINATION "plugins/xcbglintegrations")
     MITK_INSTALL(FILES "${_qmake_path}/../plugins/xcbglintegrations/libqxcb-glx-integration.so")
   endif()
 
   # Install platform-specific Qt styles
 
   set(_install_DESTINATION "plugins/styles")
 
   if(WIN32)
     MITK_INSTALL(FILES "${_qmake_path}/../plugins/styles/qwindowsvistastyle.dll")
   elseif(APPLE)
     MITK_INSTALL(FILES "${_qmake_path}/../plugins/styles/libqmacstyle.dylib")
   endif()
 
   # Install Qt WebEngine
 
   if(APPLE)
     set(_install_DESTINATION "../Frameworks/QtWebEngineCore.framework")
 
     get_filename_component(_real_path "${_qmake_path}/../lib/QtWebEngineCore.framework/Helpers" REALPATH)
     MITK_INSTALL(DIRECTORY ${_real_path} USE_SOURCE_PERMISSIONS)
 
     # Translations are included in the Resources directory of
     # QtWebEngineCore.framework and are installed by default.
   else()
     set(_install_DESTINATION "")
 
     if(WIN32)
       MITK_INSTALL(PROGRAMS "${_qmake_path}/QtWebEngineProcess.exe")
     elseif(UNIX)
       MITK_INSTALL(PROGRAMS "${_qmake_path}/../libexec/QtWebEngineProcess")
     endif()
 
     # make sure resources and translations exist and try system location as well
     if(EXISTS "${_qmake_path}/../resources")
       MITK_INSTALL(DIRECTORY "${_qmake_path}/../resources")
     elseif(EXISTS "/usr/share/qt5/resources")
       MITK_INSTALL(DIRECTORY "/usr/share/qt5/resources")
     else()
       message(WARNING "No webengine resources found!")
     endif()
 
     set(_install_DESTINATION "translations")
     if(EXISTS "${_qmake_path}/../translations/qtwebengine_locales")
       MITK_INSTALL(DIRECTORY "${_qmake_path}/../translations/qtwebengine_locales")
     elseif(EXISTS "/usr/share/qt5/translations/qtwebengine_locales")
       MITK_INSTALL(DIRECTORY "/usr/share/qt5/translations/qtwebengine_locales")
     else()
       message(WARNING "No webengine translations found!")
     endif()
 
    endif()
 endif()
 
 set(_install_DESTINATION "")
 
 # Install MatchPoint binaries that are not auto-detected
 if(MITK_USE_MatchPoint)
   MITK_INSTALL(DIRECTORY "${MITK_EXTERNAL_PROJECT_PREFIX}/bin/" FILES_MATCHING PATTERN "MapUtilities*")
   MITK_INSTALL(DIRECTORY "${MITK_EXTERNAL_PROJECT_PREFIX}/bin/" FILES_MATCHING PATTERN "MapAlgorithms*")
 endif()
 
 # IMPORTANT: Restore default install destination! Do not edit this file beyond this line!
 set(_install_DESTINATION "")
diff --git a/CMake/mitkSetupCPack.cmake b/CMake/mitkSetupCPack.cmake
index 1663a79fb3..6a95fec76a 100644
--- a/CMake/mitkSetupCPack.cmake
+++ b/CMake/mitkSetupCPack.cmake
@@ -1,142 +1,97 @@
 #
 # First, set the generator variable
 #
 if(NOT CPACK_GENERATOR)
   if(WIN32)
     find_program(NSIS_MAKENSIS NAMES makensis
       PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
       DOC "Where is makensis.exe located"
       )
 
-    if(NOT NSIS_MAKENSIS)
-      set(CPACK_GENERATOR ZIP)
-    else()
-      set(CPACK_GENERATOR "NSIS;ZIP")
+    set(CPACK_GENERATOR ZIP)
 
-    endif(NOT NSIS_MAKENSIS)
+    if(NSIS_MAKENSIS)
+      set(MITK_CREATE_NSIS_INSTALLER ON CACHE BOOL "Create NSIS installer in addition to ZIP archive")
+      mark_as_advanced(MITK_CREATE_NSIS_INSTALLER)
+      if(MITK_CREATE_NSIS_INSTALLER)
+        list(APPEND CPACK_GENERATOR NSIS)
+      endif()
+    endif()
   else()
     if(APPLE)
       set(CPACK_GENERATOR DragNDrop)
     else()
       set(CPACK_GENERATOR TGZ)
     endif()
   endif()
-endif(NOT CPACK_GENERATOR)
-
-# Set Redistributable information for windows
-if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
-  include(mitkFunctionGetMSVCVersion)
-  mitkFunctionGetMSVCVersion()
-  set(CPACK_VISUAL_STUDIO_VERSION_MAJOR "${VISUAL_STUDIO_VERSION_MAJOR}")
-  set(CPACK_VISUAL_STUDIO_PRODUCT_NAME "${VISUAL_STUDIO_PRODUCT_NAME}")
-  set(CPACK_LIBRARY_ARCHITECTURE "${CMAKE_LIBRARY_ARCHITECTURE}")
-
-  # Visual Studio 2017 already comes with redistributable installers.
-  # Try to find the right one.
-
-  set(vswhere "$ENV{PROGRAMFILES\(X86\)}\\Microsoft Visual Studio\\Installer\\vswhere.exe")
-
-  if(EXISTS ${vswhere})
-    execute_process(COMMAND ${vswhere} -latest -property installationPath
-      OUTPUT_VARIABLE installationPath
-      OUTPUT_STRIP_TRAILING_WHITESPACE)
-    file(TO_CMAKE_PATH "${installationPath}" installationPath)
-    set(redistPath "${installationPath}/VC/Redist/MSVC")
-    file(GLOB redistPath "${installationPath}/VC/Redist/MSVC/*")
-    list(LENGTH redistPath length)
-    if(length EQUAL 1)
-      if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-        set(redistPath "${redistPath}/vc_redist.x64.exe")
-      else()
-        set(redistPath "${redistPath}/vc_redist.x86.exe")
-      endif()
-      if(EXISTS ${redistPath})
-        set(CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE ${redistPath} CACHE FILEPATH "Path to the appropriate Microsoft Visual Studio Redistributable")
-      endif()
-    endif()
-  endif()
-
-  if(NOT DEFINED CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE)
-    set(CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE "" CACHE FILEPATH "Path to the appropriate Microsoft Visual Studio Redistributable")
-  endif()
-endif()
-
-if(EXISTS ${CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE} )
-  install(PROGRAMS ${CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE}
-          DESTINATION thirdpartyinstallers)
-
-  get_filename_component(CPACK_REDISTRIBUTABLE_FILE_NAME ${CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE} NAME )
 endif()
 
 # On windows set default install directory appropriately for 32 and 64 bit
 # installers if not already set
 if(WIN32 AND NOT CPACK_NSIS_INSTALL_ROOT)
   if(CMAKE_CL_64)
     set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
   else()
     set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
   endif()
 endif()
 
 # By default, do not warn when built on machines using only VS Express
-if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
-  set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
+if(MITK_USE_OpenMP)
+  set(CMAKE_INSTALL_OPENMP_LIBRARIES ON)
 endif()
 
 # include required mfc libraries
 include(InstallRequiredSystemLibraries)
 
 set(CPACK_PACKAGE_NAME "MITK")
 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Medical Imaging Interaction Toolkit")
 set(CPACK_PACKAGE_VENDOR "German Cancer Research Center (DKFZ)")
 set(CPACK_PACKAGE_DESCRIPTION_FILE "${MITK_SOURCE_DIR}/LICENSE")
 set(CPACK_RESOURCE_FILE_LICENSE "${MITK_SOURCE_DIR}/LICENSE")
 
 string(REPLACE "/" "_" CPACK_PACKAGE_VERSION_MAJOR "${MITK_REVISION_DESC}")
 
 # tell cpack to strip all debug symbols from all files
 set(CPACK_STRIP_FILES ON)
 
 # set version
 if(NOT CPACK_PACKAGE_VERSION_MAJOR)
   set(CPACK_PACKAGE_VERSION_MAJOR ${MITK_VERSION_MAJOR})
   set(CPACK_PACKAGE_VERSION_MINOR ${MITK_VERSION_MINOR})
   set(CPACK_PACKAGE_VERSION_PATCH ${MITK_VERSION_PATCH})
   set(CPACK_PACKAGE_VERSION "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}")
 else()
   set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR})
 endif()
 
 # determine possible system specific extension
 set(CPACK_PACKAGE_ARCH "unkown-architecture")
 
 if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
   if(CMAKE_CL_64)
     set(CPACK_PACKAGE_ARCH "windows-x86_64")
   elseif(WIN32)
     set(CPACK_PACKAGE_ARCH "windows-x86")
   endif()
 endif()
 
 if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
   if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686)
     set(CPACK_PACKAGE_ARCH "linux-x86")
   elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64)
     if(${CMAKE_CXX_FLAGS} MATCHES " -m32 ")
       set(CPACK_PACKAGE_ARCH "linux-x86")
     else()
       set(CPACK_PACKAGE_ARCH "linux-x86_64")
     endif()
   else()
     set(CPACK_PACKAGE_ARCH "linux")
   endif()
 endif()
 
 if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
   set(CPACK_PACKAGE_ARCH "macos-x86_64")
 endif()
 
 set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_ARCH}")
-
-
-
diff --git a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp
index 48a1301bf6..8ada9faf2b 100644
--- a/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp
+++ b/Modules/Segmentation/Interactions/mitkFastMarchingTool3D.cpp
@@ -1,334 +1,334 @@
 /*============================================================================
 
 The Medical Imaging Interaction Toolkit (MITK)
 
 Copyright (c) German Cancer Research Center (DKFZ)
 All rights reserved.
 
 Use of this source code is governed by a 3-clause BSD license that can be
 found in the LICENSE file.
 
 ============================================================================*/
 
 #include "mitkFastMarchingTool3D.h"
 #include "mitkToolManager.h"
 
 #include "mitkBaseRenderer.h"
 #include "mitkInteractionConst.h"
 #include "mitkRenderingManager.h"
 
 #include "mitkImageAccessByItk.h"
 
 // itk filter
 #include "itkBinaryThresholdImageFilter.h"
 #include "itkCurvatureAnisotropicDiffusionImageFilter.h"
 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
 #include "itkSigmoidImageFilter.h"
 
 // us
 #include <usGetModuleContext.h>
 #include <usModule.h>
 #include <usModuleContext.h>
 #include <usModuleResource.h>
 
 namespace mitk
 {
   MITK_TOOL_MACRO(MITKSEGMENTATION_EXPORT, FastMarchingTool3D, "FastMarching3D tool");
 }
 
 mitk::FastMarchingTool3D::FastMarchingTool3D()
   : AutoSegmentationWithPreviewTool(),
     m_LowerThreshold(0),
     m_UpperThreshold(200),
     m_StoppingValue(100),
     m_Sigma(1.0),
     m_Alpha(-0.5),
     m_Beta(3.0),
     m_PointSetAddObserverTag(0),
     m_PointSetRemoveObserverTag(0)
 {
 }
 
 mitk::FastMarchingTool3D::~FastMarchingTool3D()
 {
 }
 
 bool mitk::FastMarchingTool3D::CanHandle(const BaseData* referenceData, const BaseData* workingData) const
 {
   if(!Superclass::CanHandle(referenceData, workingData))
     return false;
 
   if (referenceData == nullptr)
     return false;
 
   auto *image = dynamic_cast<const Image *>(referenceData);
 
   if (image == nullptr)
     return false;
 
   if (image->GetDimension() < 3)
     return false;
 
   return true;
 }
 
 const char **mitk::FastMarchingTool3D::GetXPM() const
 {
   return nullptr; // mitkFastMarchingTool3D_xpm;
 }
 
 us::ModuleResource mitk::FastMarchingTool3D::GetIconResource() const
 {
   us::Module *module = us::GetModuleContext()->GetModule();
   us::ModuleResource resource = module->GetResource("FastMarching_48x48.png");
   return resource;
 }
 
 const char *mitk::FastMarchingTool3D::GetName() const
 {
   return "Fast Marching 3D";
 }
 
 void mitk::FastMarchingTool3D::SetUpperThreshold(double value)
 {
   m_UpperThreshold = value / 10.0;
 }
 
 void mitk::FastMarchingTool3D::SetLowerThreshold(double value)
 {
   m_LowerThreshold = value / 10.0;
 }
 
 void mitk::FastMarchingTool3D::SetBeta(double value)
 {
   if (m_Beta != value)
   {
     m_Beta = value;
   }
 }
 
 void mitk::FastMarchingTool3D::SetSigma(double value)
 {
   if (m_Sigma != value)
   {
     if (value > 0.0)
     {
       m_Sigma = value;
     }
   }
 }
 
 void mitk::FastMarchingTool3D::SetAlpha(double value)
 {
   if (m_Alpha != value)
   {
     m_Alpha = value;
   }
 }
 
 void mitk::FastMarchingTool3D::SetStoppingValue(double value)
 {
   if (m_StoppingValue != value)
   {
     m_StoppingValue = value;
   }
 }
 
 void mitk::FastMarchingTool3D::Activated()
 {
   Superclass::Activated();
 
   m_SeedsAsPointSet = mitk::PointSet::New();
   m_SeedsAsPointSetNode = mitk::DataNode::New();
   m_SeedsAsPointSetNode->SetData(m_SeedsAsPointSet);
   m_SeedsAsPointSetNode->SetName("3D_FastMarching_PointSet");
   m_SeedsAsPointSetNode->SetBoolProperty("helper object", true);
   m_SeedsAsPointSetNode->SetColor(0.0, 1.0, 0.0);
   m_SeedsAsPointSetNode->SetVisibility(true);
 
   // Create PointSetData Interactor
   m_SeedPointInteractor = mitk::PointSetDataInteractor::New();
   // Load the according state machine for regular point set interaction
   m_SeedPointInteractor->LoadStateMachine("PointSet.xml");
   // Set the configuration file that defines the triggers for the transitions
   m_SeedPointInteractor->SetEventConfig("PointSetConfig.xml");
   // set the DataNode (which already is added to the DataStorage
   m_SeedPointInteractor->SetDataNode(m_SeedsAsPointSetNode);
 
   m_ToolManager->GetDataStorage()->Add(m_SeedsAsPointSetNode, m_ToolManager->GetWorkingData(0));
 
   m_SeedContainer = NodeContainer::New();
   m_SeedContainer->Initialize();
 
   itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::Pointer pointAddedCommand =
     itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::New();
   pointAddedCommand->SetCallbackFunction(this, &mitk::FastMarchingTool3D::OnAddPoint);
   m_PointSetAddObserverTag = m_SeedsAsPointSet->AddObserver(mitk::PointSetAddEvent(), pointAddedCommand);
 
   itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::Pointer pointRemovedCommand =
     itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::New();
   pointRemovedCommand->SetCallbackFunction(this, &mitk::FastMarchingTool3D::OnDelete);
   m_PointSetRemoveObserverTag = m_SeedsAsPointSet->AddObserver(mitk::PointSetRemoveEvent(), pointRemovedCommand);
 }
 
 void mitk::FastMarchingTool3D::Deactivated()
 {
   this->ClearSeeds();
 
   // Deactivate Interaction
   m_SeedPointInteractor->SetDataNode(nullptr);
   m_ToolManager->GetDataStorage()->Remove(m_SeedsAsPointSetNode);
   m_SeedsAsPointSetNode = nullptr;
   m_SeedsAsPointSet->RemoveObserver(m_PointSetAddObserverTag);
   m_SeedsAsPointSet->RemoveObserver(m_PointSetRemoveObserverTag);
   m_SeedsAsPointSet = nullptr;
 
   Superclass::Deactivated();
 }
 
 void mitk::FastMarchingTool3D::OnAddPoint()
 {
   // Add a new seed point for FastMarching algorithm
   mitk::Point3D clickInIndex;
 
   this->GetReferenceData()->GetGeometry()->WorldToIndex(m_SeedsAsPointSet->GetPoint(m_SeedsAsPointSet->GetSize() - 1),
                                                 clickInIndex);
   itk::Index<3> seedPosition;
   seedPosition[0] = clickInIndex[0];
   seedPosition[1] = clickInIndex[1];
   seedPosition[2] = clickInIndex[2];
 
   NodeType node;
   const double seedValue = 0.0;
   node.SetValue(seedValue);
   node.SetIndex(seedPosition);
   this->m_SeedContainer->InsertElement(this->m_SeedContainer->Size(), node);
 
   mitk::RenderingManager::GetInstance()->RequestUpdateAll();
 
   this->UpdatePreview();
 }
 
 void mitk::FastMarchingTool3D::OnDelete()
 {
   // delete last seed point
   if (!(this->m_SeedContainer->empty()))
   {
     // delete last element of seeds container
     this->m_SeedContainer->pop_back();
 
     mitk::RenderingManager::GetInstance()->RequestUpdateAll();
 
     this->UpdatePreview();
   }
 }
 
 void mitk::FastMarchingTool3D::ClearSeeds()
 {
   // clear seeds for FastMarching as well as the PointSet for visualization
   if (this->m_SeedContainer.IsNotNull())
     this->m_SeedContainer->Initialize();
 
   if (this->m_SeedsAsPointSet.IsNotNull())
   {
     // remove observers from current pointset
     m_SeedsAsPointSet->RemoveObserver(m_PointSetAddObserverTag);
     m_SeedsAsPointSet->RemoveObserver(m_PointSetRemoveObserverTag);
 
     // renew pointset
     this->m_SeedsAsPointSet = mitk::PointSet::New();
     this->m_SeedsAsPointSetNode->SetData(this->m_SeedsAsPointSet);
     m_SeedsAsPointSetNode->SetName("Seeds_Preview");
     m_SeedsAsPointSetNode->SetBoolProperty("helper object", true);
     m_SeedsAsPointSetNode->SetColor(0.0, 1.0, 0.0);
     m_SeedsAsPointSetNode->SetVisibility(true);
 
     // add callback function for adding and removing points
     itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::Pointer pointAddedCommand =
       itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::New();
     pointAddedCommand->SetCallbackFunction(this, &mitk::FastMarchingTool3D::OnAddPoint);
     m_PointSetAddObserverTag = m_SeedsAsPointSet->AddObserver(mitk::PointSetAddEvent(), pointAddedCommand);
 
     itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::Pointer pointRemovedCommand =
       itk::SimpleMemberCommand<mitk::FastMarchingTool3D>::New();
     pointRemovedCommand->SetCallbackFunction(this, &mitk::FastMarchingTool3D::OnDelete);
     m_PointSetRemoveObserverTag = m_SeedsAsPointSet->AddObserver(mitk::PointSetRemoveEvent(), pointRemovedCommand);
   }
 }
 
 template <typename TPixel, unsigned int VImageDimension>
 void mitk::FastMarchingTool3D::DoITKFastMarching(const itk::Image<TPixel, VImageDimension>* inputImage,
   mitk::Image* segmentation, unsigned int timeStep)
 {
   typedef itk::Image<TPixel, VImageDimension> InputImageType;
 
   /* typedefs for itk pipeline */
 
   typedef mitk::Tool::DefaultSegmentationDataType OutputPixelType;
   typedef itk::Image<OutputPixelType, VImageDimension> OutputImageType;
 
   typedef itk::CurvatureAnisotropicDiffusionImageFilter<InputImageType, InternalImageType> SmoothingFilterType;
   typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<InternalImageType, InternalImageType> GradientFilterType;
   typedef itk::SigmoidImageFilter<InternalImageType, InternalImageType> SigmoidFilterType;
   typedef itk::BinaryThresholdImageFilter<InternalImageType, OutputImageType> ThresholdingFilterType;
 
   auto smoothFilter = SmoothingFilterType::New();
   smoothFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand);
   smoothFilter->SetTimeStep(0.05);
   smoothFilter->SetNumberOfIterations(2);
   smoothFilter->SetConductanceParameter(9.0);
 
   auto gradientMagnitudeFilter = GradientFilterType::New();
   gradientMagnitudeFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand);
   gradientMagnitudeFilter->SetSigma(m_Sigma);
 
   auto sigmoidFilter = SigmoidFilterType::New();
   sigmoidFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand);
   sigmoidFilter->SetAlpha(m_Alpha);
   sigmoidFilter->SetBeta(m_Beta);
   sigmoidFilter->SetOutputMinimum(0.0);
   sigmoidFilter->SetOutputMaximum(1.0);
 
   auto fastMarchingFilter = FastMarchingFilterType::New();
   fastMarchingFilter->AddObserver(itk::ProgressEvent(), m_ProgressCommand);
   fastMarchingFilter->SetStoppingValue(m_StoppingValue);
   fastMarchingFilter->SetTrialPoints(m_SeedContainer);
 
   auto thresholdFilter = ThresholdingFilterType::New();
   thresholdFilter->SetLowerThreshold(m_LowerThreshold);
   thresholdFilter->SetUpperThreshold(m_UpperThreshold);
   thresholdFilter->SetOutsideValue(0);
   thresholdFilter->SetInsideValue(1.0);
 
   // set up pipeline
   smoothFilter->SetInput(inputImage);
   gradientMagnitudeFilter->SetInput(smoothFilter->GetOutput());
   sigmoidFilter->SetInput(gradientMagnitudeFilter->GetOutput());
   fastMarchingFilter->SetInput(sigmoidFilter->GetOutput());
   thresholdFilter->SetInput(fastMarchingFilter->GetOutput());
   thresholdFilter->Update();
 
   segmentation->SetVolume((void*)(thresholdFilter->GetOutput()->GetPixelContainer()->GetBufferPointer()), timeStep);
 }
 
 void mitk::FastMarchingTool3D::UpdatePrepare()
 {
   // remove interaction with poinset while updating
   if (m_SeedPointInteractor.IsNotNull())
     m_SeedPointInteractor->SetDataNode(nullptr);
 }
 
 void mitk::FastMarchingTool3D::UpdateCleanUp()
 {
   // add interaction with poinset again
   if (m_SeedPointInteractor.IsNotNull())
     m_SeedPointInteractor->SetDataNode(m_SeedsAsPointSetNode);
 }
 
 void mitk::FastMarchingTool3D::DoUpdatePreview(const Image* inputAtTimeStep, Image* previewImage, TimeStepType timeStep)
 {
-  if (nullptr != inputAtTimeStep && nullptr != previewImage && m_SeedContainer.IsNotNull() && !m_SeedContainer->empty())
+  if (nullptr != inputAtTimeStep && nullptr != previewImage && m_SeedContainer.IsNotNull())
   {
     AccessFixedDimensionByItk_n(inputAtTimeStep, DoITKFastMarching, 3, (previewImage, timeStep));
   }
 }