18 #include "itkImageFileReader.h"
19 #include "itkRegularStepGradientDescentOptimizer.h"
21 #include "ui_QmitkBSplineRegistrationViewControls.h"
25 #include <qfiledialog.h>
26 #include <qmessagebox.h>
27 #include <qvalidator.h>
37 : QWidget(parent, f), m_FixedNode(nullptr), m_MovingNode(nullptr)
44 QObject::connect((QObject *)(
m_Controls.m_BrowseDeformationField),
50 SIGNAL(activated(
int)),
52 SLOT(setCurrentIndex(
int)));
67 else if (optimizer == 1)
82 QFileDialog *w =
new QFileDialog(
this,
"Select Deformation Field");
83 w->setFileMode(QFileDialog::ExistingFiles);
84 w->setNameFilter(
"Images (*.mhd)");
85 w->setDirectory(
"G:\\home\\vanbrugg\\testimages\\deformable");
88 if (w->exec() != QDialog::Accepted)
91 cout <<
"Failed to load" << endl;
94 QStringList filenames = w->selectedFiles();
95 QStringList::Iterator it = filenames.begin();
96 if (it != filenames.end())
98 std::string
filename = (*it).toStdString();
100 QString qStr = QString(filename.c_str());
108 reader->SetFileName(
m_Controls.m_DeformationField->text().toStdString());
113 typedef itk::ImageRegionIterator<DeformationFieldType> IteratorType;
114 IteratorType deformIter(deformationField, deformationField->GetRequestedRegion());
116 for (deformIter.GoToBegin(); !deformIter.IsAtEnd(); ++deformIter)
118 std::cout << deformIter.Get() << std::endl;
131 registration->SetSaveResult(
false);
132 registration->SetReferenceImage(fimage);
133 registration->SetInput(mimage);
138 registration->SetNumberOfGridPoints(
m_Controls.m_NumberOfGridNodes->text().toInt());
140 registration->SetUpdateInputImage(
true);
142 if (
m_Controls.m_SaveDeformFieldCheck->isChecked())
145 registration->SetSaveDeformationField(
true);
146 registration->SetDeformationFileName(
m_Controls.m_DeformationField->text().toStdString());
151 registration->Update();
153 catch (itk::ExceptionObject &excpt)
155 QMessageBox::information(
this,
"Registration exception", excpt.GetDescription(), QMessageBox::Ok);
160 if (image.IsNotNull())
166 levWinProp->SetLevelWindow(levelWindow);
178 if (
m_Controls.m_OptimizerSelector->currentText() ==
"LBFGSOptimizer")
186 else if (
m_Controls.m_OptimizerSelector->currentText() ==
"Gradient Descent")
191 m_Controls.m_NumberOfIterationsGradientDescent->text().toInt());
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is NULL, the BaseRenderer-independent PropertyList ...
itk::SmartPointer< Self > Pointer
mitk::DataNode * m_FixedNode
void SetProperty(const std::string &propertyKey, BaseProperty *property)
Set a property in the list/map by value.
Ui::QmitkBSplineRegistrationViewControls m_Controls
virtual void SetData(mitk::BaseData *baseData)
Set the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
QmitkBSplineRegistrationView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
void SelectDeformationField()
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
void PrintDeformationField()
mitk::OptimizerParameters::Pointer m_OptimizerParameters
void HideAllOptimizerFrames()
mitk::DataNode * m_MovingNode
itk::Vector< float, 3 > VectorType
The LevelWindow class Class to store level/window values.
void OptimizerSelected(int optimizer)
void SetMovingNode(mitk::DataNode *movingNode)
void setOptimizerParameters()
itk::ImageFileReader< DeformationFieldType > ImageReaderType
static RenderingManager * GetInstance()
static const std::string filename
Image class for storing images.
void SetAuto(const Image *image, bool tryPicTags=true, bool guessByCentralSlice=true, unsigned selectedComponent=0)
sets level/window to optimize the contrast of the given Image
itk::Image< VectorType, 3 > DeformationFieldType
void SetFixedNode(mitk::DataNode *fixedNode)
void CalculateTransformation()
~QmitkBSplineRegistrationView()
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.
static Pointer New()
Method for creation through the object factory.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.