12 #ifndef __itkFiberTracts_hxx 13 #define __itkFiberTracts_hxx 20 template<
class TValue >
21 typename LightObject::Pointer
25 typename LightObject::Pointer loPtr = Superclass::InternalClone();
30 itkExceptionMacro(<<
"downcast to type " << this->GetNameOfClass()<<
" failed.");
33 rval->m_Header = m_Header;
34 rval->m_Fibers = m_Fibers;
38 template<
class TValue >
45 auto fibers = out->GetFibers();
46 int num = GetNumberOfFibers();
47 for (
int i = 0; i < num; ++i )
49 auto fiber = this->GetFiber(i)->DeepClone();
50 fibers->InsertElement( fibers->Size(), fiber);
55 template<
class TValue >
61 for (
int i = 0; i < GetNumberOfFibers(); ++i )
62 num += GetFiber(i)->GetNumberOfPoints();
66 template<
class TValue >
69 ::GetPointStats(std::vector<double>& numPointsStats, std::vector<double>& pointDistStats)
const 71 std::vector<double> numVec, distVec;
72 for (
int i = 0; i < GetNumberOfFibers(); ++i )
74 auto fiber = GetFiber(i);
75 numVec.push_back(fiber->GetNumberOfPoints());
76 auto vec = fiber->GetPointDistanceStats();
77 distVec.push_back(vec[2]);
83 template<
class TValue >
89 for (
int i = 0; i < GetNumberOfFibers(); ++i )
90 this->GetFiber(i)->RemoveScalarsByName(name, scalarNames);
95 template<
class TValue >
101 for (
int i = 0; i < GetNumberOfFibers(); ++i )
102 this->GetFiber(i)->RemovePropertiesByName(name, scalarNames);
107 template<
class TValue >
114 result->m_Header->n_count = indices.size();
116 auto fibers = result->GetFibers();
117 for (
int i = 0; i < indices.size(); ++i )
118 fibers->InsertElement(i, GetFiber(indices[i]));
123 template<
class TValue >
132 auto fibers = result->GetFibers();
133 for (
int i = 0; i < GetNumberOfFibers(); ++i )
135 auto fiber_i = GetFiber(i);
136 double dist = fiber_i->DistanceToPoint(x,y,z);
139 fibers->InsertElement(fibers->Size(), fiber_i);
143 result->m_Header->n_count=num;
148 template<
class TValue >
153 m_Fibers->InsertElement(m_Fibers->Size(), fiber);
157 template<
class TValue >
163 for (
int i = 0; i < fibers->GetNumberOfFibers(); ++i )
164 AppendFiber(fibers->GetFiber(i));
167 template<
class TValue >
172 Superclass::PrintSelf(os, indent);
173 PrintFibersHeader(os, indent);
175 std::vector<double> numPointsStats, pointDistStats;
176 GetPointStats(numPointsStats, pointDistStats);
179 (m_Header->n_count)(m_Fibers->Size()).msg(
"the number of tracts are not consistent in m_Header and m_Fibers");
181 os << indent << std::endl;
182 os << indent <<
"The number of fibers: " << GetNumberOfFibers() << std::endl;
183 os << indent <<
"Total number of points: " << GetNumberOfPoints() << std::endl << std::flush;
184 utl::PrintVector(numPointsStats,
"stats of the number of points (min,max,mean,std): ",
" ", os << indent,
false);
185 utl::PrintVector(pointDistStats,
"stats of distances between points (min,max,mean,std): ",
" ", os << indent,
false);
186 for (
int i = 0; i < m_Fibers->Size(); ++i )
189 os << indent << std::endl;
190 os << indent <<
"Fiber #" << i <<
" : number of points = " << fiber->GetNumberOfPoints() << std::endl;
191 fiber->Print(os, indent);
193 os << indent<< std::endl;
bool IsSameStructure(const TrackVisHeaderType &h1, const TrackVisHeaderType &h2)
void RemoveScalarName(TrackVisHeaderType &header, const std::string &name)
FiberTracts< TValue >::Pointer DeepClone() const
FiberType::Pointer FiberPointer
void RemovePropertyName(TrackVisHeaderType &header, const std::string &name)
std::vector< double > GetContainerStats(IteratorType v1, IteratorType v2)
#define utlSAGlobalException(expr)
void AppendFiber(const FiberPointer fiber)
void CopyTrackvisHeader(const TrackVisHeaderType &hFrom, TrackVisHeaderType &hTo)
virtual void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
void GetPointStats(std::vector< double > &numPointsStats, std::vector< double > &pointDistStats) const
std::vector< std::string > CovertChar2DArrayToStringArray(const char arr[][M], int N)
#define utlGlobalException(cond, expout)
void AppendFibers(const Pointer fibers)
Pointer SelectByBallROI(double x, double y, double z, double radius)
void PrintVector(const std::vector< T > &vec, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout, bool showStats=true)
void RemovePropertiesByName(const std::string &name)
Pointer SelectByIndicesOfTracts(const std::vector< int > &indices)
SmartPointer< Self > Pointer
LightObject::Pointer InternalClone() const ITK_OVERRIDE
int GetNumberOfPoints() const
void RemoveScalarsByName(const std::string &name)