diff --git a/Modules/DiffusionImaging/DiffusionCore/cmdapps/CMakeLists.txt b/Modules/DiffusionImaging/DiffusionCore/cmdapps/CMakeLists.txt
index 83a538fd92..df36d8afdc 100644
--- a/Modules/DiffusionImaging/DiffusionCore/cmdapps/CMakeLists.txt
+++ b/Modules/DiffusionImaging/DiffusionCore/cmdapps/CMakeLists.txt
@@ -1,45 +1,44 @@
option(BUILD_DiffusionCoreCmdApps "Build commandline tools for diffusion" OFF)
if(BUILD_DiffusionCoreCmdApps OR MITK_BUILD_ALL_APPS)
# needed include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
# list of diffusion cmdapps
# if an app requires additional dependencies
# they are added after a "^^" and separated by "_"
set( diffusioncorecmdapps
- DwiDenoising^^
ImageResampler^^
ExportShImage^^
CopyGeometry^^
Registration^^
DiffusionDICOMLoader^^
ResampleGradients^^
)
foreach(diffusioncorecmdapp ${diffusioncorecmdapps})
# extract cmd app name and dependencies
string(REPLACE "^^" "\\;" cmdapp_info ${diffusioncorecmdapp})
set(cmdapp_info_list ${cmdapp_info})
list(GET cmdapp_info_list 0 appname)
list(GET cmdapp_info_list 1 raw_dependencies)
string(REPLACE "_" "\\;" dependencies "${raw_dependencies}")
set(dependencies_list ${dependencies})
mitkFunctionCreateCommandLineApp(
NAME ${appname}
DEPENDS MitkCore MitkDiffusionCore ${dependencies_list}
PACKAGE_DEPENDS ITK
)
endforeach()
-
+
endif()
mitkFunctionCreateCommandLineApp(
NAME Dicom2Nrrd
DEPENDS MitkCore ${dependencies_list}
)
diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/CMakeLists.txt b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/CMakeLists.txt
index 490c2f7ba4..83ef9b42fc 100644
--- a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/CMakeLists.txt
+++ b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/CMakeLists.txt
@@ -1,9 +1,9 @@
# The project name must correspond to the directory name of your plug-in
# and must not contain periods.
project(org_mitk_gui_qt_diffusionimaging_preprocessing)
mitk_create_plugin(
EXPORT_DIRECTIVE DIFFUSIONIMAGING_PREPROCESSING_EXPORT
EXPORTED_INCLUDE_SUFFIXES src
- MODULE_DEPENDS MitkDiffusionCore
+ MODULE_DEPENDS MitkDiffusionCore MitkPython MitkQtPython
)
diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/files.cmake b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/files.cmake
index 0009a93c61..61c991d6e5 100644
--- a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/files.cmake
+++ b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/files.cmake
@@ -1,42 +1,45 @@
set(SRC_CPP_FILES
)
set(INTERNAL_CPP_FILES
mitkPluginActivator.cpp
QmitkPreprocessingView.cpp
+ QmitkBrainExtractionView.cpp
)
set(UI_FILES
src/internal/QmitkPreprocessingViewControls.ui
+ src/internal/QmitkBrainExtractionViewControls.ui
)
set(MOC_H_FILES
src/internal/mitkPluginActivator.h
src/internal/QmitkPreprocessingView.h
+ src/internal/QmitkBrainExtractionView.h
)
set(CACHED_RESOURCE_FILES
plugin.xml
resources/preprocessing.png
resources/dwi2.png
)
set(QRC_FILES
)
set(CPP_FILES )
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/plugin.xml b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/plugin.xml
index f19813d57d..c441b6d060 100644
--- a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/plugin.xml
@@ -1,17 +1,25 @@
-
+
+
+
-
+
diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionView.cpp
new file mode 100644
index 0000000000..d9d4475c43
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionView.cpp
@@ -0,0 +1,149 @@
+/*===================================================================
+
+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.
+
+===================================================================*/
+
+//misc
+#define _USE_MATH_DEFINES
+#include
+
+// Blueberry
+#include
+#include
+
+// Qmitk
+#include "QmitkBrainExtractionView.h"
+
+// MITK
+#include
+
+// Qt
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define _USE_MATH_DEFINES
+#include
+
+const std::string QmitkBrainExtractionView::VIEW_ID = "org.mitk.views.brainextraction";
+
+QmitkBrainExtractionView::QmitkBrainExtractionView()
+ : QmitkAbstractView()
+ , m_Controls( 0 )
+ , m_DiffusionImage( nullptr )
+{
+
+}
+
+// Destructor
+QmitkBrainExtractionView::~QmitkBrainExtractionView()
+{
+}
+
+void QmitkBrainExtractionView::CreateQtPartControl( QWidget *parent )
+{
+ // build up qt view, unless already done
+ if ( !m_Controls )
+ {
+ // create GUI widgets from the Qt Designer's .ui file
+ m_Controls = new Ui::QmitkBrainExtractionViewControls;
+ m_Controls->setupUi( parent );
+ connect( m_Controls->m_ImageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateGUI()) );
+ connect( m_Controls->m_StartButton, SIGNAL(clicked()), this, SLOT(StartBrainExtraction()) );
+ this->m_Parent = parent;
+
+ m_Controls->m_ImageBox->SetDataStorage(this->GetDataStorage());
+ mitk::NodePredicateDimension::Pointer dimPred = mitk::NodePredicateDimension::New(3);
+ mitk::TNodePredicateDataType::Pointer isImagePredicate = mitk::TNodePredicateDataType::New();
+ m_Controls->m_ImageBox->SetPredicate(mitk::NodePredicateAnd::New(isImagePredicate,dimPred));
+
+ UpdateGUI();
+
+ std::string module_library_full_path = us::GetModuleContext()->GetModule()->GetLocation();
+ std::string library_file;
+ itksys::SystemTools::SplitProgramPath(module_library_full_path, m_ModulePath, library_file);
+ }
+}
+
+void QmitkBrainExtractionView::OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList& )
+{
+}
+
+void QmitkBrainExtractionView::UpdateGUI()
+{
+ if (m_Controls->m_ImageBox->GetSelectedNode().IsNotNull())
+ m_Controls->m_StartButton->setEnabled(true);
+ else
+ m_Controls->m_StartButton->setEnabled(false);
+}
+
+void QmitkBrainExtractionView::SetFocus()
+{
+ UpdateGUI();
+ m_Controls->m_StartButton->setFocus();
+}
+
+void QmitkBrainExtractionView::StartBrainExtraction()
+{
+ mitk::DataNode::Pointer node = m_Controls->m_ImageBox->GetSelectedNode();
+ mitk::Image::Pointer mitk_image = dynamic_cast(node->GetData());
+
+ us::ModuleContext* context = us::GetModuleContext();
+ us::ServiceReference m_PythonServiceRef = context->GetServiceReference();
+ mitk::IPythonService* m_PythonService = dynamic_cast ( context->GetService(m_PythonServiceRef) );
+ mitk::IPythonService::ForceLoadModule();
+
+ m_PythonService->Execute("import SimpleITK as sitk");
+ m_PythonService->Execute("import SimpleITK._SimpleITK as _SimpleITK");
+ m_PythonService->Execute("import numpy");
+ m_PythonService->CopyToPythonAsSimpleItkImage( mitk_image, "in_image");
+ m_PythonService->Execute("model=\""+m_ModulePath+"/brain_extraction_model.model\"");
+ m_PythonService->ExecuteScript(m_ModulePath + "/brain_extraction_script.py");
+
+ {
+ mitk::Image::Pointer image = m_PythonService->CopySimpleItkImageFromPython("brain_mask");
+ mitk::DataNode::Pointer corrected_node = mitk::DataNode::New();
+ corrected_node->SetData( image );
+ QString name(node->GetName().c_str());
+ name += "_BrainMask";
+ corrected_node->SetName(name.toStdString());
+ GetDataStorage()->Add(corrected_node, node);
+ }
+
+ {
+ mitk::Image::Pointer image = m_PythonService->CopySimpleItkImageFromPython("brain_extracted");
+ mitk::DataNode::Pointer corrected_node = mitk::DataNode::New();
+ corrected_node->SetData( image );
+ QString name(node->GetName().c_str());
+ name += "_SkullStripped";
+ corrected_node->SetName(name.toStdString());
+ GetDataStorage()->Add(corrected_node, node);
+ }
+}
diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionView.h b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionView.h
new file mode 100644
index 0000000000..2f8193f297
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionView.h
@@ -0,0 +1,72 @@
+/*===================================================================
+
+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
+#include
+
+#include
+#include "ui_QmitkBrainExtractionViewControls.h"
+#include
+#include
+#include
+
+/*!
+\brief View for diffusion image registration / head motion correction
+*/
+class QmitkBrainExtractionView : public QmitkAbstractView
+{
+
+ // this is needed for all Qt objects that should have a Qt meta-object
+ // (everything that derives from QObject and wants to have signal/slots)
+ Q_OBJECT
+
+public:
+
+ static const std::string VIEW_ID;
+
+ QmitkBrainExtractionView();
+ virtual ~QmitkBrainExtractionView();
+
+ virtual void CreateQtPartControl(QWidget *parent) override;
+ void SetFocus() override;
+
+protected slots:
+
+ void StartBrainExtraction();
+ void UpdateGUI(); ///< update button activity etc. dpending on current datamanager selection
+
+
+protected:
+
+ /// \brief called by QmitkAbstractView when DataManager's selection has changed
+ virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList& nodes) override;
+
+ Ui::QmitkBrainExtractionViewControls* m_Controls;
+
+ mitk::Image::Pointer m_DiffusionImage;
+ std::vector< mitk::DataNode::Pointer > m_SelectedDiffusionNodes;
+
+private:
+
+ void UpdateRegistrationStatus(); ///< update textual status display of the Registration process
+
+ // the Qt parent of our GUI (NOT of this object)
+ QWidget* m_Parent;
+ std::string m_ModulePath;
+
+};
diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionViewControls.ui
new file mode 100644
index 0000000000..22a52561f5
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/QmitkBrainExtractionViewControls.ui
@@ -0,0 +1,88 @@
+
+
+ QmitkBrainExtractionViewControls
+
+
+
+ 0
+ 0
+ 435
+ 744
+
+
+
+ Form
+
+
+ -
+
+
+ false
+
+
+
+
+
+ Start Brain Extraction
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Raised
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ -
+
+
+ Input Image:
+
+
+
+
+
+
+
+
+
+
+ QmitkDataStorageComboBox
+ QComboBox
+ QmitkDataStorageComboBox.h
+
+
+
+
+
diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/mitkPluginActivator.cpp
index cdf7135bad..aafe6330b1 100644
--- a/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/mitkPluginActivator.cpp
+++ b/Plugins/org.mitk.gui.qt.diffusionimaging.preprocessing/src/internal/mitkPluginActivator.cpp
@@ -1,38 +1,44 @@
/*===================================================================
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 "mitkPluginActivator.h"
#include "src/internal/QmitkPreprocessingView.h"
+#include "src/internal/QmitkBrainExtractionView.h"
+#include
+
ctkPluginContext* mitk::PluginActivator::m_Context = nullptr;
+US_INITIALIZE_MODULE
+
ctkPluginContext* mitk::PluginActivator::GetContext()
{
return m_Context;
}
void mitk::PluginActivator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(QmitkPreprocessingView, context)
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkBrainExtractionView, context)
m_Context = context;
}
void mitk::PluginActivator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
m_Context = nullptr;
}