Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkConnectomicsNetwork.h
Go to the documentation of this file.
1 
2 /*===================================================================
3 
4 The Medical Imaging Interaction Toolkit (MITK)
5 
6 Copyright (c) German Cancer Research Center,
7 Division of Medical and Biological Informatics.
8 All rights reserved.
9 
10 This software is distributed WITHOUT ANY WARRANTY; without
11 even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 A PARTICULAR PURPOSE.
13 
14 See LICENSE.txt or http://www.mitk.org for details.
15 
16 ===================================================================*/
17 
18 
19 #ifndef _MITK_ConnectomicsNetwork_H
20 #define _MITK_ConnectomicsNetwork_H
21 
22 #include <MitkConnectomicsExports.h>
23 
24 #include "mitkBaseData.h"
25 
26 #ifndef Q_MOC_RUN
27 #include <boost/graph/adjacency_list.hpp>
28 #endif
29 
30 namespace mitk {
31 
53  class MITKCONNECTOMICS_EXPORT ConnectomicsNetwork : public BaseData
54  {
55  public:
59  struct NetworkNode
60  {
61  int id;
62  std::string label;
63  std::vector< float > coordinates;
64  };
65 
67  struct NetworkEdge
68  {
69  int sourceId;
70  int targetId;
71  int weight; // For now the number of times it was present
72  double edge_weight; // For boost, currently set to 1 by default for unweighted calculations
73  };
74 
76  //typedef boost::adjacency_list< boost::listS, boost::listS, boost::undirectedS, NetworkNode, NetworkEdge > NetworkType;
77  typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, NetworkNode, NetworkEdge > NetworkType;
78  typedef boost::graph_traits<NetworkType>::vertex_descriptor VertexDescriptorType;
79  typedef boost::graph_traits<NetworkType>::edge_descriptor EdgeDescriptorType;
80 
81  // virtual methods that need to be implemented
82  virtual void UpdateOutputInformation() override;
83  virtual void SetRequestedRegionToLargestPossibleRegion() override;
84  virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
85  virtual bool VerifyRequestedRegion() override;
86  virtual void SetRequestedRegion(const itk::DataObject * ) override;
87 
88 
89  // Macros
91  itkFactorylessNewMacro(Self)
92  itkCloneMacro(Self)
93 
95 
96  bool EdgeExists( VertexDescriptorType vertexA, VertexDescriptorType vertexB ) const;
97 
99  void IncreaseEdgeWeight( VertexDescriptorType vertexA, VertexDescriptorType vertexB );
100 
102  void AddEdge( VertexDescriptorType vertexA, VertexDescriptorType vertexB);
103 
105  void AddEdge( VertexDescriptorType vertexA, VertexDescriptorType vertexB, int sourceID, int targetID, int weight = 1, double edge_weight = 1.0 );
106 
108  VertexDescriptorType AddVertex( int id);
109 
111  void SetLabel( VertexDescriptorType vertex, std::string inLabel );
112 
114  void SetCoordinates( VertexDescriptorType vertex, std::vector< float > inCoordinates );
115 
117  void clear();
118 
120  NetworkNode GetNode( VertexDescriptorType vertex ) const;
121 
123  NetworkEdge GetEdge( VertexDescriptorType vertexA, VertexDescriptorType vertexB ) const;
124 
126  std::vector< NetworkNode > GetVectorOfAllNodes() const;
127 
129  std::vector< VertexDescriptorType > GetVectorOfAllVertexDescriptors() const;
130 
132  std::vector< VertexDescriptorType > GetVectorOfAdjacentNodes( VertexDescriptorType vertex ) const;
133 
135  std::vector< std::pair< std::pair< NetworkNode, NetworkNode > , NetworkEdge > > GetVectorOfAllEdges() const;
136 
138  int GetNumberOfVertices() const;
139 
141  int GetNumberOfEdges() const;
142 
144  int GetNumberOfSelfLoops();
145 
147  double GetAverageDegree();
148 
150  double GetConnectionDensity();
151 
153  int GetMaximumWeight() const;
154 
156  std::vector< int > GetDegreeOfNodes( ) const;
157 
159  int GetMaximumDegree() const;
160 
162  std::vector< double > GetLocalClusteringCoefficients( ) const;
163 
165  std::vector< double > GetClusteringCoefficientsByDegree( );
166 
168  double GetGlobalClusteringCoefficient( );
169 
171  std::vector< double > GetNodeBetweennessVector() const;
172 
174  std::vector< double > GetEdgeBetweennessVector() const;
175 
177  bool CheckForLabel( std::string targetLabel ) const;
178 
180  std::vector< double > GetShortestDistanceVectorFromLabel( std::string targetLabel ) const;
181 
183  NetworkType* GetBoostGraph();
184 
186  void SetBoostGraph( NetworkType* newGraph );
187 
188  void ImportNetwort( mitk::ConnectomicsNetwork::Pointer source );
189 
191  bool GetIsModified() const;
192 
194  void SetIsModified( bool );
195 
197  void UpdateBounds( );
198 
200  void PruneUnconnectedSingleNodes();
201 
207  void UpdateIDs();
208 
209  protected:
211  virtual ~ConnectomicsNetwork();
212 
213  NetworkType m_Network;
214 
218 
219  bool m_IsModified;
220 
221  private:
222 
223  };
224 
234  MITKCONNECTOMICS_EXPORT bool Equal( mitk::ConnectomicsNetwork* leftHandSide, mitk::ConnectomicsNetwork* rightHandSide, mitk::ScalarType eps, bool verbose);
235 
236 } // namespace mitk
237 
238 #endif /* _MITK_ConnectomicsNetwork_H */
Base of all data objects.
Definition: mitkBaseData.h:39
double ScalarType
STL namespace.
DataCollection - Class to facilitate loading/accessing structured data.
boost::graph_traits< NetworkType >::edge_descriptor EdgeDescriptorType
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, NetworkNode, NetworkEdge > NetworkType
boost::graph_traits< NetworkType >::vertex_descriptor VertexDescriptorType
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
MITKCORE_EXPORT const ScalarType eps
Connectomics Network Class.