Medical Imaging Interaction Toolkit  2024.06.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: Label instances [if Mask has more then one label]
101  --> 4. Level: Timestep [if >1 exist] */
102  void BuildHierarchicalModel();
103 
104  StatisticsContainerVector m_Statistics;
105 
107  std::vector<mitk::DataNode::ConstPointer> m_ImageNodes;
113  std::vector<std::pair<mitk::DataNode::ConstPointer, unsigned int> > m_TimeStepResolvedImageNodes;
115  std::vector<mitk::DataNode::ConstPointer> m_MaskNodes;
117  std::vector<std::pair<mitk::DataNode::ConstPointer, unsigned int>> m_TimeStepResolvedMaskNodes;
118  std::vector<std::string> m_StatisticNames;
119 
120  std::mutex m_Mutex;
121  std::unique_ptr<QmitkImageStatisticsTreeItem> m_RootItem;
122  QVariant m_HeaderFirstColumn;
123  itk::TimeStamp m_BuildTime;
124 
125  bool m_IgnoreZeroValueVoxel = false;
126  unsigned int m_HistogramNBins = 100;
127 };
128 
129 #endif
QmitkAbstractDataStorageModel::DataStorageChanged
virtual void DataStorageChanged()=0
QmitkImageStatisticsTreeModel
Definition: QmitkImageStatisticsTreeModel.h:34
MitkImageStatisticsUIExports.h
QmitkImageStatisticsTreeItem
Definition: QmitkImageStatisticsTreeItem.h:28
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