00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "QmitkTensorReconstructionView.h"
00020 #include "mitkDiffusionImagingConfigure.h"
00021
00022
00023 #include <QMessageBox>
00024
00025
00026 #include "itkTimeProbe.h"
00027
00028
00029 #include "mitkProgressBar.h"
00030 #include "mitkStatusBar.h"
00031
00032 #include "mitkNodePredicateDataType.h"
00033 #include "QmitkDataStorageComboBox.h"
00034 #include "QmitkStdMultiWidget.h"
00035
00036 #include "mitkTeemDiffusionTensor3DReconstructionImageFilter.h"
00037 #include "itkDiffusionTensor3DReconstructionImageFilter.h"
00038 #include "itkTensorImageToDiffusionImageFilter.h"
00039 #include "itkPointShell.h"
00040 #include "itkVector.h"
00041
00042 #include "mitkTensorImage.h"
00043 #include "mitkProperties.h"
00044 #include "mitkDataNodeObject.h"
00045 #include "mitkOdfNormalizationMethodProperty.h"
00046 #include "mitkOdfScaleByProperty.h"
00047 #include "mitkDiffusionImageMapper.h"
00048
00049 #include "berryIStructuredSelection.h"
00050 #include "berryIWorkbenchWindow.h"
00051 #include "berryISelectionService.h"
00052
00053 const std::string QmitkTensorReconstructionView::VIEW_ID =
00054 "org.mitk.views.tensorreconstruction";
00055
00056 #define DI_INFO MITK_INFO("DiffusionImaging")
00057
00058 typedef float TTensorPixelType;
00059
00060 using namespace berry;
00061
00062 struct TrSelListener : ISelectionListener
00063 {
00064
00065 berryObjectMacro(TrSelListener);
00066
00067 TrSelListener(QmitkTensorReconstructionView* view)
00068 {
00069 m_View = view;
00070 }
00071
00072 void DoSelectionChanged(ISelection::ConstPointer selection)
00073 {
00074
00075
00076
00077 m_View->m_CurrentSelection = selection.Cast<const IStructuredSelection>();
00078
00079
00080 if(m_View->m_CurrentSelection)
00081 {
00082 bool foundDwiVolume = false;
00083 bool foundTensorVolume = false;
00084
00085
00086 for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin();
00087 i != m_View->m_CurrentSelection->End(); ++i)
00088 {
00089
00090
00091 if (mitk::DataNodeObject::Pointer nodeObj = i->Cast<mitk::DataNodeObject>())
00092 {
00093 mitk::DataNode::Pointer node = nodeObj->GetDataNode();
00094
00095
00096 if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0)
00097 {
00098 foundDwiVolume = true;
00099 }
00100
00101
00102 if(QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0)
00103 {
00104 foundTensorVolume = true;
00105 }
00106 }
00107 }
00108
00109 m_View->m_Controls->m_ItkReconstruction->setEnabled(foundDwiVolume);
00110 m_View->m_Controls->m_TeemReconstruction->setEnabled(foundDwiVolume);
00111
00112 m_View->m_Controls->m_TensorsToDWIButton->setEnabled(foundTensorVolume);
00113
00114 }
00115 }
00116
00117 void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection)
00118 {
00119
00120 if (part)
00121 {
00122 QString partname(part->GetPartName().c_str());
00123 if(partname.compare("Datamanager")==0)
00124 {
00125
00126
00127 DoSelectionChanged(selection);
00128
00129 }
00130 }
00131 }
00132
00133 QmitkTensorReconstructionView* m_View;
00134 };
00135
00136 QmitkTensorReconstructionView::QmitkTensorReconstructionView()
00137 : QmitkFunctionality(),
00138 m_Controls(NULL),
00139 m_MultiWidget(NULL)
00140 {
00141 }
00142
00143 QmitkTensorReconstructionView::~QmitkTensorReconstructionView()
00144 {
00145 this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener( m_SelListener);
00146 }
00147
00148 void QmitkTensorReconstructionView::CreateQtPartControl(QWidget *parent)
00149 {
00150 if (!m_Controls)
00151 {
00152
00153 m_Controls = new Ui::QmitkTensorReconstructionViewControls;
00154 m_Controls->setupUi(parent);
00155 this->CreateConnections();
00156
00157 m_Controls->m_TensorReconstructionNumberThreadsSpinbox->setValue(8);
00158
00159 QStringList items;
00160 items << "LLS (Linear Least Squares)"
00161 << "MLE (Maximum Likelihood)"
00162 << "NLS (Nonlinear Least Squares)"
00163 << "WLS (Weighted Least Squares)";
00164 m_Controls->m_TensorEstimationTeemEstimationMethodCombo->addItems(items);
00165 m_Controls->m_TensorEstimationTeemEstimationMethodCombo->setCurrentIndex(0);
00166
00167 m_Controls->m_TensorEstimationManualThreashold->setChecked(false);
00168 m_Controls->m_TensorEstimationTeemSigmaEdit->setText("NaN");
00169 m_Controls->m_TensorEstimationTeemNumItsSpin->setValue(1);
00170 m_Controls->m_TensorEstimationTeemFuzzyEdit->setText("0.0");
00171 m_Controls->m_TensorEstimationTeemMinValEdit->setText("1.0");
00172
00173 m_Controls->m_TensorEstimationTeemNumItsLabel_2->setEnabled(true);
00174 m_Controls->m_TensorEstimationTeemNumItsSpin->setEnabled(true);
00175
00176 m_Controls->m_TensorsToDWIBValueEdit->setText("1000");
00177
00178 Advanced1CheckboxClicked();
00179 Advanced2CheckboxClicked();
00180 TeemCheckboxClicked();
00181
00182 #ifndef DIFFUSION_IMAGING_EXTENDED
00183 m_Controls->m_TeemToggle->setVisible(false);
00184 #endif
00185
00186
00187
00188
00189 }
00190
00191 m_SelListener = berry::ISelectionListener::Pointer(new TrSelListener(this));
00192 this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener( m_SelListener);
00193 berry::ISelection::ConstPointer sel(
00194 this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager"));
00195 m_CurrentSelection = sel.Cast<const IStructuredSelection>();
00196 m_SelListener.Cast<TrSelListener>()->DoSelectionChanged(sel);
00197 }
00198
00199 void QmitkTensorReconstructionView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget)
00200 {
00201 berry::ISelection::ConstPointer sel(
00202 this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager"));
00203 m_CurrentSelection = sel.Cast<const IStructuredSelection>();
00204 m_SelListener.Cast<TrSelListener>()->DoSelectionChanged(sel);
00205 m_MultiWidget = &stdMultiWidget;
00206 }
00207
00208 void QmitkTensorReconstructionView::StdMultiWidgetNotAvailable()
00209 {
00210 m_MultiWidget = NULL;
00211 }
00212
00213 void QmitkTensorReconstructionView::CreateConnections()
00214 {
00215 if ( m_Controls )
00216 {
00217 connect( (QObject*)(m_Controls->m_TeemToggle), SIGNAL(clicked()), this, SLOT(TeemCheckboxClicked()) );
00218 connect( (QObject*)(m_Controls->m_ItkReconstruction), SIGNAL(clicked()), this, SLOT(ItkReconstruction()) );
00219 connect( (QObject*)(m_Controls->m_TeemReconstruction), SIGNAL(clicked()), this, SLOT(TeemReconstruction()) );
00220 connect( (QObject*)(m_Controls->m_TensorEstimationTeemEstimationMethodCombo), SIGNAL(currentIndexChanged(int)), this, SLOT(MethodChoosen(int)) );
00221 connect( (QObject*)(m_Controls->m_Advanced1), SIGNAL(clicked()), this, SLOT(Advanced1CheckboxClicked()) );
00222 connect( (QObject*)(m_Controls->m_Advanced2), SIGNAL(clicked()), this, SLOT(Advanced2CheckboxClicked()) );
00223 connect( (QObject*)(m_Controls->m_TensorEstimationManualThreashold), SIGNAL(clicked()), this, SLOT(ManualThresholdClicked()) );
00224 connect( (QObject*)(m_Controls->m_TensorsToDWIButton), SIGNAL(clicked()), this, SLOT(TensorsToDWI()) );
00225 }
00226 }
00227
00228 void QmitkTensorReconstructionView::TeemCheckboxClicked()
00229 {
00230 m_Controls->groupBox_3->setVisible(m_Controls->
00231 m_TeemToggle->isChecked());
00232 }
00233
00234 void QmitkTensorReconstructionView::Advanced1CheckboxClicked()
00235 {
00236 bool check = m_Controls->
00237 m_Advanced1->isChecked();
00238
00239 m_Controls->frame->setVisible(check);
00240 }
00241
00242 void QmitkTensorReconstructionView::Advanced2CheckboxClicked()
00243 {
00244 bool check = m_Controls->
00245 m_Advanced2->isChecked();
00246
00247 m_Controls->frame_2->setVisible(check);
00248 }
00249
00250 void QmitkTensorReconstructionView::ManualThresholdClicked()
00251 {
00252 m_Controls->m_TensorReconstructionThreasholdEdit_2->setEnabled(
00253 m_Controls->m_TensorEstimationManualThreashold->isChecked());
00254 }
00255
00256 void QmitkTensorReconstructionView::Activated()
00257 {
00258 QmitkFunctionality::Activated();
00259 }
00260
00261 void QmitkTensorReconstructionView::Deactivated()
00262 {
00263 QmitkFunctionality::Deactivated();
00264 }
00265
00266 void QmitkTensorReconstructionView::MethodChoosen(int method)
00267 {
00268 m_Controls->m_TensorEstimationTeemNumItsLabel_2->setEnabled(method==3);
00269 m_Controls->m_TensorEstimationTeemNumItsSpin->setEnabled(method==3);
00270 }
00271
00272 void QmitkTensorReconstructionView::ItkReconstruction()
00273 {
00274 Reconstruct(0);
00275 }
00276
00277 void QmitkTensorReconstructionView::TeemReconstruction()
00278 {
00279 Reconstruct(1);
00280 }
00281
00282 void QmitkTensorReconstructionView::Reconstruct(int method)
00283 {
00284 if (m_CurrentSelection)
00285 {
00286 mitk::DataStorage::SetOfObjects::Pointer set =
00287 mitk::DataStorage::SetOfObjects::New();
00288
00289 int at = 0;
00290 for (IStructuredSelection::iterator i = m_CurrentSelection->Begin();
00291 i != m_CurrentSelection->End();
00292 ++i)
00293 {
00294
00295 if (mitk::DataNodeObject::Pointer nodeObj = i->Cast<mitk::DataNodeObject>())
00296 {
00297 mitk::DataNode::Pointer node = nodeObj->GetDataNode();
00298 if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0)
00299 {
00300 set->InsertElement(at++, node);
00301 }
00302 }
00303 }
00304
00305 if(method == 0)
00306 {
00307 ItkTensorReconstruction(set);
00308 }
00309
00310 if(method == 1)
00311 {
00312 TeemTensorReconstruction(set);
00313 }
00314
00315 }
00316 }
00317
00318 void QmitkTensorReconstructionView::ItkTensorReconstruction
00319 (mitk::DataStorage::SetOfObjects::Pointer inImages)
00320 {
00321 try
00322 {
00323 itk::TimeProbe clock;
00324
00325 int nrFiles = inImages->size();
00326 if (!nrFiles) return;
00327
00328 QString status;
00329 mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles);
00330
00331 mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() );
00332 mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() );
00333
00334 std::vector<mitk::DataNode::Pointer> nodes;
00335 while ( itemiter != itemiterend )
00336 {
00337
00338 mitk::DiffusionImage<DiffusionPixelType>* vols =
00339 static_cast<mitk::DiffusionImage<DiffusionPixelType>*>(
00340 (*itemiter)->GetData());
00341
00342 std::string nodename;
00343 (*itemiter)->GetStringProperty("name", nodename);
00344 ++itemiter;
00345
00346
00347 clock.Start();
00348 MBI_INFO << "Tensor reconstruction ";
00349 mitk::StatusBar::GetInstance()->DisplayText(status.sprintf(
00350 "Tensor reconstruction for %s", nodename.c_str()).toAscii());
00351 typedef itk::DiffusionTensor3DReconstructionImageFilter<
00352 DiffusionPixelType, DiffusionPixelType, TTensorPixelType > TensorReconstructionImageFilterType;
00353 TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter =
00354 TensorReconstructionImageFilterType::New();
00355 tensorReconstructionFilter->SetGradientImage( vols->GetDirections(), vols->GetVectorImage() );
00356 tensorReconstructionFilter->SetNumberOfThreads( m_Controls->m_TensorReconstructionNumberThreadsSpinbox->value() );
00357 tensorReconstructionFilter->SetBValue(vols->GetB_Value());
00358 tensorReconstructionFilter->SetThreshold( m_Controls->m_TensorReconstructionThreasholdEdit->text().toFloat() );
00359 tensorReconstructionFilter->Update();
00360 clock.Stop();
00361 MBI_DEBUG << "took " << clock.GetMeanTime() << "s.";
00362
00363
00364 mitk::TensorImage::Pointer image = mitk::TensorImage::New();
00365 image->InitializeByItk( tensorReconstructionFilter->GetOutput() );
00366 image->SetVolume( tensorReconstructionFilter->GetOutput()->GetBufferPointer() );
00367 mitk::DataNode::Pointer node=mitk::DataNode::New();
00368 node->SetData( image );
00369
00370 QString newname;
00371 newname = newname.append(nodename.c_str());
00372 newname = newname.append("_dti");
00373
00374 SetDefaultNodeProperties(node, newname.toStdString());
00375 nodes.push_back(node);
00376
00377 mitk::ProgressBar::GetInstance()->Progress();
00378
00379 }
00380
00381 std::vector<mitk::DataNode::Pointer>::iterator nodeIt;
00382 for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt)
00383 GetDefaultDataStorage()->Add(*nodeIt);
00384
00385 mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii());
00386 m_MultiWidget->RequestUpdate();
00387
00388 }
00389 catch (itk::ExceptionObject &ex)
00390 {
00391 MBI_INFO << ex ;
00392 return ;
00393 }
00394 }
00395
00396
00397
00398 void QmitkTensorReconstructionView::TeemTensorReconstruction
00399 (mitk::DataStorage::SetOfObjects::Pointer inImages)
00400 {
00401 try
00402 {
00403 itk::TimeProbe clock;
00404
00405 int nrFiles = inImages->size();
00406 if (!nrFiles) return;
00407
00408 QString status;
00409 mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles);
00410
00411 mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() );
00412 mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() );
00413
00414 std::vector<mitk::DataNode::Pointer> nodes;
00415 while ( itemiter != itemiterend )
00416 {
00417
00418 mitk::DiffusionImage<DiffusionPixelType>* vols =
00419 static_cast<mitk::DiffusionImage<DiffusionPixelType>*>(
00420 (*itemiter)->GetData());
00421
00422 std::string nodename;
00423 (*itemiter)->GetStringProperty("name", nodename);
00424 ++itemiter;
00425
00426
00427 clock.Start();
00428 MBI_INFO << "Teem Tensor reconstruction ";
00429 mitk::StatusBar::GetInstance()->DisplayText(status.sprintf(
00430 "Teem Tensor reconstruction for %s", nodename.c_str()).toAscii());
00431 typedef mitk::TeemDiffusionTensor3DReconstructionImageFilter<
00432 DiffusionPixelType, TTensorPixelType > TensorReconstructionImageFilterType;
00433 TensorReconstructionImageFilterType::Pointer tensorReconstructionFilter =
00434 TensorReconstructionImageFilterType::New();
00435 tensorReconstructionFilter->SetInput( vols );
00436 if(!m_Controls->m_TensorEstimationTeemSigmaEdit->text().contains(QString("NaN")))
00437 tensorReconstructionFilter->SetSigma( m_Controls->m_TensorEstimationTeemSigmaEdit->text().toFloat() );
00438 switch(m_Controls->m_TensorEstimationTeemEstimationMethodCombo->currentIndex())
00439 {
00440
00441
00442
00443
00444 case 0:
00445 tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsLLS);
00446 break;
00447 case 1:
00448 tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsMLE);
00449 break;
00450 case 2:
00451 tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsNLS);
00452 break;
00453 case 3:
00454 tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsWLS);
00455 break;
00456 default:
00457 tensorReconstructionFilter->SetEstimationMethod(mitk::TeemTensorEstimationMethodsLLS);
00458 }
00459 tensorReconstructionFilter->SetNumIterations( m_Controls->m_TensorEstimationTeemNumItsSpin->value() );
00460 if(m_Controls->m_TensorEstimationManualThreashold->isChecked())
00461 tensorReconstructionFilter->SetConfidenceThreshold( m_Controls->m_TensorReconstructionThreasholdEdit_2->text().toDouble() );
00462 tensorReconstructionFilter->SetConfidenceFuzzyness( m_Controls->m_TensorEstimationTeemFuzzyEdit->text().toFloat() );
00463 tensorReconstructionFilter->SetMinPlausibleValue( m_Controls->m_TensorEstimationTeemMinValEdit->text().toDouble() );
00464 tensorReconstructionFilter->Update();
00465 clock.Stop();
00466 MBI_DEBUG << "took " << clock.GetMeanTime() << "s." ;
00467
00468
00469 mitk::DataNode::Pointer node2=mitk::DataNode::New();
00470 node2->SetData( tensorReconstructionFilter->GetOutputItk() );
00471
00472 QString newname;
00473 newname = newname.append(nodename.c_str());
00474 newname = newname.append("_dtix");
00475
00476 SetDefaultNodeProperties(node2, newname.toStdString());
00477 nodes.push_back(node2);
00478
00479 mitk::ProgressBar::GetInstance()->Progress();
00480
00481 }
00482
00483 std::vector<mitk::DataNode::Pointer>::iterator nodeIt;
00484 for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt)
00485 GetDefaultDataStorage()->Add(*nodeIt);
00486
00487 mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii());
00488 m_MultiWidget->RequestUpdate();
00489
00490 }
00491 catch (itk::ExceptionObject &ex)
00492 {
00493 MBI_INFO << ex ;
00494 return ;
00495 }
00496 }
00497
00498 void QmitkTensorReconstructionView::SetDefaultNodeProperties(mitk::DataNode::Pointer node, std::string name)
00499 {
00500 node->SetProperty( "ShowMaxNumber", mitk::IntProperty::New( 500 ) );
00501 node->SetProperty( "Scaling", mitk::FloatProperty::New( 1.0 ) );
00502 node->SetProperty( "Normalization", mitk::OdfNormalizationMethodProperty::New());
00503 node->SetProperty( "ScaleBy", mitk::OdfScaleByProperty::New());
00504 node->SetProperty( "IndexParam1", mitk::FloatProperty::New(2));
00505 node->SetProperty( "IndexParam2", mitk::FloatProperty::New(1));
00506 node->SetProperty( "visible", mitk::BoolProperty::New( true ) );
00507 node->SetProperty( "VisibleOdfs", mitk::BoolProperty::New( false ) );
00508 node->SetProperty ("layer", mitk::IntProperty::New(100));
00509 node->SetProperty( "DoRefresh", mitk::BoolProperty::New( true ) );
00510
00511
00512 node->SetProperty( "name", mitk::StringProperty::New(name) );
00513 }
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00530
00531
00532
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00549
00550
00551
00553
00554
00555
00556 void QmitkTensorReconstructionView::TensorsToDWI()
00557 {
00558 if (m_CurrentSelection)
00559 {
00560 mitk::DataStorage::SetOfObjects::Pointer set =
00561 mitk::DataStorage::SetOfObjects::New();
00562
00563 int at = 0;
00564 for (IStructuredSelection::iterator i = m_CurrentSelection->Begin();
00565 i != m_CurrentSelection->End();
00566 ++i)
00567 {
00568
00569 if (mitk::DataNodeObject::Pointer nodeObj = i->Cast<mitk::DataNodeObject>())
00570 {
00571 mitk::DataNode::Pointer node = nodeObj->GetDataNode();
00572 if(QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0)
00573 {
00574 set->InsertElement(at++, node);
00575 }
00576 }
00577 }
00578
00579 DoTensorsToDWI(set);
00580 }
00581 }
00582
00583 template<int ndirs>
00584 std::vector<itk::Vector<double,3> > QmitkTensorReconstructionView::MakeGradientList()
00585 {
00586 std::vector<itk::Vector<double,3> > retval;
00587 vnl_matrix_fixed<double, 3, ndirs>* U =
00588 itk::PointShell<ndirs, vnl_matrix_fixed<double, 3, ndirs> >::DistributePointShell();
00589
00590 for(int i=0; i<ndirs;i++)
00591 {
00592 itk::Vector<double,3> v;
00593 v[0] = U->get(0,i); v[1] = U->get(1,i); v[2] = U->get(2,i);
00594 retval.push_back(v);
00595 }
00596 return retval;
00597 }
00598
00599 void QmitkTensorReconstructionView::DoTensorsToDWI
00600 (mitk::DataStorage::SetOfObjects::Pointer inImages)
00601 {
00602 try
00603 {
00604 itk::TimeProbe clock;
00605
00606 int nrFiles = inImages->size();
00607 if (!nrFiles) return;
00608
00609 QString status;
00610 mitk::ProgressBar::GetInstance()->AddStepsToDo(nrFiles);
00611
00612 mitk::DataStorage::SetOfObjects::const_iterator itemiter( inImages->begin() );
00613 mitk::DataStorage::SetOfObjects::const_iterator itemiterend( inImages->end() );
00614
00615 std::vector<mitk::DataNode::Pointer> nodes;
00616 while ( itemiter != itemiterend )
00617 {
00618
00619 std::string nodename;
00620 (*itemiter)->GetStringProperty("name", nodename);
00621
00622 mitk::TensorImage* vol =
00623 static_cast<mitk::TensorImage*>((*itemiter)->GetData());
00624
00625 ++itemiter;
00626
00627 typedef float TTensorPixelType;
00628 typedef itk::DiffusionTensor3D< TTensorPixelType > TensorPixelType;
00629 typedef itk::Image< TensorPixelType, 3 > TensorImageType;
00630
00631
00632 TensorImageType::Pointer itkvol = TensorImageType::New();
00633 mitk::CastToItkImage<TensorImageType>(vol, itkvol);
00634
00635 typedef itk::TensorImageToDiffusionImageFilter<
00636 TTensorPixelType, DiffusionPixelType > FilterType;
00637
00638 FilterType::GradientListType gradientList;
00639
00640 switch(m_Controls->m_TensorsToDWINumDirsSelect->currentIndex())
00641 {
00642 case 0:
00643 gradientList = MakeGradientList<12>();
00644 break;
00645 case 1:
00646 gradientList = MakeGradientList<42>();
00647 break;
00648 case 2:
00649 gradientList = MakeGradientList<92>();
00650 break;
00651 case 3:
00652 gradientList = MakeGradientList<162>();
00653 break;
00654 case 4:
00655 gradientList = MakeGradientList<252>();
00656 break;
00657 case 5:
00658 gradientList = MakeGradientList<362>();
00659 break;
00660 case 6:
00661 gradientList = MakeGradientList<492>();
00662 break;
00663 case 7:
00664 gradientList = MakeGradientList<642>();
00665 break;
00666 case 8:
00667 gradientList = MakeGradientList<812>();
00668 break;
00669 case 9:
00670 gradientList = MakeGradientList<1002>();
00671 break;
00672 default:
00673 gradientList = MakeGradientList<92>();
00674
00675 }
00676
00677 double bVal = m_Controls->m_TensorsToDWIBValueEdit->text().toDouble();
00678
00679
00680 clock.Start();
00681 MBI_INFO << "DWI Estimation ";
00682 mitk::StatusBar::GetInstance()->DisplayText(status.sprintf(
00683 "DWI Estimation for %s", nodename.c_str()).toAscii());
00684 FilterType::Pointer filter = FilterType::New();
00685 filter->SetInput( itkvol );
00686 filter->SetBValue(bVal);
00687 filter->SetGradientList(gradientList);
00688 filter->SetNumberOfThreads(1);
00689 filter->Update();
00690 clock.Stop();
00691 MBI_DEBUG << "took " << clock.GetMeanTime() << "s.";
00692
00693 itk::Vector<double,3> v;
00694 v[0] = 0; v[1] = 0; v[2] = 0;
00695 gradientList.push_back(v);
00696
00697
00698 mitk::DiffusionImage<DiffusionPixelType>::Pointer image = mitk::DiffusionImage<DiffusionPixelType>::New();
00699 image->SetVectorImage( filter->GetOutput() );
00700 image->SetB_Value(bVal);
00701 image->SetDirections(gradientList);
00702 image->InitializeFromVectorImage();
00703 mitk::DataNode::Pointer node=mitk::DataNode::New();
00704 node->SetData( image );
00705
00706 mitk::DiffusionImageMapper<short>::SetDefaultProperties(node);
00707
00708 QString newname;
00709 newname = newname.append(nodename.c_str());
00710 newname = newname.append("_dwi");
00711 node->SetName(newname.toAscii());
00712
00713 nodes.push_back(node);
00714
00715 mitk::ProgressBar::GetInstance()->Progress();
00716
00717 }
00718
00719 std::vector<mitk::DataNode::Pointer>::iterator nodeIt;
00720 for(nodeIt = nodes.begin(); nodeIt != nodes.end(); ++nodeIt)
00721 GetDefaultDataStorage()->Add(*nodeIt);
00722
00723 mitk::StatusBar::GetInstance()->DisplayText(status.sprintf("Finished Processing %d Files", nrFiles).toAscii());
00724 m_MultiWidget->RequestUpdate();
00725
00726 }
00727 catch (itk::ExceptionObject &ex)
00728 {
00729 MBI_INFO << ex ;
00730 return ;
00731 }
00732 }