Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
QmitkImageStatisticsTreeModel.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef QmitkImageStatisticsTreeModel_h
15 #define QmitkImageStatisticsTreeModel_h
16 
18 
19 //MITK
22 
23 #include <mutex>
24 
26 
35 {
36  Q_OBJECT
37 
38 public:
39 
40  QmitkImageStatisticsTreeModel(QObject *parent = nullptr);
42 
43  void SetImageNodes(const std::vector<mitk::DataNode::ConstPointer>& nodes);
44  void SetMaskNodes(const std::vector<mitk::DataNode::ConstPointer>& nodes);
45  void Clear();
46 
48  void SetIgnoreZeroValueVoxel(bool _arg);
50  bool GetIgnoreZeroValueVoxel() const;
51 
53  void SetHistogramNBins(unsigned int nbins);
55  unsigned int GetHistogramNBins() const;
56 
57  Qt::ItemFlags flags(const QModelIndex &index) const override;
58  QVariant data(const QModelIndex &index, int role) const override;
59  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
60  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
61  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
62 
63  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
64  QModelIndex parent(const QModelIndex &child) const override;
65 
66 signals:
67  void dataAvailable();
69  void modelChanged();
70 
71 protected:
72  /*
73  * @brief See 'QmitkAbstractDataStorageModel'
74  */
75  void DataStorageChanged() override;
76  /*
77  * @brief See 'QmitkAbstractDataStorageModel'
78  */
79  void NodePredicateChanged() override;
80  /*
81  * @brief See 'QmitkAbstractDataStorageModel'
82  */
83  void NodeAdded(const mitk::DataNode *node) override;
84  /*
85  * @brief See 'QmitkAbstractDataStorageModel'
86  */
87  void NodeChanged(const mitk::DataNode *node) override;
88  /*
89  * @brief See 'QmitkAbstractDataStorageModel'
90  */
91  void NodeRemoved(const mitk::DataNode *node) override;
92 
93 private:
94  void UpdateByDataStorage();
95 
96  using StatisticsContainerVector = std::vector<mitk::ImageStatisticsContainer::ConstPointer>;
97  /* builds a hierarchical tree model for the image statistics
98  1. Level: Image
99  --> 2. Level: Mask [if exist]
100  --> 3. Level: Timestep [if >1 exist] */
101  void BuildHierarchicalModel();
102 
103  StatisticsContainerVector m_Statistics;
104 
106  std::vector<mitk::DataNode::ConstPointer> m_ImageNodes;
112  std::vector<std::pair<mitk::DataNode::ConstPointer, unsigned int> > m_TimeStepResolvedImageNodes;
114  std::vector<mitk::DataNode::ConstPointer> m_MaskNodes;
116  std::vector<std::pair<mitk::DataNode::ConstPointer, unsigned int>> m_TimeStepResolvedMaskNodes;
117  std::vector<std::string> m_StatisticNames;
118 
119  std::mutex m_Mutex;
120  QmitkImageStatisticsTreeItem *m_RootItem;
121  QVariant m_HeaderFirstColumn;
122 
123  bool m_IgnoreZeroValueVoxel = false;
124  unsigned int m_HistogramNBins = 100;
125 };
126 
127 #endif
QmitkAbstractDataStorageModel::DataStorageChanged
virtual void DataStorageChanged()=0
QmitkImageStatisticsTreeModel
Definition: QmitkImageStatisticsTreeModel.h:34
MitkImageStatisticsUIExports.h
QmitkImageStatisticsTreeItem
Definition: QmitkImageStatisticsTreeItem.h:25
QmitkAbstractDataStorageModel::NodeRemoved
virtual void NodeRemoved(const mitk::DataNode *node)=0
QmitkAbstractDataStorageModel::NodeChanged
virtual void NodeChanged(const mitk::DataNode *node)=0
MITKIMAGESTATISTICSUI_EXPORT
#define MITKIMAGESTATISTICSUI_EXPORT
Definition: MitkImageStatisticsUIExports.h:15
QmitkAbstractDataStorageModel.h
QmitkAbstractDataStorageModel::NodeAdded
virtual void NodeAdded(const mitk::DataNode *node)=0
QmitkAbstractDataStorageModel
Definition: QmitkAbstractDataStorageModel.h:40
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
QmitkAbstractDataStorageModel::NodePredicateChanged
virtual void NodePredicateChanged()=0
mitkImageStatisticsContainer.h