diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake
index 1221a5b610..11ea4a277a 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/files.cmake
@@ -1,72 +1,76 @@
SET(SRC_CPP_FILES
QmitkODFDetailsWidget.cpp
QmitkODFRenderWidget.cpp
)
SET(INTERNAL_CPP_FILES
mitkPluginActivator.cpp
QmitkQBallReconstructionView.cpp
QmitkPreprocessingView.cpp
QmitkDiffusionDicomImportView.cpp
QmitkDiffusionQuantificationView.cpp
QmitkTensorReconstructionView.cpp
QmitkDiffusionImagingPublicPerspective.cpp
QmitkControlVisualizationPropertiesView.cpp
QmitkODFDetailsView.cpp
+ QmitkGlobalFiberTrackingView.cpp
)
SET(UI_FILES
src/internal/QmitkQBallReconstructionViewControls.ui
src/internal/QmitkPreprocessingViewControls.ui
src/internal/QmitkDiffusionDicomImportViewControls.ui
src/internal/QmitkDiffusionQuantificationViewControls.ui
src/internal/QmitkTensorReconstructionViewControls.ui
src/internal/QmitkControlVisualizationPropertiesViewControls.ui
src/internal/QmitkODFDetailsViewControls.ui
+ src/internal/QmitkGlobalFiberTrackingViewControls.ui
)
SET(MOC_H_FILES
src/internal/mitkPluginActivator.h
src/internal/QmitkQBallReconstructionView.h
src/internal/QmitkPreprocessingView.h
src/internal/QmitkDiffusionDicomImportView.h
src/internal/QmitkDiffusionImagingPublicPerspective.h
src/internal/QmitkDiffusionQuantificationView.h
src/internal/QmitkTensorReconstructionView.h
src/internal/QmitkControlVisualizationPropertiesView.h
src/internal/QmitkODFDetailsView.h
src/QmitkODFRenderWidget.h
src/QmitkODFDetailsWidget.h
+ src/internal/QmitkGlobalFiberTrackingView.h
)
SET(CACHED_RESOURCE_FILES
# list of resource files which can be used by the plug-in
# system without loading the plug-ins shared library,
# for example the icon used in the menu and tabs for the
# plug-in views in the workbench
plugin.xml
resources/preprocessing.png
resources/dwiimport.png
resources/quantification.png
resources/reconodf.png
resources/recontensor.png
resources/vizControls.png
- resources/odf.png
+ resources/OdfDetails.png
+ resources/GlobalTracking.png
)
SET(QRC_FILES
# uncomment the following line if you want to use Qt resources
resources/QmitkDiffusionImaging.qrc
)
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/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml
index e75f2c811b..fe30ab1d8a 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/plugin.xml
@@ -1,61 +1,68 @@
+ icon="resources/OdfDetails.png" />
+
+
+
+
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/GlobalTracking.png b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/GlobalTracking.png
new file mode 100644
index 0000000000..d875ea96bd
Binary files /dev/null and b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/GlobalTracking.png differ
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/OdfDetails.png b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/OdfDetails.png
new file mode 100644
index 0000000000..c1eff6a986
Binary files /dev/null and b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/OdfDetails.png differ
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingView.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingView.cpp
new file mode 100644
index 0000000000..30e297870c
--- /dev/null
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingView.cpp
@@ -0,0 +1,699 @@
+/*=========================================================================
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+// Blueberry
+#include
+#include
+
+// Qmitk
+#include "QmitkGlobalFiberTrackingView.h"
+#include
+
+// Qt
+#include
+#include
+#include
+
+// MITK
+#include
+#include
+#include
+#include
+
+// ITK
+#include
+#include
+
+// MISC
+#include
+
+
+QmitkTrackingWorker::QmitkTrackingWorker(QmitkGlobalFiberTrackingView* view)
+ : m_View(view)
+{
+
+}
+
+void QmitkTrackingWorker::run()
+{
+ MITK_INFO << "Resampling mask images";
+ // setup resampler
+ typedef itk::ResampleImageFilter ResamplerType;
+ ResamplerType::Pointer resampler = ResamplerType::New();
+ resampler->SetOutputSpacing( m_View->m_ItkQBallImage->GetSpacing() );
+ resampler->SetOutputOrigin( m_View->m_ItkQBallImage->GetOrigin() );
+ resampler->SetOutputDirection( m_View->m_ItkQBallImage->GetDirection() );
+ resampler->SetSize( m_View->m_ItkQBallImage->GetLargestPossibleRegion().GetSize() );
+
+ // resample mask image
+ resampler->SetInput( m_View->m_MaskImage );
+ resampler->SetDefaultPixelValue(0);
+ resampler->Update();
+ m_View->m_MaskImage = resampler->GetOutput();
+
+ m_View->m_GlobalTracker = QmitkGlobalFiberTrackingView::GlobalTrackingFilterType::New();
+ m_View->m_GlobalTracker->SetInput0(m_View->m_ItkQBallImage.GetPointer());
+ m_View->m_GlobalTracker->SetMaskImage(m_View->m_MaskImage);
+ m_View->m_GlobalTracker->SetTempStart((float)m_View->m_Controls->m_StartTempSlider->value()/100);
+ m_View->m_GlobalTracker->SetTempEnd((float)m_View->m_Controls->m_EndTempSlider->value()/10000);
+ m_View->m_GlobalTracker->SetNumIt(m_View->m_Iterations);
+ m_View->m_GlobalTracker->SetParticleWeight((float)m_View->m_Controls->m_ParticleWeightSlider->value()/10000);
+ m_View->m_GlobalTracker->SetSubtractMean(m_View->m_Controls->m_MeanSubtractionCheckbox->isChecked());
+ m_View->m_GlobalTracker->SetParticleWidth((float)(m_View->m_Controls->m_ParticleWidthSlider->value())/10);
+ m_View->m_GlobalTracker->SetParticleLength((float)(m_View->m_Controls->m_ParticleLengthSlider->value())/10);
+ m_View->m_GlobalTracker->SetInexBalance((float)m_View->m_Controls->m_InExBalanceSlider->value()/10);
+ m_View->m_GlobalTracker->SetFiberLength(m_View->m_Controls->m_FiberLengthSlider->value());
+
+ m_View->m_GlobalTracker->Update();
+ m_View->m_TrackingThread.quit();
+}
+
+const std::string QmitkGlobalFiberTrackingView::VIEW_ID =
+"org.mitk.views.globalfibertracking";
+
+QmitkGlobalFiberTrackingView::QmitkGlobalFiberTrackingView()
+ : QmitkFunctionality()
+ , m_Controls( 0 )
+ , m_MultiWidget( NULL )
+ , m_ThreadIsRunning(false)
+ , m_GlobalTracker(NULL)
+ , m_QBallImage(NULL)
+ , m_MaskImage(NULL)
+ , m_QBallImageNode(NULL)
+ , m_ItkQBallImage(NULL)
+ , m_FiberBundleNode(NULL)
+ , m_TrackingWorker(this)
+ , m_QBallSelected(false)
+ , m_FibSelected(false)
+ , m_Iterations(10000000)
+ , m_LastStep(0)
+{
+ m_TrackingWorker.moveToThread(&m_TrackingThread);
+ connect(&m_TrackingThread, SIGNAL(started()), this, SLOT(BeforeThread()));
+ connect(&m_TrackingThread, SIGNAL(started()), &m_TrackingWorker, SLOT(run()));
+ connect(&m_TrackingThread, SIGNAL(finished()), this, SLOT(AfterThread()));
+ connect(&m_TrackingThread, SIGNAL(terminated()), this, SLOT(AfterThread()));
+ m_TrackingTimer = new QTimer(this);
+}
+
+QmitkGlobalFiberTrackingView::~QmitkGlobalFiberTrackingView()
+{
+ delete m_TrackingTimer;
+}
+
+// update tracking status and generate fiber bundle
+void QmitkGlobalFiberTrackingView::TimerUpdate()
+{
+ mitk::ProgressBar::GetInstance()->Progress(m_GlobalTracker->GetCurrentStep()-m_LastStep);
+ m_LastStep = m_GlobalTracker->GetCurrentStep();
+ UpdateTrackingStatus();
+ GenerateFiberBundle();
+}
+
+// tell global tractography filter to stop after current step
+void QmitkGlobalFiberTrackingView::StopGlobalTracking()
+{
+ if (m_GlobalTracker.IsNull())
+ return;
+ m_GlobalTracker->SetAbortTracking(true);
+ m_Controls->m_GlobalTrackingStop->setEnabled(false);
+ m_Controls->m_GlobalTrackingStop->setText("Stopping Tractography ...");
+}
+
+// update gui elements and generate fiber bundle after tracking is finished
+void QmitkGlobalFiberTrackingView::AfterThread()
+{
+ m_ThreadIsRunning = false;
+ m_TrackingTimer->stop();
+
+ UpdateGUI();
+ UpdateTrackingStatus();
+ GenerateFiberBundle();
+}
+
+// start tracking timer and update gui elements before tracking is started
+void QmitkGlobalFiberTrackingView::BeforeThread()
+{
+ m_ThreadIsRunning = true;
+ m_TrackingTime = QTime::currentTime();
+ m_ElapsedTime = 0;
+ m_TrackingTimer->start(1000);
+
+ UpdateGUI();
+}
+
+// setup gui elements and signal/slot connections
+void QmitkGlobalFiberTrackingView::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::QmitkGlobalFiberTrackingViewControls;
+ m_Controls->setupUi( parent );
+
+ AdvancedSettings();
+
+ connect( m_TrackingTimer, SIGNAL(timeout()), this, SLOT(TimerUpdate()) );
+ connect( m_Controls->m_GlobalTrackingStop, SIGNAL(clicked()), this, SLOT(StopGlobalTracking()) );
+ connect( m_Controls->m_GlobalTrackingStart, SIGNAL(clicked()), this, SLOT(StartGlobalTracking()) );
+ connect( m_Controls->m_SetMaskButton, SIGNAL(clicked()), this, SLOT(SetMask()) );
+ connect( m_Controls->m_AdvancedSettingsCheckbox, SIGNAL(clicked()), this, SLOT(AdvancedSettings()) );
+ connect( m_Controls->m_SaveTrackingParameters, SIGNAL(clicked()), this, SLOT(SaveTrackingParameters()) );
+ connect( m_Controls->m_LoadTrackingParameters, SIGNAL(clicked()), this, SLOT(LoadTrackingParameters()) );
+ connect( m_Controls->m_IterationsSlider, SIGNAL(valueChanged(int)), this, SLOT(SetIterations(int)) );
+ connect( m_Controls->m_ParticleWidthSlider, SIGNAL(valueChanged(int)), this, SLOT(SetParticleWidth(int)) );
+ connect( m_Controls->m_ParticleLengthSlider, SIGNAL(valueChanged(int)), this, SLOT(SetParticleLength(int)) );
+ connect( m_Controls->m_InExBalanceSlider, SIGNAL(valueChanged(int)), this, SLOT(SetInExBalance(int)) );
+ connect( m_Controls->m_FiberLengthSlider, SIGNAL(valueChanged(int)), this, SLOT(SetFiberLength(int)) );
+ connect( m_Controls->m_ParticleWeightSlider, SIGNAL(valueChanged(int)), this, SLOT(SetParticleWeight(int)) );
+ connect( m_Controls->m_StartTempSlider, SIGNAL(valueChanged(int)), this, SLOT(SetStartTemp(int)) );
+ connect( m_Controls->m_EndTempSlider, SIGNAL(valueChanged(int)), this, SLOT(SetEndTemp(int)) );
+ }
+}
+
+void QmitkGlobalFiberTrackingView::SetInExBalance(int value)
+{
+ m_Controls->m_InExBalanceLabel->setText(QString::number((float)value/10));
+}
+
+void QmitkGlobalFiberTrackingView::SetFiberLength(int value)
+{
+ m_Controls->m_FiberLengthLabel->setText(QString::number(value));
+}
+
+void QmitkGlobalFiberTrackingView::SetParticleWeight(int value)
+{
+ m_Controls->m_ParticleWeightLabel->setText(QString::number((float)value/10000));
+}
+
+void QmitkGlobalFiberTrackingView::SetStartTemp(int value)
+{
+ m_Controls->m_StartTempLabel->setText(QString::number((float)value/100));
+}
+
+void QmitkGlobalFiberTrackingView::SetEndTemp(int value)
+{
+ m_Controls->m_EndTempLabel->setText(QString::number((float)value/10000));
+}
+
+void QmitkGlobalFiberTrackingView::SetParticleWidth(int value)
+{
+ if (value>0)
+ m_Controls->m_ParticleWidthLabel->setText(QString::number((float)value/10)+" mm");
+ else
+ m_Controls->m_ParticleWidthLabel->setText("auto");
+}
+
+void QmitkGlobalFiberTrackingView::SetParticleLength(int value)
+{
+ if (value>0)
+ m_Controls->m_ParticleLengthLabel->setText(QString::number((float)value/10)+" mm");
+ else
+ m_Controls->m_ParticleLengthLabel->setText("auto");
+}
+
+void QmitkGlobalFiberTrackingView::SetIterations(int value)
+{
+ switch(value)
+ {
+ case 0:
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^4");
+ m_Iterations = 10000;
+ break;
+ case 1:
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^4");
+ m_Iterations = 50000;
+ break;
+ case 2:
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^5");
+ m_Iterations = 100000;
+ break;
+ case 3:
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^5");
+ m_Iterations = 500000;
+ break;
+ case 4:
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^6");
+ m_Iterations = 1000000;
+ break;
+ case 5:
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^6");
+ m_Iterations = 5000000;
+ break;
+ case 6:
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^7");
+ m_Iterations = 10000000;
+ break;
+ case 7:
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^7");
+ m_Iterations = 50000000;
+ break;
+ case 8:
+ m_Controls->m_IterationsLabel->setText("10^8");
+ m_Iterations = 100000000;
+ break;
+ case 9:
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^8");
+ m_Iterations = 500000000;
+ break;
+ case 10:
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^9");
+ m_Iterations = 1000000000;
+ break;
+ case 11:
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^9");
+ m_Iterations = 5000000000;
+ break;
+ }
+
+}
+
+void QmitkGlobalFiberTrackingView::StdMultiWidgetAvailable(QmitkStdMultiWidget &stdMultiWidget)
+{
+ m_MultiWidget = &stdMultiWidget;
+}
+
+void QmitkGlobalFiberTrackingView::StdMultiWidgetNotAvailable()
+{
+ m_MultiWidget = NULL;
+}
+
+// called if datamanager selection changes
+void QmitkGlobalFiberTrackingView::OnSelectionChanged( std::vector nodes )
+{
+ m_QBallSelected = false;
+ m_FibSelected = false;
+
+ // iterate all selected objects
+ for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it )
+ {
+ mitk::DataNode::Pointer node = *it;
+
+ if( node.IsNotNull() && dynamic_cast(node->GetData()) )
+ {
+ m_QBallSelected = true;
+ m_QBallImageNode = node;
+ }
+ else if (node.IsNotNull() && dynamic_cast(node->GetData()))
+ {
+ m_FibSelected = true;
+ m_FiberBundleNode = node;
+ }
+ }
+
+ UpdateGUI();
+}
+
+// update gui elements displaying trackings status
+void QmitkGlobalFiberTrackingView::UpdateTrackingStatus()
+{
+ if (m_GlobalTracker.IsNull())
+ return;
+
+ m_ElapsedTime += m_TrackingTime.elapsed()/1000;
+ m_TrackingTime.restart();
+ unsigned long hours = m_ElapsedTime/3600;
+ unsigned long minutes = (m_ElapsedTime%3600)/60;
+ unsigned long seconds = m_ElapsedTime%60;
+
+ m_Controls->m_ProposalAcceptance->setText(QString::number(m_GlobalTracker->GetProposalAcceptance()*100)+"%");
+
+ m_Controls->m_TrackingTimeLabel->setText( QString::number(hours)+QString("h ")+QString::number(minutes)+QString("m ")+QString::number(seconds)+QString("s") );
+ m_Controls->m_NumConnectionsLabel->setText( QString::number(m_GlobalTracker->GetNumConnections()) );
+ m_Controls->m_NumParticlesLabel->setText( QString::number(m_GlobalTracker->GetNumParticles()) );
+ m_Controls->m_CurrentStepLabel->setText( QString::number(100*(float)m_GlobalTracker->GetCurrentStep()/m_GlobalTracker->GetSteps())+"%" );
+ m_Controls->m_AcceptedFibersLabel->setText( QString::number(m_GlobalTracker->GetNumAcceptedFibers()) );
+}
+
+// update gui elements (enable/disable elements and set tooltips)
+void QmitkGlobalFiberTrackingView::UpdateGUI()
+{
+ if (!m_ThreadIsRunning && m_QBallSelected)
+ {
+ m_Controls->m_GlobalTrackingStop->setEnabled(false);
+ m_Controls->m_GlobalTrackingStart->setEnabled(true);
+ m_Controls->m_LoadTrackingParameters->setEnabled(true);
+ m_Controls->m_MaskFrame->setEnabled(true);
+ m_Controls->m_IterationsSlider->setEnabled(true);
+ m_Controls->m_AdvancedFrame->setEnabled(true);
+ m_Controls->m_GlobalTrackingStop->setText("Stop Tractography");
+ m_Controls->m_GlobalTrackingStart->setToolTip("Start tractography. No further change of parameters possible.");
+ m_Controls->m_GlobalTrackingStop->setToolTip("");
+ }
+ else if (!m_ThreadIsRunning)
+ {
+ m_Controls->m_GlobalTrackingStop->setEnabled(false);
+ m_Controls->m_GlobalTrackingStart->setEnabled(false);
+ m_Controls->m_LoadTrackingParameters->setEnabled(true);
+ m_Controls->m_MaskFrame->setEnabled(true);
+ m_Controls->m_IterationsSlider->setEnabled(true);
+ m_Controls->m_AdvancedFrame->setEnabled(true);
+ m_Controls->m_GlobalTrackingStop->setText("Stop Tractography");
+ m_Controls->m_GlobalTrackingStart->setToolTip("No Q-Ball image selected.");
+ m_Controls->m_GlobalTrackingStop->setToolTip("");
+ }
+ else
+ {
+ m_Controls->m_GlobalTrackingStop->setEnabled(true);
+ m_Controls->m_GlobalTrackingStart->setEnabled(false);
+ m_Controls->m_LoadTrackingParameters->setEnabled(false);
+ m_Controls->m_MaskFrame->setEnabled(false);
+ m_Controls->m_IterationsSlider->setEnabled(false);
+ m_Controls->m_AdvancedFrame->setEnabled(false);
+ m_Controls->m_AdvancedFrame->setVisible(false);
+ m_Controls->m_AdvancedSettingsCheckbox->setChecked(false);
+ m_Controls->m_GlobalTrackingStart->setToolTip("Tracking in progress.");
+ m_Controls->m_GlobalTrackingStop->setToolTip("Stop tracking and display results.");
+ }
+}
+
+// show/hide advanced settings frame
+void QmitkGlobalFiberTrackingView::AdvancedSettings()
+{
+ m_Controls->m_AdvancedFrame->setVisible(m_Controls->m_AdvancedSettingsCheckbox->isChecked());
+}
+
+// set mask image data node
+void QmitkGlobalFiberTrackingView::SetMask()
+{
+ std::vector nodes = GetDataManagerSelection();
+ if (nodes.empty())
+ {
+ m_MaskImageNode = NULL;
+ m_Controls->m_MaskImageEdit->setText("N/A");
+ return;
+ }
+
+ for( std::vector::iterator it = nodes.begin();
+ it != nodes.end();
+ ++it )
+ {
+ mitk::DataNode::Pointer node = *it;
+
+ if (node.IsNotNull() && dynamic_cast(node->GetData()))
+ {
+ m_MaskImageNode = node;
+ m_Controls->m_MaskImageEdit->setText(node->GetName().c_str());
+ return;
+ }
+ }
+}
+
+// cast image to float
+template
+void QmitkGlobalFiberTrackingView::CastToFloat(InputImageType* image, mitk::Image::Pointer outImage)
+{
+ typedef itk::CastImageFilter ItkCastFilter;
+ typename ItkCastFilter::Pointer itkCaster = ItkCastFilter::New();
+ itkCaster->SetInput(image);
+ itkCaster->Update();
+ outImage->InitializeByItk(itkCaster->GetOutput());
+ outImage->SetVolume(itkCaster->GetOutput()->GetBufferPointer());
+}
+
+// check for mask and qbi and start tracking thread
+void QmitkGlobalFiberTrackingView::StartGlobalTracking()
+{
+ if(m_ThreadIsRunning)
+ {
+ MITK_WARN("QmitkGlobalFiberTrackingView")<<"Thread already running!";
+ return;
+ }
+
+ if (!m_QBallSelected)
+ {
+ // Nothing selected. Inform the user and return
+ QMessageBox::information( NULL, "Template", "Please load and select a qball image before starting image processing.");
+ return;
+ }
+
+ // a node itself is not very useful, we need its data item (the image)
+ mitk::BaseData* data = m_QBallImageNode->GetData();
+ if (!data)
+ return;
+
+ // test if this data item is an image or not (could also be a surface or something totally different)
+ m_QBallImage = dynamic_cast( data );
+ if (m_QBallImage.IsNull())
+ return;
+
+ // cast qbi to itk
+ m_ItkQBallImage = ItkQBallImgType::New();
+ mitk::CastToItkImage(m_QBallImage, m_ItkQBallImage);
+
+ // mask image found?
+ if(m_Controls->m_MaskImageEdit->text().compare("N/A") != 0)
+ {
+ m_MaskImage = 0;
+ mitk::BaseData* data = m_MaskImageNode->GetData();
+ if (data)
+ {
+ // test if this data item is an image or not (could also be a surface or something totally different)
+ mitk::Image* tmpImage = dynamic_cast( data );
+ if (tmpImage)
+ {
+ mitk::Image::Pointer mitkMaskImg = mitk::Image::New();
+ AccessFixedDimensionByItk_1(tmpImage, CastToFloat, 3, mitkMaskImg);
+ typedef mitk::ImageToItk CastType;
+ CastType::Pointer caster = CastType::New();
+ caster->SetInput(mitkMaskImg);
+ caster->Update();
+ m_MaskImage = caster->GetOutput();
+ }
+ }
+ }
+
+ // if no mask image is selected generate it
+ if( m_MaskImage.IsNull() )
+ {
+ m_MaskImage = MaskImgType::New();
+ m_MaskImage->SetSpacing( m_ItkQBallImage->GetSpacing() ); // Set the image spacing
+ m_MaskImage->SetOrigin( m_ItkQBallImage->GetOrigin() ); // Set the image origin
+ m_MaskImage->SetDirection( m_ItkQBallImage->GetDirection() ); // Set the image direction
+ m_MaskImage->SetLargestPossibleRegion( m_ItkQBallImage->GetLargestPossibleRegion());
+ m_MaskImage->SetBufferedRegion( m_ItkQBallImage->GetLargestPossibleRegion() );
+ m_MaskImage->Allocate();
+
+ itk::ImageRegionIterator it (m_MaskImage, m_MaskImage->GetLargestPossibleRegion() );
+ for (it = it.Begin(); !it.IsAtEnd(); ++it)
+ {
+ it.Set(1);
+ }
+ }
+
+ int steps = m_Iterations/10000;
+ if (steps<10)
+ steps = 10;
+
+ m_LastStep = 0;
+ mitk::ProgressBar::GetInstance()->AddStepsToDo(steps);
+
+ // start worker thread
+ m_TrackingThread.start(QThread::LowestPriority);
+}
+
+// generate mitkFiberBundle from tracking filter output
+void QmitkGlobalFiberTrackingView::GenerateFiberBundle()
+{
+ if (m_GlobalTracker.IsNull() || m_ItkQBallImage.IsNull() || m_QBallImage.IsNull() || (!m_Controls->m_VisualizationCheckbox->isChecked() && m_ThreadIsRunning))
+ return;
+
+ m_FiberBundle = mitk::FiberBundle::New();
+
+ typedef std::vector< itk::Point > FiberTractType;
+ typedef std::vector< FiberTractType > FiberBundleType;
+
+ FiberBundleType* fiberBundle = m_GlobalTracker->GetFiberBundle();
+
+ for (int i=0; isize(); i++)
+ {
+ FiberTractType* tract = &fiberBundle->at(i);
+ for (int j=0; jsize(); j++)
+ m_FiberBundle->PushPoint(i, tract->at(j));
+ }
+ m_FiberBundle->initFiberGroup();
+
+ float bounds[] = {0,0,0};
+ bounds[0] = m_ItkQBallImage->GetLargestPossibleRegion().GetSize().GetElement(0);
+ bounds[1] = m_ItkQBallImage->GetLargestPossibleRegion().GetSize().GetElement(1);
+ bounds[2] = m_ItkQBallImage->GetLargestPossibleRegion().GetSize().GetElement(2);
+ m_FiberBundle->SetBounds(bounds);
+ m_FiberBundle->SetGeometry(m_QBallImage->GetGeometry());
+
+ if (m_FiberBundleNode.IsNotNull()){
+ GetDefaultDataStorage()->Remove(m_FiberBundleNode);
+ m_FiberBundleNode = 0;
+ }
+ m_FiberBundleNode = mitk::DataNode::New();
+ m_FiberBundleNode->SetData(m_FiberBundle);
+
+ QString name(m_QBallImageNode->GetName().c_str());
+ name += "_FiberBundle";
+ m_FiberBundleNode->SetName(name.toStdString());
+ m_FiberBundleNode->SetVisibility(true);
+
+ if(m_QBallImageNode.IsNull())
+ GetDataStorage()->Add(m_FiberBundleNode);
+ else
+ GetDataStorage()->Add(m_FiberBundleNode, m_QBallImageNode);
+}
+
+// save current tracking paramters as xml file (.gtp)
+void QmitkGlobalFiberTrackingView::SaveTrackingParameters()
+{
+ TiXmlDocument documentXML;
+ TiXmlDeclaration* declXML = new TiXmlDeclaration( "1.0", "", "" );
+ documentXML.LinkEndChild( declXML );
+
+ TiXmlElement* mainXML = new TiXmlElement("global_tracking_parameter_file");
+ mainXML->SetAttribute("file_version", "0.1");
+ documentXML.LinkEndChild(mainXML);
+
+ TiXmlElement* paramXML = new TiXmlElement("parameter_set");
+ paramXML->SetAttribute("iterations", m_Iterations);
+ paramXML->SetAttribute("particle_length", QString::number((float)m_Controls->m_ParticleLengthSlider->value()/10).toStdString());
+ paramXML->SetAttribute("particle_width", QString::number((float)m_Controls->m_ParticleWidthSlider->value()/10).toStdString());
+ paramXML->SetAttribute("particle_weight", QString::number((float)m_Controls->m_ParticleWeightSlider->value()/10000).toStdString());
+ paramXML->SetAttribute("temp_start", QString::number((float)m_Controls->m_StartTempSlider->value()/100).toStdString());
+ paramXML->SetAttribute("temp_end", QString::number((float)m_Controls->m_EndTempSlider->value()/10000).toStdString());
+ paramXML->SetAttribute("inexbalance", QString::number((float)m_Controls->m_InExBalanceSlider->value()/10).toStdString());
+ paramXML->SetAttribute("fiber_length", QString::number(m_Controls->m_FiberLengthSlider->value()).toStdString());
+ mainXML->LinkEndChild(paramXML);
+ QString filename = QFileDialog::getSaveFileName(
+ 0,
+ tr("Save Parameters"),
+ QDir::currentPath()+"/param.gtp",
+ tr("Global Tracking Parameters (*.gtp)") );
+
+ if(filename.isEmpty() || filename.isNull())
+ return;
+ if(!filename.endsWith(".gtp"))
+ filename += ".gtp";
+ documentXML.SaveFile( filename.toStdString() );
+}
+
+void QmitkGlobalFiberTrackingView::UpdateIteraionsGUI(unsigned long iterations)
+{
+ switch(iterations)
+ {
+ case 10000:
+ m_Controls->m_IterationsSlider->setValue(0);
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^4");
+ break;
+ case 50000:
+ m_Controls->m_IterationsSlider->setValue(1);
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^4");
+ break;
+ case 100000:
+ m_Controls->m_IterationsSlider->setValue(2);
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^5");
+ break;
+ case 500000:
+ m_Controls->m_IterationsSlider->setValue(3);
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^5");
+ break;
+ case 1000000:
+ m_Controls->m_IterationsSlider->setValue(4);
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^6");
+ break;
+ case 5000000:
+ m_Controls->m_IterationsSlider->setValue(5);
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^6");
+ break;
+ case 10000000:
+ m_Controls->m_IterationsSlider->setValue(6);
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^7");
+ break;
+ case 50000000:
+ m_Controls->m_IterationsSlider->setValue(7);
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^7");
+ break;
+ case 100000000:
+ m_Controls->m_IterationsSlider->setValue(8);
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^8");
+ break;
+ case 500000000:
+ m_Controls->m_IterationsSlider->setValue(9);
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^8");
+ break;
+ case 1000000000:
+ m_Controls->m_IterationsSlider->setValue(10);
+ m_Controls->m_IterationsLabel->setText("Iterations: 10^9");
+ break;
+ case 5000000000:
+ m_Controls->m_IterationsSlider->setValue(11);
+ m_Controls->m_IterationsLabel->setText("Iterations: 5x10^9");
+ break;
+ }
+}
+
+// load current tracking paramters from xml file (.gtp)
+void QmitkGlobalFiberTrackingView::LoadTrackingParameters()
+{
+ QString filename = QFileDialog::getOpenFileName(0, tr("Load Parameters"), QDir::currentPath(), tr("Global Tracking Parameters (*.gtp)") );
+ if(filename.isEmpty() || filename.isNull())
+ return;
+
+ TiXmlDocument doc( filename.toStdString() );
+ doc.LoadFile();
+
+ TiXmlHandle hDoc(&doc);
+ TiXmlElement* pElem;
+ TiXmlHandle hRoot(0);
+
+ pElem = hDoc.FirstChildElement().Element();
+ hRoot = TiXmlHandle(pElem);
+ pElem = hRoot.FirstChildElement("parameter_set").Element();
+
+ QString iterations(pElem->Attribute("iterations"));
+ m_Iterations = iterations.toULong();
+ UpdateIteraionsGUI(m_Iterations);
+
+ QString particleLength(pElem->Attribute("particle_length"));
+ float pLength = particleLength.toFloat();
+ QString particleWidth(pElem->Attribute("particle_width"));
+ float pWidth = particleWidth.toFloat();
+
+ if (pLength==0)
+ m_Controls->m_ParticleLengthLabel->setText("auto");
+ else
+ m_Controls->m_ParticleLengthLabel->setText(particleLength+" mm");
+ if (pWidth==0)
+ m_Controls->m_ParticleWidthLabel->setText("auto");
+ else
+ m_Controls->m_ParticleWidthLabel->setText(particleWidth+" mm");
+
+ m_Controls->m_ParticleWidthSlider->setValue(pWidth*10);
+ m_Controls->m_ParticleLengthSlider->setValue(pLength*10);
+
+ QString partWeight(pElem->Attribute("particle_weight"));
+ m_Controls->m_ParticleWeightSlider->setValue(partWeight.toFloat()*10000);
+ m_Controls->m_ParticleWeightLabel->setText(partWeight);
+
+ QString startTemp(pElem->Attribute("temp_start"));
+ m_Controls->m_StartTempSlider->setValue(startTemp.toFloat()*100);
+ m_Controls->m_StartTempLabel->setText(startTemp);
+
+ QString endTemp(pElem->Attribute("temp_end"));
+ m_Controls->m_EndTempSlider->setValue(endTemp.toFloat()*10000);
+ m_Controls->m_EndTempLabel->setText(endTemp);
+
+ QString inExBalance(pElem->Attribute("inexbalance"));
+ m_Controls->m_InExBalanceSlider->setValue(inExBalance.toFloat()*10);
+ m_Controls->m_InExBalanceLabel->setText(inExBalance);
+
+
+ QString fiberLength(pElem->Attribute("fiber_length"));
+ m_Controls->m_FiberLengthSlider->setValue(fiberLength.toInt());
+ m_Controls->m_FiberLengthLabel->setText(fiberLength);
+}
+
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingView.h b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingView.h
new file mode 100644
index 0000000000..6669acf79a
--- /dev/null
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingView.h
@@ -0,0 +1,162 @@
+/*=========================================================================
+Program: Medical Imaging & Interaction Toolkit
+Language: C++
+Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $
+Version: $Revision: 21975 $
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef QmitkGlobalFiberTrackingView_h
+#define QmitkGlobalFiberTrackingView_h
+
+#include
+
+#include
+
+#include "ui_QmitkGlobalFiberTrackingViewControls.h"
+
+#include
+#include
+#include
+#include
+#include
+
+class QmitkGlobalFiberTrackingView;
+
+class QmitkTrackingWorker : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ QmitkTrackingWorker(QmitkGlobalFiberTrackingView* view);
+
+public slots:
+
+ void run();
+
+private:
+
+ QmitkGlobalFiberTrackingView* m_View;
+};
+
+/*!
+ \brief QmitkGlobalFiberTrackingView
+
+ \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation.
+
+ \sa QmitkFunctionality
+ \ingroup Functionalities
+*/
+typedef itk::Image< float, 3 > FloatImageType;
+
+namespace itk
+{
+template
+class GlobalTractographyFilter;
+}
+
+class QmitkGlobalFiberTrackingView : public QmitkFunctionality
+{
+ // 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:
+
+ typedef itk::Image MaskImgType;
+
+ typedef itk::Vector OdfVectorType;
+ typedef itk::Image ItkQBallImgType;
+
+ typedef itk::GlobalTractographyFilter GlobalTrackingFilterType;
+
+ static const std::string VIEW_ID;
+
+ QmitkGlobalFiberTrackingView();
+ virtual ~QmitkGlobalFiberTrackingView();
+
+ virtual void CreateQtPartControl(QWidget *parent);
+
+ virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget);
+ virtual void StdMultiWidgetNotAvailable();
+
+signals:
+
+protected slots:
+
+ void StartGlobalTracking();
+ void StopGlobalTracking();
+ void AfterThread();
+ void BeforeThread();
+ void TimerUpdate();
+ void SetMask();
+ void AdvancedSettings();
+ void SaveTrackingParameters();
+ void LoadTrackingParameters();
+ void SetIterations(int value);
+ void SetParticleWidth(int value);
+ void SetParticleLength(int value);
+ void SetInExBalance(int value);
+ void SetFiberLength(int value);
+ void SetParticleWeight(int value);
+ void SetStartTemp(int value);
+ void SetEndTemp(int value);
+
+private:
+
+ // Visualization & GUI
+ void GenerateFiberBundle();
+ void UpdateGUI();
+ void UpdateTrackingStatus();
+
+ /// \brief called by QmitkFunctionality when DataManager's selection has changed
+ virtual void OnSelectionChanged( std::vector nodes );
+
+ template
+ void CastToFloat(InputImageType* image, typename mitk::Image::Pointer outImage);
+
+ void UpdateIteraionsGUI(unsigned long iterations);
+
+ Ui::QmitkGlobalFiberTrackingViewControls* m_Controls;
+ QmitkStdMultiWidget* m_MultiWidget;
+
+ // data objects
+ mitk::FiberBundle::Pointer m_FiberBundle;
+ MaskImgType::Pointer m_MaskImage;
+ mitk::QBallImage::Pointer m_QBallImage;
+ ItkQBallImgType::Pointer m_ItkQBallImage;
+
+ // data nodes
+ mitk::DataNode::Pointer m_QBallImageNode;
+ mitk::DataNode::Pointer m_MaskImageNode;
+ mitk::DataNode::Pointer m_FiberBundleNode;
+
+ // flags etc.
+ bool m_ThreadIsRunning;
+ QTimer* m_TrackingTimer;
+ QTime m_TrackingTime;
+ unsigned long m_ElapsedTime;
+ bool m_QBallSelected;
+ bool m_FibSelected;
+ unsigned long m_Iterations;
+ int m_LastStep;
+
+ // global tracker and friends
+ itk::SmartPointer m_GlobalTracker;
+ QmitkTrackingWorker m_TrackingWorker;
+ QThread m_TrackingThread;
+
+ friend class QmitkTrackingWorker;
+};
+
+#endif // _QMITKGLOBALFIBERTRACKINGVIEW_H_INCLUDED
+
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingViewControls.ui b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingViewControls.ui
new file mode 100644
index 0000000000..7f907bfd2b
--- /dev/null
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkGlobalFiberTrackingViewControls.ui
@@ -0,0 +1,946 @@
+
+
+ QmitkGlobalFiberTrackingViewControls
+
+
+
+ 0
+ 0
+ 463
+ 1011
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ QmitkTemplate
+
+
+
+ 0
+
+
+ 3
+
+
+ 0
+
+
+ 3
+
+
+ 0
+
+ -
+
+
+
+
+
+ false
+
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ true
+
+
+ false
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Raised
+
+
+
+ QFormLayout::AllNonFixedFieldsGrow
+
+
+ 0
+
+
+ 4
+
+
+ 0
+
+
-
+
+
+ Mask Image
+
+
+
+ -
+
+
+ Mask image. Particles will be sampled with a probability according to the voxel value.
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+ 0
+
+
-
+
+
+ true
+
+
+ =>
+
+
+
+ -
+
+
+ true
+
+
+ N/A
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Iterations: 10^7
+
+
+
+ -
+
+
+ true
+
+
+ Visualize Tractography
+
+
+ true
+
+
+
+ -
+
+
+ Advanced Settings
+
+
+
+ -
+
+
+ true
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+ 0
+
+
+ 4
+
+
+ 0
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+ auto
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ auto = 1.5 * min. spacing; l
+
+
+ 100
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ auto
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ auto = 0.5 * min. spacing; sigma
+
+
+ 100
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ 0.001
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ unitless w
+
+
+ 1
+
+
+ 1000
+
+
+ 1
+
+
+ 10
+
+
+ Qt::Horizontal
+
+
+ true
+
+
+ QSlider::NoTicks
+
+
+
+ -
+
+
+ 0.1
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 1
+
+
+ 100
+
+
+ 1
+
+
+ 10
+
+
+ Qt::Horizontal
+
+
+ false
+
+
+ false
+
+
+ QSlider::NoTicks
+
+
+
+ -
+
+
+ 0.001
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ 1
+
+
+ 99
+
+
+ 1
+
+
+ 10
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ IE Bias < 0 < EE Bias
+
+
+ -50
+
+
+ 50
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ 10
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ Only fibers containing more than the specified number of particles are accepted.
+
+
+ 100
+
+
+ 1
+
+
+ 10
+
+
+ Qt::Horizontal
+
+
+ QSlider::NoTicks
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Particle Length:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Particle Width:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Particle Weight:
+
+
+
+ -
+
+
+ Start Temperature:
+
+
+
+ -
+
+
+ End Temperature:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Balance In/Ex Energy:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Min. Fiber Length:
+
+
+
+ -
+
+
+ true
+
+
+ Use mean subtracted ODFs (recommended).
+
+
+ Subtract ODF Mean
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 60
+ 20
+
+
+
+
+
+
+
+ -
+
+
+ true
+
+
+ Save current parameters as xml (.gtp)
+
+
+ Qt::LeftToRight
+
+
+ Save Parameters
+
+
+
+ :/qmitk/btnMoveDown.png:/qmitk/btnMoveDown.png
+
+
+
+ -
+
+
+ true
+
+
+ Load parameters from xml file (.gtp)
+
+
+ Qt::LeftToRight
+
+
+ Load Parameters
+
+
+
+ :/qmitk/btnMoveUp.png:/qmitk/btnMoveUp.png
+
+
+
+ -
+
+
+ Specify number of iterations for the tracking algorithm.
+
+
+ 11
+
+
+ 6
+
+
+ Qt::Horizontal
+
+
+ QSlider::TicksBelow
+
+
+
+ -
+
+
+ false
+
+
+ No Q-Ball image selected.
+
+
+ Qt::LeftToRight
+
+
+ Start Tractography
+
+
+
+ :/qmitk/play.xpm:/qmitk/play.xpm
+
+
+
+ -
+
+
+ false
+
+
+
+
+
+ Qt::LeftToRight
+
+
+ Stop Tractography
+
+
+
+ :/qmitk/stop.xpm:/qmitk/stop.xpm
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+ 0
+
+
+ 7
+
+
+ 0
+
+
-
+
+
+ Will only be updated if tracking is visualized
+
+
+ Will only be updated if tracking is visualized
+
+
+
+
+
+ Accepted Fibers:
+
+
+
+ -
+
+
+ Will only be updated if tracking is visualized
+
+
+
+
+
+
+
+
+ -
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Progress:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Connections:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Particles:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Tracking Time:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ Proposal Acceptance Rate:
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Expanding
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp
index 3413428379..1715b75d19 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/mitkPluginActivator.cpp
@@ -1,38 +1,40 @@
#include "mitkPluginActivator.h"
#include
#include "src/internal/QmitkDiffusionImagingPublicPerspective.h"
#include "src/internal/QmitkQBallReconstructionView.h"
#include "src/internal/QmitkPreprocessingView.h"
#include "src/internal/QmitkDiffusionDicomImportView.h"
#include "src/internal/QmitkDiffusionQuantificationView.h"
#include "src/internal/QmitkTensorReconstructionView.h"
#include "src/internal/QmitkControlVisualizationPropertiesView.h"
#include "src/internal/QmitkODFDetailsView.h"
+#include "src/internal/QmitkGlobalFiberTrackingView.h"
namespace mitk {
void PluginActivator::start(ctkPluginContext* context)
{
BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionImagingPublicPerspective, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkQBallReconstructionView, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkPreprocessingView, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionDicomImport, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkDiffusionQuantificationView, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkTensorReconstructionView, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkControlVisualizationPropertiesView, context)
BERRY_REGISTER_EXTENSION_CLASS(QmitkODFDetailsView, context)
+ BERRY_REGISTER_EXTENSION_CLASS(QmitkGlobalFiberTrackingView, context)
}
void PluginActivator::stop(ctkPluginContext* context)
{
Q_UNUSED(context)
}
}
Q_EXPORT_PLUGIN2(org_mitk_gui_qt_diffusionimaging, mitk::PluginActivator)
diff --git a/Modules/DiffusionImaging/CMakeLists.txt b/Modules/DiffusionImaging/CMakeLists.txt
index 63f18398f3..7766735ede 100644
--- a/Modules/DiffusionImaging/CMakeLists.txt
+++ b/Modules/DiffusionImaging/CMakeLists.txt
@@ -1,20 +1,26 @@
FIND_PACKAGE(ITK)
IF(ITK_GDCM_DIR)
INCLUDE(${ITK_GDCM_DIR}/GDCMConfig.cmake)
IF(GDCM_MAJOR_VERSION EQUAL 2)
ADD_DEFINITIONS(-DGDCM2)
SET(ITK_USES_GDCM2 1)
ENDIF(GDCM_MAJOR_VERSION EQUAL 2)
ENDIF(ITK_GDCM_DIR)
MITK_CREATE_MODULE( MitkDiffusionImaging
SUBPROJECTS MITK-DTI
INCLUDE_DIRS Algorithms DicomImport Interactions IODataStructures/DiffusionWeightedImages IODataStructures/QBallImages IODataStructures/TensorImages IODataStructures/FiberBundle IODataStructures/PlanarFigureComposite IODataStructures Reconstruction Tractography Rendering ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS MitkExt SceneSerializationBase QmitkExt
PACKAGE_DEPENDS Boost
)
+MITK_USE_MODULE(MitkDiffusionImaging)
+if(MitkDiffusionImaging_IS_ENABLED)
+ file(DOWNLOAD http://mitk.org/download/data/FibertrackingLUT.tar.gz ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/FibertrackingLUT.tar.gz TIMEOUT 10)
+ execute_process(COMMAND cmake -E chdir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} tar xzf FibertrackingLUT.tar.gz)
+endif()
+
ADD_SUBDIRECTORY(Testing)
-
+
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mitkDiffusionImagingConfigure.h.in ${CMAKE_CURRENT_BINARY_DIR}/mitkDiffusionImagingConfigure.h)
diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.cpp
new file mode 100644
index 0000000000..d2da8870ee
--- /dev/null
+++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.cpp
@@ -0,0 +1,45 @@
+/*=========================================================================
+ Copyright (c) German Cancer Research Center, Division of Medical and
+ Biological Informatics. All rights reserved.
+ See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+ =========================================================================*/
+
+#include "mitkParticle.h"
+
+namespace mitk
+{
+ Particle::Particle()
+ {
+
+ }
+
+ Particle::~Particle()
+ {
+
+ }
+
+ void Particle::SetDirection(VectorType dir)
+ {
+ this->m_Direction = dir;
+ }
+
+ void Particle::SetPosition(VectorType pos)
+ {
+ this->m_Position = pos;
+ }
+
+ Particle::VectorType Particle::GetDirection()
+ {
+ return this->m_Direction;
+ }
+
+ Particle::VectorType Particle::GetPosition()
+ {
+ return this->m_Position;
+ }
+}
diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.h
new file mode 100644
index 0000000000..d8f5237138
--- /dev/null
+++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkParticle.h
@@ -0,0 +1,51 @@
+
+/*=========================================================================
+ Program: Medical Imaging & Interaction Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision: 11989 $
+
+ Copyright (c) German Cancer Research Center, Division of Medical and
+ Biological Informatics. All rights reserved.
+ See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+ =========================================================================*/
+
+
+#ifndef _MITK_Particle_H
+#define _MITK_Particle_H
+
+#include "mitkBaseData.h"
+#include "MitkDiffusionImagingExports.h"
+
+namespace mitk {
+
+ /**
+ * \brief Base Class for Fiber Segments; */
+ class MitkDiffusionImaging_EXPORT Particle
+ {
+ public:
+ Particle();
+ virtual ~Particle();
+
+ typedef vnl_vector_fixed VectorType;
+
+ void SetDirection(VectorType dir);
+ void SetPosition(VectorType pos);
+
+ VectorType GetPosition();
+ VectorType GetDirection();
+
+ protected:
+ VectorType m_Position; // position
+ VectorType m_Direction; // direction
+ };
+
+} // namespace mitk
+
+#endif /* _MITK_Particle_H */
diff --git a/Modules/DiffusionImaging/Tractography/GlobalTracking/AccumulateBilin.cpp b/Modules/DiffusionImaging/Tractography/GlobalTracking/AccumulateBilin.cpp
new file mode 100644
index 0000000000..1f78d15d7b
--- /dev/null
+++ b/Modules/DiffusionImaging/Tractography/GlobalTracking/AccumulateBilin.cpp
@@ -0,0 +1,87 @@
+#include
+#include "mex.h"
+#include "matrix.h"
+#define REAL float
+
+
+
+
+
+
+
+
+void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
+{
+
+ if(nrhs!=2) {
+ mexPrintf("wrong usage!!\n",nrhs);
+ return;
+ } else if(nlhs>4) {
+ printf("Too many output arguments\n");
+ return;
+ }
+
+ int pcnt = 0;
+ const mxArray *Dim;
+ Dim = prhs[pcnt++];
+ REAL *dim = (REAL*) mxGetData(Dim);
+ int w = (int) dim[0];
+ int h = (int) dim[1];
+ int d = (int) dim[2];
+
+ const mxArray *Pts;
+ Pts = prhs[pcnt++];
+ const int numdim = mxGetNumberOfDimensions(Pts);
+ const int *pdims = mxGetDimensions(Pts);
+ int numPts = pdims[1];
+ REAL *pts = (REAL*) mxGetData(Pts);
+
+
+ int dims[3];
+ dims[0] = w;
+ dims[1] = h;
+ dims[2] = d;
+ plhs[0] = mxCreateNumericArray(3,dims,mxGetClassID(Dim),mxREAL);
+ REAL *accu = (REAL*) mxGetData(plhs[0]);
+
+
+ for (int i = 0; i < numPts; i++)
+ {
+ int idx = 3*i;
+
+ int px = (int) (pts[idx]);
+ if (px < 0 || px >= w-1)
+ continue;
+ int py = (int) (pts[idx+1]);
+ if (py < 0 || py >= h-1)
+ continue;
+ int pz = (int) (pts[idx+2]);
+ if (pz < 0 || pz >= d-1)
+ continue;
+ float frac_x = pts[idx ] - px;
+ float frac_y = pts[idx+1] - py;
+ float frac_z = pts[idx+2] - pz;
+
+
+ accu[px + w*(py+h*pz)] += (1-frac_x)*(1-frac_y)*(1-frac_z);
+
+ accu[px+1 + w*(py+h*pz)] += (frac_x)*(1-frac_y)*(1-frac_z);
+ accu[px + w*(py+1+h*pz)] += (1-frac_x)*(frac_y)*(1-frac_z);
+ accu[px + w*(py+h*pz+h)] += (1-frac_x)*(1-frac_y)*(frac_z);
+
+ accu[px + w*(py+1+h*pz+h)] += (1-frac_x)*(frac_y)*(frac_z);
+ accu[px+1 + w*(py+h*pz+h)] += (frac_x)*(1-frac_y)*(frac_z);
+ accu[px+1 + w*(py+1+h*pz)] += (frac_x)*(frac_y)*(1-frac_z);
+
+ accu[px+1 + w*(py+1+h*pz+h)] += (frac_x)*(frac_y)*(frac_z);
+
+ }
+
+
+}
+
+
+
+
+
+
diff --git a/Modules/DiffusionImaging/Tractography/GlobalTracking/AccumulateBilinWeighted.cpp b/Modules/DiffusionImaging/Tractography/GlobalTracking/AccumulateBilinWeighted.cpp
new file mode 100644
index 0000000000..c60c7c9f6c
--- /dev/null
+++ b/Modules/DiffusionImaging/Tractography/GlobalTracking/AccumulateBilinWeighted.cpp
@@ -0,0 +1,94 @@
+#include
+#include "mex.h"
+#include "matrix.h"
+#define REAL float
+
+
+
+
+
+
+
+
+void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
+{
+
+ if(nrhs!=3) {
+ mexPrintf("wrong usage!!\n",nrhs);
+ return;
+ } else if(nlhs>4) {
+ printf("Too many output arguments\n");
+ return;
+ }
+
+ int pcnt = 0;
+ const mxArray *Dim;
+ Dim = prhs[pcnt++];
+ REAL *dim = (REAL*) mxGetData(Dim);
+ int w = (int) dim[0];
+ int h = (int) dim[1];
+ int d = (int) dim[2];
+
+ const mxArray *Pts;
+ Pts = prhs[pcnt++];
+ const int numdim = mxGetNumberOfDimensions(Pts);
+ const int *pdims = mxGetDimensions(Pts);
+ int numPts = pdims[1];
+ REAL *pts = (REAL*) mxGetData(Pts);
+
+ const mxArray *Weights;
+ Weights = prhs[pcnt++];
+ const int wnumdim = mxGetNumberOfDimensions(Weights);
+ const int *wpdims = mxGetDimensions(Weights);
+ int numW = wpdims[0];
+ REAL *weights = (REAL*) mxGetData(Weights);
+
+
+ int dims[3];
+ dims[0] = w;
+ dims[1] = h;
+ dims[2] = d;
+ plhs[0] = mxCreateNumericArray(3,dims,mxGetClassID(Dim),mxREAL);
+ REAL *accu = (REAL*) mxGetData(plhs[0]);
+
+
+ for (int i = 0; i < numPts; i++)
+ {
+ int idx = 3*i;
+
+ int px = (int) (pts[idx]);
+ if (px < 0 || px >= w-1)
+ continue;
+ int py = (int) (pts[idx+1]);
+ if (py < 0 || py >= h-1)
+ continue;
+ int pz = (int) (pts[idx+2]);
+ if (pz < 0 || pz >= d-1)
+ continue;
+ float frac_x = pts[idx ] - px;
+ float frac_y = pts[idx+1] - py;
+ float frac_z = pts[idx+2] - pz;
+
+
+ accu[px + w*(py+h*pz)] += (1-frac_x)*(1-frac_y)*(1-frac_z) * weights[i];
+
+ accu[px+1 + w*(py+h*pz)] += (frac_x)*(1-frac_y)*(1-frac_z) * weights[i];
+ accu[px + w*(py+1+h*pz)] += (1-frac_x)*(frac_y)*(1-frac_z) * weights[i];
+ accu[px + w*(py+h*pz+h)] += (1-frac_x)*(1-frac_y)*(frac_z) * weights[i];
+
+ accu[px + w*(py+1+h*pz+h)] += (1-frac_x)*(frac_y)*(frac_z) * weights[i];
+ accu[px+1 + w*(py+h*pz+h)] += (frac_x)*(1-frac_y)*(frac_z) * weights[i];
+ accu[px+1 + w*(py+1+h*pz)] += (frac_x)*(frac_y)*(1-frac_z) * weights[i];
+
+ accu[px+1 + w*(py+1+h*pz+h)] += (frac_x)*(frac_y)*(frac_z) * weights[i];
+
+ }
+
+
+}
+
+
+
+
+
+
diff --git a/Modules/DiffusionImaging/Tractography/GlobalTracking/BuildFibres.cpp b/Modules/DiffusionImaging/Tractography/GlobalTracking/BuildFibres.cpp
new file mode 100644
index 0000000000..ebe5243717
--- /dev/null
+++ b/Modules/DiffusionImaging/Tractography/GlobalTracking/BuildFibres.cpp
@@ -0,0 +1,364 @@
+#ifndef _BUILDFIBRES
+#define _BUILDFIBRES
+
+//#include "matrix.h"
+#include
+#include