Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkMutualInformationMetricView.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 #include "mitkImageAccessByItk.h"
19 #include <itkMutualInformationImageToImageMetric.h>
20 
23 {
24 }
25 
27 {
28 }
29 
31 {
33 }
34 
36 {
37  if (m_MovingImage.IsNotNull())
38  {
39  AccessByItk(m_MovingImage, GetMetric2);
40  return m_MetricObject;
41  }
42  return nullptr;
43 }
44 
45 template <class TPixelType, unsigned int VImageDimension>
46 itk::Object::Pointer QmitkMutualInformationMetricView::GetMetric2(
47  itk::Image<TPixelType, VImageDimension> * /*itkImage1*/)
48 {
49  typedef typename itk::Image<TPixelType, VImageDimension> FixedImageType;
50  typedef typename itk::Image<TPixelType, VImageDimension> MovingImageType;
53  MetricPointer->SetNumberOfSpatialSamples(m_Controls.m_NumberOfSpatialSamplesMutualInformation->text().toInt());
54  MetricPointer->SetFixedImageStandardDeviation(
55  m_Controls.m_FixedImageStandardDeviationMutualInformation->text().toFloat());
56  MetricPointer->SetMovingImageStandardDeviation(
57  m_Controls.m_MovingImageStandardDeviationMutualInformation->text().toFloat());
58  MetricPointer->SetComputeGradient(m_Controls.m_ComputeGradient->isChecked());
59  m_MetricObject = MetricPointer.GetPointer();
60  return MetricPointer.GetPointer();
61 }
62 
64 {
65  itk::Array<double> metricValues;
66  metricValues.SetSize(4);
67  metricValues.fill(0);
68  metricValues[0] = m_Controls.m_ComputeGradient->isChecked();
69  metricValues[1] = m_Controls.m_NumberOfSpatialSamplesMutualInformation->text().toInt();
70  metricValues[2] = m_Controls.m_FixedImageStandardDeviationMutualInformation->text().toFloat();
71  metricValues[3] = m_Controls.m_MovingImageStandardDeviationMutualInformation->text().toFloat();
72  return metricValues;
73 }
74 
75 void QmitkMutualInformationMetricView::SetMetricParameters(itk::Array<double> metricValues)
76 {
77  m_Controls.m_ComputeGradient->setChecked(metricValues[0]);
78  m_Controls.m_NumberOfSpatialSamplesMutualInformation->setText(QString::number(metricValues[1]));
79  m_Controls.m_FixedImageStandardDeviationMutualInformation->setText(QString::number(metricValues[2]));
80  m_Controls.m_MovingImageStandardDeviationMutualInformation->setText(QString::number(metricValues[3]));
81 }
82 
84 {
85  return "MutualInformation";
86 }
87 
89 {
90  m_Controls.setupUi(parent);
91  QValidator *validatorLineEditInput = new QIntValidator(0, 20000000, this);
92  m_Controls.m_NumberOfSpatialSamplesMutualInformation->setValidator(validatorLineEditInput);
93  QValidator *validatorLineEditInputFloat = new QDoubleValidator(0, 20000000, 8, this);
94  m_Controls.m_FixedImageStandardDeviationMutualInformation->setValidator(validatorLineEditInputFloat);
95  m_Controls.m_MovingImageStandardDeviationMutualInformation->setValidator(validatorLineEditInputFloat);
96 }
97 
99 {
100  return true;
101 }
Ui::QmitkMutualInformationMetricControls m_Controls
itk::SmartPointer< Self > Pointer
virtual itk::Array< double > GetMetricParameters() override
virtual void SetMetricParameters(itk::Array< double > metricValues) override
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
MetricType
Unique integer value for every metric.
virtual itk::Object::Pointer GetMetric() override
virtual void SetupUI(QWidget *parent) override
virtual mitk::MetricParameters::MetricType GetMetricType() override
QmitkMutualInformationMetricView(QWidget *parent=nullptr, Qt::WindowFlags f=nullptr)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.