diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.cpp index 9e292dc7b2..871e0857ed 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.cpp @@ -1,368 +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. ===================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkDenoisingView.h" #include #include #include #include #include #include #include #include #include #include #include #include + + const std::string QmitkDenoisingView::VIEW_ID = "org.mitk.views.denoisingview"; QmitkDenoisingView::QmitkDenoisingView() : QmitkFunctionality() , m_Controls( 0 ) , m_MultiWidget( NULL ) - , m_OdfNormalization(0) , m_ImageNode(NULL) { - m_VtkActor = vtkActor::New(); - m_VtkMapper = vtkPolyDataMapper::New(); - m_Renderer = vtkRenderer::New(); - m_VtkRenderWindow = vtkRenderWindow::New(); - m_RenderWindowInteractor = vtkRenderWindowInteractor::New(); - m_Camera = vtkCamera::New(); - m_VtkRenderWindow->SetSize(300,300); } QmitkDenoisingView::~QmitkDenoisingView() { - } void QmitkDenoisingView::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::QmitkDenoisingViewControls; m_Controls->setupUi( parent ); -// m_Controls->m_OdfBox->setVisible(false); -// m_Controls->m_ODFRenderWidget->setVisible(false); } } void QmitkDenoisingView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { - m_MultiWidget = &stdMultiWidget; + //m_MultiWidget = &stdMultiWidget; - { + /*{ mitk::SliceNavigationController* slicer = m_MultiWidget->mitkWidget1->GetSliceNavigationController(); itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction( this, &QmitkDenoisingView::OnSliceChanged ); m_SliceObserverTag1 = slicer->AddObserver( mitk::SliceNavigationController::GeometrySliceEvent(NULL, 0), command ); } { mitk::SliceNavigationController* slicer = m_MultiWidget->mitkWidget2->GetSliceNavigationController(); itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction( this, &QmitkDenoisingView::OnSliceChanged ); m_SliceObserverTag2 = slicer->AddObserver( mitk::SliceNavigationController::GeometrySliceEvent(NULL, 0), command ); } { mitk::SliceNavigationController* slicer = m_MultiWidget->mitkWidget3->GetSliceNavigationController(); itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction( this, &QmitkDenoisingView::OnSliceChanged ); m_SliceObserverTag3 = slicer->AddObserver( mitk::SliceNavigationController::GeometrySliceEvent(NULL, 0), command ); - } + }*/ } + void QmitkDenoisingView::StdMultiWidgetNotAvailable() { - - { + /*{ mitk::SliceNavigationController* slicer = m_MultiWidget->mitkWidget1->GetSliceNavigationController(); slicer->RemoveObserver( m_SliceObserverTag1 ); } { mitk::SliceNavigationController* slicer = m_MultiWidget->mitkWidget2->GetSliceNavigationController(); slicer->RemoveObserver( m_SliceObserverTag2 ); } { mitk::SliceNavigationController* slicer = m_MultiWidget->mitkWidget3->GetSliceNavigationController(); slicer->RemoveObserver( m_SliceObserverTag3 ); - } - - m_MultiWidget = NULL; + }*/ + //m_MultiWidget = NULL; } void QmitkDenoisingView::OnSelectionChanged( std::vector nodes ) { if (m_ImageNode.IsNotNull()) m_ImageNode->RemoveObserver( m_PropertyObserverTag ); m_Controls->m_InputData->setTitle("Please Select Input Data"); m_Controls->m_InputImageLabel->setText("mandatory"); m_ImageNode = NULL; // iterate selection for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) { mitk::DataNode::Pointer node = *it; - if( node.IsNotNull() && (dynamic_cast(node->GetData()) || dynamic_cast(node->GetData())) ) + if( node.IsNotNull() && dynamic_cast(node->GetData())) { m_Controls->m_InputImageLabel->setText(node->GetName().c_str()); m_ImageNode = node; } } - UpdateOdf(); if (m_ImageNode.IsNotNull()) { itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); command->SetCallbackFunction( this, &QmitkDenoisingView::OnSliceChanged ); m_PropertyObserverTag = m_ImageNode->AddObserver( itk::ModifiedEvent(), command ); m_Controls->m_InputData->setTitle("Input Data"); } } -void QmitkDenoisingView::UpdateOdf() -{ - - /*try - { - m_Controls->m_OverviewBox->setVisible(true); - if (m_ImageNode.IsNull() || !m_MultiWidget) - { - m_Controls->m_ODFRenderWidget->setVisible(false); - m_Controls->m_OdfBox->setVisible(false); - m_Controls->m_OverviewBox->setVisible(false); - return; - } - - // restore the input image label ( needed in case the last run resulted into an exception ) - m_Controls->m_InputImageLabel->setText(m_ImageNode->GetName().c_str()); - - // ODF Normalization Property - mitk::OdfNormalizationMethodProperty* nmp = dynamic_cast(m_ImageNode->GetProperty( "Normalization" )); - if(nmp) - m_OdfNormalization = nmp->GetNormalization(); - - m_TemplateOdf = itk::OrientationDistributionFunction::GetBaseMesh(); - m_OdfTransform = vtkSmartPointer::New(); - m_OdfTransform->Identity(); - m_OdfVals = vtkSmartPointer::New(); - m_OdfSource = vtkSmartPointer::New(); - itk::OrientationDistributionFunction odf; - - mitk::Point3D world = m_MultiWidget->GetCrossPosition(); - mitk::Point3D index; - mitk::Image::Pointer img = dynamic_cast(m_ImageNode->GetData()); - unsigned int *img_dimension = img->GetDimensions(); -// img->GetTimeSlicedGeometry()->WorldToIndex(world, index); - - float sum = 0; - float max = itk::NumericTraits::NonpositiveMin(); - float min = itk::NumericTraits::max(); - QString values; - QString overviewText; - - // check if dynamic_cast successfull and if the crosshair position is inside of the geometry of the ODF data - // otherwise possible crash for a scenario with multiple nodes - if (dynamic_cast(m_ImageNode->GetData()) && ( m_ImageNode->GetData()->GetGeometry()->IsInside(world) ) ) - { - m_Controls->m_ODFRenderWidget->setVisible(true); - m_Controls->m_OdfBox->setVisible(true); - - try - { - mitk::QBallImage* qball_image = dynamic_cast< mitk::QBallImage* >( m_ImageNode->GetData() ); - - // get access to the qball image data with explicitely allowing exceptions if memory locked - mitk::ImageReadAccessor readAccess( qball_image, qball_image->GetVolumeData(0), mitk::ImageAccessorBase::ExceptionIfLocked ); - const float* qball_cPtr = static_cast< const float*>(readAccess.GetData()); - - OdfVectorImgType::IndexType ind; - ind[0] = (int)(index[0]+0.5); - ind[1] = (int)(index[1]+0.5); - ind[2] = (int)(index[2]+0.5); - - // pixel size = QBALL_ODFSIZE - // position offset = standard offset - unsigned int offset_to_data = QBALL_ODFSIZE * (ind[2] * img_dimension[1] * img_dimension[0] + ind[1] * img_dimension[0] + ind[0]); - const float *pixel_data = qball_cPtr + offset_to_data; - - for (int i=0; imax) - max = val; - if (val pd = odf.GetDirection(odf.GetPrincipleDiffusionDirection()); - overviewText += "Main Diffusion:\n "+QString::number(pd[0])+"\n "+QString::number(pd[1])+"\n "+QString::number(pd[2])+"\n"; - - m_Controls->m_OdfValuesTextEdit->setText(values); - m_Controls->m_OverviewTextEdit->setVisible(true); - } - catch( mitk::Exception &e ) - { - MITK_WARN << "LOCKED : " << e.what(); - m_Controls->m_ODFRenderWidget->setVisible(false); - m_Controls->m_OdfBox->setVisible(false); - m_Controls->m_OverviewTextEdit->setVisible(false); - - // reset the selection - m_Controls->m_InputImageLabel->setText("Click image to restore rendering!"); - } - } - else if (dynamic_cast(m_ImageNode->GetData())) - { - m_Controls->m_ODFRenderWidget->setVisible(true); - m_Controls->m_OdfBox->setVisible(false); - - - mitk::TensorImage* qball_image = dynamic_cast< mitk::TensorImage*>(m_ImageNode->GetData()); - - // pixel access block - try - { - // get access to the qball image data with explicitely allowing exceptions if memory locked - mitk::ImageReadAccessor readAccess( qball_image, qball_image->GetVolumeData(0), mitk::ImageAccessorBase::ExceptionIfLocked ); - const float* qball_cPtr = static_cast< const float*>(readAccess.GetData()); - - TensorImageType::IndexType ind; - ind[0] = (int)(index[0]+0.5); - ind[1] = (int)(index[1]+0.5); - ind[2] = (int)(index[2]+0.5); - - // 6 - tensorsize - // remaining computation - standard offset - unsigned int offset_to_data = 6 * (ind[2] * img_dimension[1] * img_dimension[0] + ind[1] * img_dimension[0] + ind[0]); - const float *pixel_data = qball_cPtr + offset_to_data; - - float tensorelems[6] = { - *(pixel_data ), - *(pixel_data + 1), - *(pixel_data + 2), - *(pixel_data + 3), - *(pixel_data + 4), - *(pixel_data + 5), - }; - - itk::DiffusionTensor3D tensor(tensorelems); - odf.InitFromTensor(tensor); - - /** Array of eigen-values. */ - /* - typedef itk::FixedArray EigenValuesArrayType; - /** Matrix of eigen-vectors. */ - /* - typedef itk::Matrix MatrixType; - typedef itk::Matrix EigenVectorsMatrixType; - - EigenValuesArrayType eigenValues; - EigenVectorsMatrixType eigenVectors; - - QString pos = QString::number(ind[0])+", "+QString::number(ind[1])+", "+QString::number(ind[2]); - overviewText += "Coordinates: "+pos+"\n"; - overviewText += "FA: "+QString::number(tensor.GetFractionalAnisotropy())+"\n"; - overviewText += "RA: "+QString::number(tensor.GetRelativeAnisotropy())+"\n"; - overviewText += "Trace: "+QString::number(tensor.GetTrace())+"\n"; - tensor.ComputeEigenAnalysis(eigenValues,eigenVectors); - overviewText += "Eigenvalues:\n "+QString::number(eigenValues[2])+"\n "+QString::number(eigenValues[1])+"\n "+QString::number(eigenValues[0])+"\n"; - overviewText += "Main Diffusion:\n "+QString::number(eigenVectors[0][0])+"\n "+QString::number(eigenVectors[1][0])+"\n "+QString::number(eigenVectors[2][0])+"\n"; - overviewText += "Values:\n "+QString::number(tensorelems[0])+"\n "+QString::number(tensorelems[1])+"\n "+QString::number(tensorelems[2])+"\n "+QString::number(tensorelems[3])+"\n "+QString::number(tensorelems[4])+"\n "+QString::number(tensorelems[5])+"\n "+"\n"; - m_Controls->m_OverviewTextEdit->setVisible(true); - } - // end pixel access block - catch(mitk::Exception &e ) - { - MITK_WARN << "LOCKED : " << e.what(); - m_Controls->m_ODFRenderWidget->setVisible(false); - m_Controls->m_OdfBox->setVisible(false); - m_Controls->m_OverviewTextEdit->setVisible(false); - - // reset the selection - m_Controls->m_InputImageLabel->setText("Click image to restore rendering!"); - } - } - else - { - m_Controls->m_ODFRenderWidget->setVisible(false); - m_Controls->m_OdfBox->setVisible(false); - overviewText += "Please reinit image geometry.\n"; - } - - // proceed only if the render widget is visible which indicates that the - // predecessing computations were successfull - if( m_Controls->m_ODFRenderWidget->isVisible() ) - { - m_Controls->m_ODFDetailsWidget->SetParameters(odf); - - switch(m_OdfNormalization) - { - case 0: - odf = odf.MinMaxNormalize(); - break; - case 1: - odf = odf.MaxNormalize(); - break; - case 2: - odf = odf.MaxNormalize(); - break; - default: - odf = odf.MinMaxNormalize(); - } - - m_Controls->m_ODFRenderWidget->GenerateODF(odf); - m_Controls->m_OverviewTextEdit->setText(overviewText.toStdString().c_str()); - } - } - catch(...) - { - QMessageBox::critical(0, "Error", "Data could not be analyzed. The image might be corrupted."); - }*/ -} - +/** +* +* ist das Interessant für mich? +* +**/ void QmitkDenoisingView::OnSliceChanged(const itk::EventObject& /*e*/) { - UpdateOdf(); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.h index 27e67c36c5..b825dd4669 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.h +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingView.h @@ -1,114 +1,105 @@ /*=================================================================== 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. ===================================================================*/ #ifndef _QMITKQmitkDenoisingView_H_INCLUDED #define _QMITKQmitkDenoisingView_H_INCLUDED #include +#include + #include #include "ui_QmitkDenoisingViewControls.h" #include #include -#include #include #include #include #include #include #include #include #include #include #include #include +#include + +// + /*! \brief View displaying details of the orientation distribution function in the voxel at the current crosshair position. \sa QmitkFunctionality \ingroup Functionalities */ - -class QmitkDenoisingView : public QmitkFunctionality +//template +class QmitkDenoisingView : public QmitkFunctionality//, public mitk::DiffusionImageSource< DiffusionPixelType > { // 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; QmitkDenoisingView(); virtual ~QmitkDenoisingView(); - typedef float TOdfPixelType; +/* typedef float TOdfPixelType; typedef itk::Vector OdfVectorType; typedef itk::Image OdfVectorImgType; typedef itk::DiffusionTensor3D< TOdfPixelType > TensorPixelType; - typedef itk::Image< TensorPixelType, 3 > TensorImageType; + typedef itk::Image< TensorPixelType, 3 > TensorImageType;*/ + typedef short DiffusionPixelType; + typedef mitk::DiffusionImage< DiffusionPixelType > DiffusionImageType; virtual void CreateQtPartControl(QWidget *parent); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); void OnSliceChanged(const itk::EventObject& e); protected slots: protected: /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( std::vector nodes ); void UpdateOdf(); ///< called if slice position or datamanager selection has changed Ui::QmitkDenoisingViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; - /** observer flags */ + + mitk::DataNode::Pointer m_ImageNode; + int m_SliceObserverTag1; int m_SliceObserverTag2; int m_SliceObserverTag3; int m_PropertyObserverTag; - - /** ODF related variables like mesh structure, values etc. */ - vtkPolyData* m_TemplateOdf; ///< spherical base mesh - vtkSmartPointer m_OdfTransform; - vtkSmartPointer m_OdfVals; - vtkSmartPointer m_OdfSource; - - int m_OdfNormalization; ///< normalization method defined in the visualization view - - /** rendering of the ODF */ - vtkActor* m_VtkActor; - vtkPolyDataMapper* m_VtkMapper; - vtkRenderer* m_Renderer; - vtkRenderWindow* m_VtkRenderWindow; - vtkRenderWindowInteractor* m_RenderWindowInteractor; - vtkCamera* m_Camera; - - mitk::DataNode::Pointer m_ImageNode; }; #endif // _QmitkDenoisingView_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingViewControls.ui index 8de64767c7..372fa09d59 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingViewControls.ui +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkDenoisingViewControls.ui @@ -1,183 +1,144 @@ QmitkDenoisingViewControls 0 0 351 734 0 0 QmitkTemplate 6 9 9 9 9 Please Select Input Data DWI: <html><head/><body><p><span style=" color:#ff0000;">mandatory</span></p></body></html> true Parameters Apply Parameter 2 Qt::Horizontal 40 20 Parameter 1 Parameter 3 - - - - - 0 - 0 - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - Qt::Vertical QSizePolicy::Expanding 20 220