DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkFiber.h
Go to the documentation of this file.
1 
11 #ifndef __itkFiber_h
12 #define __itkFiber_h
13 
14 #include <itkDataObject.h>
15 #include <itkObjectFactory.h>
16 
18 
19 #include "utlSmartAssert.h"
20 #include "utlCore.h"
21 #include "utlITKMacro.h"
22 
23 namespace itk
24 {
25 
26 template< typename TValue=double >
27 class Fiber: public DataObject
28 {
29 public:
31  typedef Fiber Self;
32  typedef DataObject Superclass;
33  typedef SmartPointer< Self > Pointer;
34  typedef SmartPointer< const Self > ConstPointer;
35 
36  itkNewMacro(Self);
37 
38  itkTypeMacro(Fiber, DataObject );
39 
40  typedef TValue ValueType;
41 
43  typedef typename TractType::Pointer TractPointer;
45 
46  typedef std::vector<ValueType> STDVectorType;
47  typedef std::shared_ptr<STDVectorType> STDVectorPointer;
48  typedef std::vector<std::vector<ValueType> > STD2DVectorType;
49  typedef std::shared_ptr<STD2DVectorType> STD2DVectorPointer;
50 
51  int GetNumberOfPoints() const
52  {
53  return m_Tract->GetVertexList()->Size();
54  }
55 
57  {
58  return m_Properties->size();
59  }
60 
62  {
63  return m_Scalars->size()>0? (*m_Scalars)[0].size() : 0;
64  }
65 
66  VertexType GetPoint(const int index) const
67  {
68  return m_Tract->GetVertexList()->GetElement(index);
69  }
70 
71  void RemoveScalarsByName(const std::string& name, const std::vector<std::string>& nameVec);
72  void RemovePropertiesByName(const std::string& name, const std::vector<std::string>& nameVec);
73 
74  Vector<double,3> GetDirection(const double pos, bool isDerivativeNormalizedByDistance=false) const
75  {
76  if (GetNumberOfPoints()<=1)
77  {
78  // the fiber only has one point, then there is no direction for that point
79  Vector<double,3> vec;
80  vec.Fill(0.0);
81  return vec;
82  }
83  else
84  {
85  // for fiber with more than 2 points
86  return m_Tract->EvaluateDerivative(pos, isDerivativeNormalizedByDistance);
87  }
88  }
89 
90  double DistanceToPoint(double x, double y, double z) const;
91 
92  std::vector<double> GetPointDistanceStats() const;
93 
94  itkSetGetMacro(Properties, STDVectorPointer);
95 
96  itkSetGetMacro(Scalars, STD2DVectorPointer);
97 
98  itkSetGetMacro(Tract, TractPointer);
99 
100  typename Fiber<TValue>::Pointer DeepClone() const;
101 
102 protected:
103  Fiber(): m_Properties(new STDVectorType()), m_Scalars(new STD2DVectorType())
104  {}
105  ~Fiber(){}
106 
107  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
108 
109  typename LightObject::Pointer InternalClone() const ITK_OVERRIDE;
110 
111  TractPointer m_Tract = TractType::New();
112 
114  STDVectorPointer m_Properties;
115 
117  STD2DVectorPointer m_Scalars;
118 
119 
120 private:
121  Fiber(const Self &) ITK_DELETE_FUNCTION;
122  void operator=(const Self &) ITK_DELETE_FUNCTION;
123 
124 };
125 
126 }
127 
128 #if !defined(ITK_MANUAL_INSTANTIATION) && !defined(__itkFiber_hxx)
129 #include "itkFiber.hxx"
130 #endif
131 
132 
133 #endif
Represent a path of line segments through ND Space.
int GetDimensionOfProperties() const
Definition: itkFiber.h:56
double DistanceToPoint(double x, double y, double z) const
Definition: itkFiber.hxx:65
LightObject::Pointer InternalClone() const ITK_OVERRIDE
Definition: itkFiber.hxx:24
TractType::VertexType VertexType
Definition: itkFiber.h:44
TractType::Pointer TractPointer
Definition: itkFiber.h:43
TractPointer m_Tract
Definition: itkFiber.h:111
std::shared_ptr< STD2DVectorType > STD2DVectorPointer
Definition: itkFiber.h:49
#define ITK_DELETE_FUNCTION
Definition: utlITKMacro.h:49
Vector< double, 3 > GetDirection(const double pos, bool isDerivativeNormalizedByDistance=false) const
Definition: itkFiber.h:74
SlowPolyLineParametricPath< 3 > TractType
Definition: itkFiber.h:42
SmartPointer< const Self > ConstPointer
Definition: itkFiber.h:34
int GetNumberOfPoints() const
Definition: itkFiber.h:51
std::vector< double > GetPointDistanceStats() const
Definition: itkFiber.hxx:86
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
STDVectorPointer m_Properties
Definition: itkFiber.h:114
void RemoveScalarsByName(const std::string &name, const std::vector< std::string > &nameVec)
Definition: itkFiber.hxx:102
itkSetGetMacro(Properties, STDVectorPointer)
STD2DVectorPointer m_Scalars
Definition: itkFiber.h:117
void RemovePropertiesByName(const std::string &name, const std::vector< std::string > &nameVec)
Definition: itkFiber.hxx:114
Fiber Self
Definition: itkFiber.h:31
SmartPointer< Self > Pointer
Definition: itkFiber.h:33
std::shared_ptr< STDVectorType > STDVectorPointer
Definition: itkFiber.h:47
std::vector< ValueType > STDVectorType
Definition: itkFiber.h:46
Created "07-24-2017.
int GetDimensionOfScalarsPerPoint() const
Definition: itkFiber.h:61
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
Definition: itkFiber.hxx:122
DataObject Superclass
Definition: itkFiber.h:32
std::vector< std::vector< ValueType > > STD2DVectorType
Definition: itkFiber.h:48
VertexType GetPoint(const int index) const
Definition: itkFiber.h:66
TValue ValueType
Definition: itkFiber.h:38
Fiber< TValue >::Pointer DeepClone() const
Definition: itkFiber.hxx:43