Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmitkTbssRoiAnalysisWidget.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,
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 
17 #ifndef QmitkTbssRoiAnalysisWidget_H_
18 #define QmitkTbssRoiAnalysisWidget_H_
19 
20 #include "QmitkPlotWidget.h"
21 
22 #include <org_mitk_gui_qt_diffusionimaging_Export.h>
23 
24 #include <mitkFiberBundle.h>
25 #include <mitkTbssImage.h>
26 
27 #include <itkVectorImage.h>
28 
29 typedef itk::VectorImage<float,3> VectorImageType;
30 typedef std::vector< itk::Index<3> > RoiType;
31 
33 typedef std::vector< PointType> TractType;
34 typedef std::vector< TractType > TractContainerType;
35 
36 class QwtPlotPicker;
37 
45 class DIFFUSIONIMAGING_EXPORT QmitkTbssRoiAnalysisWidget : public QmitkPlotWidget
46 {
47 
48 Q_OBJECT
49 
50 public:
51 
52 
53  QmitkTbssRoiAnalysisWidget( QWidget * parent);
54  virtual ~QmitkTbssRoiAnalysisWidget();
55 
56 
57  /* \brief Set group information as a vector of pairs of group name and number of group members */
58  void SetGroups(std::vector< std::pair<std::string, int> > groups)
59  {
60  m_Groups = groups;
61  }
62 
63  /* \brief Draws the group averaged profiles */
64  void DrawProfiles();
65 
66 
67  void PlotFiber4D(mitk::TbssImage::Pointer tbssImage,
68  mitk::FiberBundle *fib,
69  mitk::DataNode *startRoi,
70  mitk::DataNode *endRoi,
71  int number);
72 
73 
74  template <typename T>
75  void PlotFiberBundles(const mitk::PixelType, TractContainerType tracts, mitk::Image* img, bool avg=false);
76 
77 
78  /* \brief Sets the projections of the individual subjects */
80  {
81  m_Projections = projections;
82  }
83 
84  /* \brief Set the region of interest*/
85  void SetRoi(RoiType roi)
86  {
87  m_Roi = roi;
88  }
89 
90  /* \brief Set structure information to display in the plot */
91  void SetStructure(std::string structure)
92  {
93  m_Structure = structure;
94  }
95 
96  /* \brief Set measurement type for display in the plot */
97  void SetMeasure(std::string measure)
98  {
99  m_Measure = measure;
100  }
101 
102  /* \brief Draws a bar to indicate were the user clicked in the plot */
103  void drawBar(int x);
104 
105 
106 
107  /* \brief Returns the values of the group averaged profiles */
108  std::vector <std::vector<double> > GetVals()
109  {
110  return m_Vals;
111  }
112 
113 
114  /* \brief Returns the values of the individual subjects profiles */
115  std::vector <std::vector<double> > GetIndividualProfiles()
116  {
117  return m_IndividualProfiles;
118  }
119 
120 
121  std::vector<double> GetAverageProfile()
122  {
123  return m_Average;
124  }
125 
126 
127  void SetPlottingFiber(bool b)
128  {
129  m_PlottingFiberBundle = b;
130  }
131 
133  {
134  return m_PlottingFiberBundle;
135  }
136 
137 
138  void PlotFiberBetweenRois(mitk::FiberBundle *fib, mitk::Image* img,
139  mitk::DataNode *startRoi, mitk::DataNode *endRoi, bool avg=-1, int number=25);
140 
141 
142 
143 
144  // Takes an index which is an x coordinate from the plot and finds the corresponding position in world space
146  void ModifyPlot(int number, bool avg);
147 
148 
149 
150  QwtPlotPicker* m_PlotPicker;
151 
152 protected:
153 
155 
156 
157  std::vector< std::vector<double> > m_Vals;
158 
159  std::vector< std::vector<double> > m_IndividualProfiles;
160  std::vector< double > m_Average;
161 
162 
163 
164  std::vector< std::vector<double> > CalculateGroupProfiles();
165  std::vector< std::vector<double> > CalculateGroupProfilesFibers(mitk::TbssImage::Pointer tbssImage,
166  mitk::FiberBundle *fib,
167  mitk::DataNode* startRoi,
168  mitk::DataNode* endRoi,
169  int number);
170 
171  void Plot(std::vector <std::vector<double> > groupProfiles);
172 
173 
174  void Tokenize(const std::string& str,
175  std::vector<std::string>& tokens,
176  const std::string& delimiters = " ")
177  {
178  // Skip delimiters at beginning.
179  std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
180  // Find first "non-delimiter".
181  std::string::size_type pos = str.find_first_of(delimiters, lastPos);
182 
183  while (std::string::npos != pos || std::string::npos != lastPos)
184  {
185  // Found a token, add it to the vector.
186  tokens.push_back(str.substr(lastPos, pos - lastPos));
187  // Skip delimiters. Note the "not_of"
188  lastPos = str.find_first_not_of(delimiters, pos);
189  // Find next "non-delimiter"
190  pos = str.find_first_of(delimiters, lastPos);
191  }
192  }
193 
194  std::vector< std::pair<std::string, int> > m_Groups;
195 
198  std::string m_Structure;
199  std::string m_Measure;
200 
201  bool m_PlottingFiberBundle; // true when the plot results from a fiber tracking result (vtk .fib file)
202 
203 
204  // Resample a collection of tracts so that every tract contains #number equidistant samples
205  TractContainerType ParameterizeTracts(TractContainerType tracts, int number);
206 
207 
209 
210 
213 
216 
217 
218  void DoPlotFiberBundles(mitk::FiberBundle *fib, mitk::Image* img,
219  mitk::DataNode* startRoi, mitk::DataNode* endRoi, bool avg=false, int number=25);
220 
221 
222 
223  /* \brief Creates tracts from a mitk::FiberBundle and two planar figures indicating the start end end point */
224  TractContainerType CreateTracts(mitk::FiberBundle *fib, mitk::DataNode* startRoi, mitk::DataNode* endRoi);
225 
226 
227 
228 };
229 
230 #endif
mitk::Point3D PointType
void SetProjections(VectorImageType::Pointer projections)
itk::SmartPointer< Self > Pointer
std::vector< std::pair< std::string, int > > m_Groups
std::vector< itk::Index< 3 > > RoiType
std::vector< std::vector< double > > m_IndividualProfiles
void SetMeasure(std::string measure)
itk::VectorImage< float, 3 > VectorImageType
std::vector< TractType > TractContainerType
void SetGroups(std::vector< std::pair< std::string, int > > groups)
std::vector< PointType > TractType
std::vector< std::vector< double > > GetIndividualProfiles()
std::vector< std::vector< double > > GetVals()
Plot widget for TBSS Data This widget can plot regions of interest on TBSS projection data...
Image class for storing images.
Definition: mitkImage.h:76
Base Class for Fiber Bundles;.
void SetStructure(std::string structure)
std::vector< double > GetAverageProfile()
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
std::vector< std::vector< double > > m_Vals
this class encapsulates diffusion volumes (vectorimages not yet supported by mitkImage) ...
Definition: mitkTbssImage.h:34
VectorImageType::Pointer m_Projections
static std::string GetPositionInWorld(mitk::InteractionEvent *event)
GetPosition Return World Position as String.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
Class for defining the data type of pixels.
Definition: mitkPixelType.h:55