NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
ImageStatisticsView.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef ImageStatisticsView_h
16 #define ImageStatisticsView_h
17 
18 #include <berryISelectionListener.h>
19 
20 #include <QmitkAbstractView.h>
21 
22 #include "ui_ImageStatisticsViewControls.h"
23 
24 #include <itkMIDASHelper.h>
25 
42 class ImageStatisticsView : public QmitkAbstractView
43 {
44  Q_OBJECT
45 
46  typedef QmitkAbstractView Superclass;
47 
48 public:
49 
52  virtual ~ImageStatisticsView();
53 
54  static const QString VIEW_ID;
55 
56  virtual void CreateQtPartControl(QWidget *parent) override;
57 
59  virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source,
60  const QList<mitk::DataNode::Pointer>& nodes ) override;
61 
63  virtual void OnPreferencesChanged(const berry::IBerryPreferences*) override;
64 
65 protected slots:
66 
67  void OnPerSliceStatsCheckBoxToggled(bool toggled);
68 
69  void OnAxialRadioButtonToggled(bool toggled);
70 
71  void OnSagittalRadioButtonToggled(bool toggled);
72 
73  void OnCoronalRadioButtonToggled(bool toggled);
74 
76  void OnUpdateButtonClicked();
77 
80 
81 protected:
82 
83  virtual void SetFocus() override;
84 
85 private:
86 
88  void Copy();
89 
91  void RetrievePreferenceValues();
92 
94  void EnableControls(bool enabled);
95 
97  bool IsSelectionValid(const QList<mitk::DataNode::Pointer>& nodes);
98 
100  void InitializeTable();
101 
103  void Update(const QList<mitk::DataNode::Pointer>& nodes);
104 
106  template <typename PixelType>
107  QTreeWidgetItem* CreateTableRow(QTreeWidgetItem* parentItem,
108  const QString& value,
109  PixelType min,
110  PixelType max,
111  double mean,
112  double median,
113  double stdDev,
114  unsigned long count,
115  double volume,
116  int sliceIndex = 0);
117 
119  template <typename PixelType, unsigned int VImageDimension>
120  void GetLabelValues(
121  itk::Image<PixelType, VImageDimension>* itkImage,
122  std::set<PixelType>& labels);
123 
124 
126  template <typename PixelType, unsigned int VImageDimension>
127  void GetVoxelVolume(
128  itk::Image<PixelType, VImageDimension>* itkImage,
129  double& volume
130  );
131 
133  template <typename TPixel>
134  void TestMinAndMax(
135  TPixel imageValue,
136  TPixel& min,
137  TPixel& max
138  );
139 
142  template <typename TPixel>
143  void AccumulateData(
144  TPixel imageValue,
145  double& mean,
146  double& s0,
147  double& s1,
148  double& s2,
149  unsigned long& counter
150  );
151 
153  void CalculateMeanAndStdDev(
154  double& mean,
155  double s0,
156  double s1,
157  double s2,
158  double& stdDev,
159  unsigned long counter
160  );
161 
163  template <typename TPixel>
164  void AccumulateValue(
165  TPixel imageValue,
166  TPixel& min,
167  TPixel& max,
168  double& mean,
169  double& s0,
170  double& s1,
171  double& s2,
172  unsigned long& counter,
173  TPixel* imagePixelsCopy
174  );
175 
179  template <typename TPixel1, typename TPixel2>
180  void AccumulateValue(
181  bool invert,
182  TPixel2 valueToCompareMaskAgainst,
183  TPixel1 imageValue,
184  TPixel2 maskValue,
185  TPixel1& min,
186  TPixel1& max,
187  double& mean,
188  double& s0,
189  double& s1,
190  double& s2,
191  unsigned long& counter,
192  TPixel1* imagePixelsCopy
193  );
194 
196  template <typename TPixel, unsigned VImageDimension>
197  void CalculateStats(
198  itk::Image<TPixel, VImageDimension>* itkImage,
199  const itk::ImageRegion<VImageDimension>& region,
200  TPixel& min,
201  TPixel& max,
202  double& mean,
203  double& s0,
204  double& s1,
205  double& s2,
206  double& stdDev,
207  unsigned long& counter,
208  TPixel* imagePixelsCopy,
209  double& median
210  );
211 
216  template <typename TPixel1, typename TPixel2, unsigned int VImageDimension>
217  void CalculateStatsWithMask(
218  itk::Image<TPixel1, VImageDimension>* itkImage,
219  itk::Image<TPixel2, VImageDimension>* itkMask,
220  const itk::ImageRegion<VImageDimension>& region,
221  bool invert,
222  TPixel2 label,
223  TPixel1& min,
224  TPixel1& max,
225  double& mean,
226  double& s0,
227  double& s1,
228  double& s2,
229  double& stdDev,
230  unsigned long& counter,
231  TPixel1* imagePixelsCopy,
232  double& median
233  );
234 
238  template <typename TPixel, unsigned int VImageDimension>
239  void UpdateTable(
240  itk::Image<TPixel, VImageDimension>* itkImage
241  );
242 
246  template <typename TPixel1, unsigned int VImageDimension1, typename TPixel2, unsigned int VImageDimension2>
247  void UpdateTableWithMask(
248  itk::Image<TPixel1, VImageDimension1>* itkImage,
249  itk::Image<TPixel2, VImageDimension2>* itkMask
250  );
251 
252 
254  bool eventFilter(QObject* object, QEvent* event) override;
255 
256  Ui::ImageStatisticsViewControls m_Controls;
257  bool m_AutoUpdate;
258  bool m_RequireSameSizeImage;
259  bool m_AssumeBinary;
260  int m_BackgroundValue;
261  mitk::DataNode::Pointer m_MaskNode;
262  mitk::DataNode::Pointer m_ImageNode;
263  bool m_PerSliceStats;
264  itk::Orientation m_Orientation;
265 
266 };
267 
268 #endif
GLuint counter
Definition: glew.h:2637
void OnUpdateButtonClicked()
Checks to see if there is a valid selection, and if so, triggers Update with the currently selected n...
Definition: ImageStatisticsView.cxx:245
GLenum GLsizei const GLuint GLboolean enabled
Definition: glew.h:2537
Orientation
Definition: itkMIDASHelper.h:35
Provides simple image statistics over an image, or a region of interest.
Definition: ImageStatisticsView.h:42
virtual void SetFocus() override
Definition: ImageStatisticsView.cxx:63
void OnCopyAllButtonClicked()
Selects every row in the table and copies them to the clipboard.
Definition: ImageStatisticsView.cxx:1002
void OnCoronalRadioButtonToggled(bool toggled)
Definition: ImageStatisticsView.cxx:967
ImageStatisticsView()
Definition: ImageStatisticsView.cxx:43
static const QString VIEW_ID
Definition: ImageStatisticsView.h:54
virtual ~ImageStatisticsView()
Definition: ImageStatisticsView.cxx:57
void OnSagittalRadioButtonToggled(bool toggled)
Definition: ImageStatisticsView.cxx:955
GLsizei const GLfloat * value
Definition: glew.h:1833
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
GLuint GLuint GLsizei count
Definition: glew.h:1237
berryObjectMacro(ImageStatisticsView)
GLboolean invert
Definition: glew.h:1406
Provides useful utility functions that could be used in multiple ITK filters.
GLuint GLsizei GLsizei GLchar * label
Definition: glew.h:10629
cl_event event
Definition: glew.h:3231
virtual void OnPreferencesChanged(const berry::IBerryPreferences *) override
BlueBerry's notification about preference changes (e.g. from a preferences dialog).
Definition: ImageStatisticsView.cxx:111
void OnPerSliceStatsCheckBoxToggled(bool toggled)
Definition: ImageStatisticsView.cxx:931
virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList< mitk::DataNode::Pointer > &nodes) override
called by QmitkAbstractView when DataManager's selection has changed
Definition: ImageStatisticsView.cxx:136
virtual void CreateQtPartControl(QWidget *parent) override
Definition: ImageStatisticsView.cxx:69
void OnAxialRadioButtonToggled(bool toggled)
Definition: ImageStatisticsView.cxx:943
GLsizei GLsizei GLchar * source
Definition: glew.h:1816