17 #ifndef __itkStreamlineTrackingFilter_txx
18 #define __itkStreamlineTrackingFilter_txx
25 #include <itkImageRegionConstIterator.h>
26 #include <itkImageRegionConstIteratorWithIndex.h>
27 #include <itkImageRegionIterator.h>
29 #define _USE_MATH_DEFINES
34 template<
class TTensorPixelType,
class TPDPixelType>
38 : m_FiberPolyData(NULL)
44 , m_MinCurvatureRadius(0)
47 , m_MinTractLength(0.0)
52 , m_PointPistance(0.0)
53 , m_ResampleFibers(false)
59 this->SetNumberOfRequiredInputs( 1 );
60 this->SetNumberOfIndexedInputs(3);
67 ::RoundToNearest(
double num) {
68 return (num > 0.0) ? floor(num + 0.5) : ceil(num - 0.5);
75 ::BeforeThreadedGenerateData()
82 m_ImageSize.resize(3);
83 m_ImageSize[0] = inputImage->GetLargestPossibleRegion().GetSize()[0];
84 m_ImageSize[1] = inputImage->GetLargestPossibleRegion().GetSize()[1];
85 m_ImageSize[2] = inputImage->GetLargestPossibleRegion().GetSize()[2];
87 if (m_ImageSize[0]<3 || m_ImageSize[1]<3 || m_ImageSize[2]<3)
88 m_Interpolate =
false;
90 m_ImageSpacing.resize(3);
91 m_ImageSpacing[0] = inputImage->GetSpacing()[0];
92 m_ImageSpacing[1] = inputImage->GetSpacing()[1];
93 m_ImageSpacing[2] = inputImage->GetSpacing()[2];
96 if(m_ImageSpacing[0]<m_ImageSpacing[1] && m_ImageSpacing[0]<m_ImageSpacing[2])
97 minSpacing = m_ImageSpacing[0];
98 else if (m_ImageSpacing[1] < m_ImageSpacing[2])
99 minSpacing = m_ImageSpacing[1];
101 minSpacing = m_ImageSpacing[2];
102 if (m_StepSize<0.1*minSpacing)
103 m_StepSize = 0.1*minSpacing;
105 if (m_ResampleFibers)
106 m_PointPistance = 0.5*minSpacing;
109 for (
unsigned int i=0; i<this->GetNumberOfThreads(); i++)
112 m_PolyDataContainer->InsertElement(i, poly);
115 if (m_SeedImage.IsNull())
119 m_SeedImage->SetSpacing( inputImage->GetSpacing() );
120 m_SeedImage->SetOrigin( inputImage->GetOrigin() );
121 m_SeedImage->SetDirection( inputImage->GetDirection() );
122 m_SeedImage->SetRegions( inputImage->GetLargestPossibleRegion() );
123 m_SeedImage->Allocate();
124 m_SeedImage->FillBuffer(1);
127 if (m_MaskImage.IsNull())
131 m_MaskImage->SetSpacing( inputImage->GetSpacing() );
132 m_MaskImage->SetOrigin( inputImage->GetOrigin() );
133 m_MaskImage->SetDirection( inputImage->GetDirection() );
134 m_MaskImage->SetRegions( inputImage->GetLargestPossibleRegion() );
135 m_MaskImage->Allocate();
136 m_MaskImage->FillBuffer(1);
139 bool useUserFaImage =
true;
140 if (m_FaImage.IsNull())
143 m_FaImage->SetSpacing( inputImage->GetSpacing() );
144 m_FaImage->SetOrigin( inputImage->GetOrigin() );
145 m_FaImage->SetDirection( inputImage->GetDirection() );
146 m_FaImage->SetRegions( inputImage->GetLargestPossibleRegion() );
147 m_FaImage->Allocate();
148 m_FaImage->FillBuffer(0.0);
149 useUserFaImage =
false;
152 m_NumberOfInputs = 0;
153 for (
unsigned int i=0; i<this->GetNumberOfIndexedInputs(); i++)
155 if (this->ProcessObject::GetInput(i)==NULL)
159 pdImage->SetSpacing( inputImage->GetSpacing() );
160 pdImage->SetOrigin( inputImage->GetOrigin() );
161 pdImage->SetDirection( inputImage->GetDirection() );
162 pdImage->SetRegions( inputImage->GetLargestPossibleRegion() );
164 m_PdImage.push_back(pdImage);
167 emaxImage->SetSpacing( inputImage->GetSpacing() );
168 emaxImage->SetOrigin( inputImage->GetOrigin() );
169 emaxImage->SetDirection( inputImage->GetDirection() );
170 emaxImage->SetRegions( inputImage->GetLargestPossibleRegion() );
171 emaxImage->Allocate();
172 emaxImage->FillBuffer(1.0);
173 m_EmaxImage.push_back(emaxImage);
176 m_InputImage.push_back(inputImage);
180 MITK_INFO <<
"Processing " << m_NumberOfInputs <<
" tensor files";
182 typedef itk::DiffusionTensor3D<TTensorPixelType> TensorType;
183 typename TensorType::EigenValuesArrayType eigenvalues;
184 typename TensorType::EigenVectorsMatrixType eigenvectors;
187 for (
int x=0; x<m_ImageSize[0]; x++)
188 for (
int y=0; y<m_ImageSize[1]; y++)
189 for (
int z=0; z<m_ImageSize[2]; z++)
191 typename InputImageType::IndexType index;
192 index[0] = x; index[1] = y; index[2] = z;
193 for (
int i=0; i<m_NumberOfInputs; i++)
196 vnl_vector_fixed<double,3> dir;
197 tensor.ComputeEigenAnalysis(eigenvalues, eigenvectors);
198 dir[0] = eigenvectors(2, 0);
199 dir[1] = eigenvectors(2, 1);
200 dir[2] = eigenvectors(2, 2);
202 m_PdImage.at(i)->SetPixel(index, dir);
204 m_FaImage->SetPixel(index, m_FaImage->GetPixel(index)+tensor.GetFractionalAnisotropy());
205 m_EmaxImage.at(i)->SetPixel(index, 2/eigenvalues[2]);
208 m_FaImage->SetPixel(index, m_FaImage->GetPixel(index)/m_NumberOfInputs);
212 std::cout <<
"StreamlineTrackingFilter: using trilinear interpolation" << std::endl;
215 if (m_MinCurvatureRadius<0.0)
216 m_MinCurvatureRadius = 0.1*minSpacing;
218 std::cout <<
"StreamlineTrackingFilter: using nearest neighbor interpolation" << std::endl;
221 if (m_MinCurvatureRadius<0.0)
222 m_MinCurvatureRadius = 0.5*minSpacing;
224 std::cout <<
"StreamlineTrackingFilter: Min. curvature radius: " << m_MinCurvatureRadius << std::endl;
225 std::cout <<
"StreamlineTrackingFilter: FA threshold: " << m_FaThreshold << std::endl;
226 std::cout <<
"StreamlineTrackingFilter: stepsize: " << m_StepSize <<
" mm" << std::endl;
227 std::cout <<
"StreamlineTrackingFilter: f: " << m_F << std::endl;
228 std::cout <<
"StreamlineTrackingFilter: g: " << m_G << std::endl;
229 std::cout <<
"StreamlineTrackingFilter: starting streamline tracking using " << this->GetNumberOfThreads() <<
" threads." << std::endl;
232 template<
class TTensorPixelType,
class TPDPixelType>
234 ::CalculateNewPosition(itk::ContinuousIndex<double, 3>& pos, vnl_vector_fixed<double,3>& dir,
typename InputImageType::IndexType& index)
236 vnl_matrix_fixed< double, 3, 3 > rot = m_InputImage.at(0)->GetDirection().GetTranspose();
241 pos[0] += dir[0]/m_ImageSpacing[0];
242 pos[1] += dir[1]/m_ImageSpacing[1];
243 pos[2] += dir[2]/m_ImageSpacing[2];
244 index[0] = RoundToNearest(pos[0]);
245 index[1] = RoundToNearest(pos[1]);
246 index[2] = RoundToNearest(pos[2]);
250 dir[0] /= m_ImageSpacing[0];
251 dir[1] /= m_ImageSpacing[1];
252 dir[2] /= m_ImageSpacing[2];
258 if (fabs(fabs(RoundToNearest(pos[0])-pos[0])-0.5)>
mitk::eps)
259 x = fabs(pos[0]-RoundToNearest(pos[0])-0.5)/dir[0];
261 x = fabs(pos[0]-std::ceil(pos[0])-0.5)/dir[0];
265 if (fabs(fabs(RoundToNearest(pos[0])-pos[0])-0.5)>
mitk::eps)
266 x = -fabs(pos[0]-RoundToNearest(pos[0])+0.5)/dir[0];
268 x = -fabs(pos[0]-std::floor(pos[0])+0.5)/dir[0];
275 if (fabs(fabs(RoundToNearest(pos[1])-pos[1])-0.5)>
mitk::eps)
276 y = fabs(pos[1]-RoundToNearest(pos[1])-0.5)/dir[1];
278 y = fabs(pos[1]-std::ceil(pos[1])-0.5)/dir[1];
282 if (fabs(fabs(RoundToNearest(pos[1])-pos[1])-0.5)>
mitk::eps)
283 y = -fabs(pos[1]-RoundToNearest(pos[1])+0.5)/dir[1];
285 y = -fabs(pos[1]-std::floor(pos[1])+0.5)/dir[1];
296 if (fabs(fabs(RoundToNearest(pos[2])-pos[2])-0.5)>
mitk::eps)
297 z = fabs(pos[2]-RoundToNearest(pos[2])-0.5)/dir[2];
299 z = fabs(pos[2]-std::ceil(pos[2])-0.5)/dir[2];
303 if (fabs(fabs(RoundToNearest(pos[2])-pos[2])-0.5)>
mitk::eps)
304 z = -fabs(pos[2]-RoundToNearest(pos[2])+0.5)/dir[2];
306 z = -fabs(pos[2]-std::floor(pos[2])+0.5)/dir[2];
327 index[0] = std::floor(pos[0]);
329 index[0] = std::ceil(pos[0]);
330 index[1] = RoundToNearest(pos[1]);
331 index[2] = RoundToNearest(pos[2]);
336 index[1] = std::floor(pos[1]);
338 index[1] = std::ceil(pos[1]);
339 index[0] = RoundToNearest(pos[0]);
340 index[2] = RoundToNearest(pos[2]);
345 index[2] = std::floor(pos[2]);
347 index[2] = std::ceil(pos[2]);
348 index[1] = RoundToNearest(pos[1]);
349 index[0] = RoundToNearest(pos[0]);
389 template<
class TTensorPixelType,
class TPDPixelType>
391 ::IsValidPosition(itk::ContinuousIndex<double, 3>& pos,
typename InputImageType::IndexType &index, vnl_vector_fixed< double, 8 >& interpWeights,
int imageIdx)
393 if (!m_InputImage.at(imageIdx)->GetLargestPossibleRegion().IsInside(index) || m_MaskImage->GetPixel(index)==0)
398 double frac_x = pos[0] - index[0];
399 double frac_y = pos[1] - index[1];
400 double frac_z = pos[2] - index[2];
423 if (index[0] < 0 || index[0] >= m_ImageSize[0]-1)
425 if (index[1] < 0 || index[1] >= m_ImageSize[1]-1)
427 if (index[2] < 0 || index[2] >= m_ImageSize[2]-1)
430 interpWeights[0] = ( frac_x)*( frac_y)*( frac_z);
431 interpWeights[1] = (1-frac_x)*( frac_y)*( frac_z);
432 interpWeights[2] = ( frac_x)*(1-frac_y)*( frac_z);
433 interpWeights[3] = ( frac_x)*( frac_y)*(1-frac_z);
434 interpWeights[4] = (1-frac_x)*(1-frac_y)*( frac_z);
435 interpWeights[5] = ( frac_x)*(1-frac_y)*(1-frac_z);
436 interpWeights[6] = (1-frac_x)*( frac_y)*(1-frac_z);
437 interpWeights[7] = (1-frac_x)*(1-frac_y)*(1-frac_z);
439 typename InputImageType::IndexType tmpIdx;
440 double FA = m_FaImage->GetPixel(index) * interpWeights[0];
441 tmpIdx = index; tmpIdx[0]++;
442 FA += m_FaImage->GetPixel(tmpIdx) * interpWeights[1];
443 tmpIdx = index; tmpIdx[1]++;
444 FA += m_FaImage->GetPixel(tmpIdx) * interpWeights[2];
445 tmpIdx = index; tmpIdx[2]++;
446 FA += m_FaImage->GetPixel(tmpIdx) * interpWeights[3];
447 tmpIdx = index; tmpIdx[0]++; tmpIdx[1]++;
448 FA += m_FaImage->GetPixel(tmpIdx) * interpWeights[4];
449 tmpIdx = index; tmpIdx[1]++; tmpIdx[2]++;
450 FA += m_FaImage->GetPixel(tmpIdx) * interpWeights[5];
451 tmpIdx = index; tmpIdx[2]++; tmpIdx[0]++;
452 FA += m_FaImage->GetPixel(tmpIdx) * interpWeights[6];
453 tmpIdx = index; tmpIdx[0]++; tmpIdx[1]++; tmpIdx[2]++;
454 FA += m_FaImage->GetPixel(tmpIdx) * interpWeights[7];
456 if (FA<m_FaThreshold)
459 else if (m_FaImage->GetPixel(index)<m_FaThreshold)
465 template<
class TTensorPixelType,
class TPDPixelType>
467 ::FollowStreamline(itk::ContinuousIndex<double, 3> pos,
int dirSign, vtkPoints* points, std::vector< vtkIdType >& ids,
int imageIdx)
469 double tractLength = 0;
470 typedef itk::DiffusionTensor3D<TTensorPixelType> TensorType;
471 typename TensorType::EigenValuesArrayType eigenvalues;
472 typename TensorType::EigenVectorsMatrixType eigenvectors;
473 vnl_vector_fixed< double, 8 > interpWeights;
475 typename InputImageType::IndexType index, indexOld;
476 indexOld[0] = -1; indexOld[1] = -1; indexOld[2] = -1;
477 itk::Point<double> worldPos;
479 double distanceInVoxel = 0;
482 index[0] = RoundToNearest(pos[0]);
483 index[1] = RoundToNearest(pos[1]);
484 index[2] = RoundToNearest(pos[2]);
486 vnl_vector_fixed<double,3> dir = m_PdImage.at(imageIdx)->GetPixel(index);
488 vnl_vector_fixed<double,3> dirOld = dir;
492 for (
int step=0; step< m_MaxLength/2; step++)
495 CalculateNewPosition(pos, dir, index);
496 distance += m_StepSize;
499 if (!IsValidPosition(pos, index, interpWeights, imageIdx))
505 else if (distance>=m_PointPistance)
507 tractLength += m_StepSize;
508 distanceInVoxel += m_StepSize;
509 m_SeedImage->TransformContinuousIndexToPhysicalPoint( pos, worldPos );
510 ids.push_back(points->InsertNextPoint(worldPos.GetDataPointer()));
519 for (
int img=0; img<m_NumberOfInputs; img++)
521 vnl_vector_fixed<double,3> newDir = m_PdImage.at(img)->GetPixel(index);
526 double scale = m_EmaxImage.at(img)->GetPixel(index);
527 newDir[0] = m_F*newDir[0] + (1-m_F)*( (1-m_G)*dirOld[0] + scale*m_G*(tensor[0]*dirOld[0] + tensor[1]*dirOld[1] + tensor[2]*dirOld[2]));
528 newDir[1] = m_F*newDir[1] + (1-m_F)*( (1-m_G)*dirOld[1] + scale*m_G*(tensor[1]*dirOld[0] + tensor[3]*dirOld[1] + tensor[4]*dirOld[2]));
529 newDir[2] = m_F*newDir[2] + (1-m_F)*( (1-m_G)*dirOld[2] + scale*m_G*(tensor[2]*dirOld[0] + tensor[4]*dirOld[1] + tensor[5]*dirOld[2]));
532 double angle = dot_product(dirOld, newDir);
547 vnl_vector_fixed<double,3> v3 = dir+dirOld; v3 *= m_StepSize;
548 double a = m_StepSize;
549 double b = m_StepSize;
550 double c = v3.magnitude();
551 double r = a*b*c/std::sqrt((a+b+c)*(a+b-c)*(b+c-a)*(a-b+c));
553 if (r<m_MinCurvatureRadius)
568 typename InputImageType::IndexType tmpIdx = index;
571 if (m_NumberOfInputs>1)
574 for (
int img=0; img<m_NumberOfInputs; img++)
576 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
577 if (fabs(angle)>minAngle)
580 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
583 tensor = tmpTensor * interpWeights[0];
586 tmpIdx = index; tmpIdx[0]++;
587 for (
int img=0; img<m_NumberOfInputs; img++)
589 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
590 if (fabs(angle)>minAngle)
593 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
596 tensor += tmpTensor * interpWeights[1];
599 tmpIdx = index; tmpIdx[1]++;
600 for (
int img=0; img<m_NumberOfInputs; img++)
602 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
603 if (fabs(angle)>minAngle)
606 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
609 tensor += tmpTensor * interpWeights[2];
612 tmpIdx = index; tmpIdx[2]++;
613 for (
int img=0; img<m_NumberOfInputs; img++)
615 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
616 if (fabs(angle)>minAngle)
619 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
622 tensor += tmpTensor * interpWeights[3];
625 tmpIdx = index; tmpIdx[0]++; tmpIdx[1]++;
626 for (
int img=0; img<m_NumberOfInputs; img++)
628 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
629 if (fabs(angle)>minAngle)
632 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
635 tensor += tmpTensor * interpWeights[4];
638 tmpIdx = index; tmpIdx[1]++; tmpIdx[2]++;
639 for (
int img=0; img<m_NumberOfInputs; img++)
641 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
642 if (fabs(angle)>minAngle)
645 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
648 tensor += tmpTensor * interpWeights[5];
651 tmpIdx = index; tmpIdx[2]++; tmpIdx[0]++;
652 for (
int img=0; img<m_NumberOfInputs; img++)
654 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
655 if (fabs(angle)>minAngle)
658 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
661 tensor += tmpTensor * interpWeights[6];
664 tmpIdx = index; tmpIdx[0]++; tmpIdx[1]++; tmpIdx[2]++;
665 for (
int img=0; img<m_NumberOfInputs; img++)
667 double angle = dot_product(dirOld, m_PdImage.at(img)->GetPixel(tmpIdx));
668 if (fabs(angle)>minAngle)
671 tmpTensor = m_InputImage.at(img)->GetPixel(tmpIdx);
674 tensor += tmpTensor * interpWeights[7];
678 tensor = m_InputImage.at(0)->GetPixel(index) * interpWeights[0];
679 typename InputImageType::IndexType tmpIdx = index; tmpIdx[0]++;
680 tensor += m_InputImage.at(0)->GetPixel(tmpIdx) * interpWeights[1];
681 tmpIdx = index; tmpIdx[1]++;
682 tensor += m_InputImage.at(0)->GetPixel(tmpIdx) * interpWeights[2];
683 tmpIdx = index; tmpIdx[2]++;
684 tensor += m_InputImage.at(0)->GetPixel(tmpIdx) * interpWeights[3];
685 tmpIdx = index; tmpIdx[0]++; tmpIdx[1]++;
686 tensor += m_InputImage.at(0)->GetPixel(tmpIdx) * interpWeights[4];
687 tmpIdx = index; tmpIdx[1]++; tmpIdx[2]++;
688 tensor += m_InputImage.at(0)->GetPixel(tmpIdx) * interpWeights[5];
689 tmpIdx = index; tmpIdx[2]++; tmpIdx[0]++;
690 tensor += m_InputImage.at(0)->GetPixel(tmpIdx) * interpWeights[6];
691 tmpIdx = index; tmpIdx[0]++; tmpIdx[1]++; tmpIdx[2]++;
692 tensor += m_InputImage.at(0)->GetPixel(tmpIdx) * interpWeights[7];
695 tensor.ComputeEigenAnalysis(eigenvalues, eigenvectors);
696 dir[0] = eigenvectors(2, 0);
697 dir[1] = eigenvectors(2, 1);
698 dir[2] = eigenvectors(2, 2);
703 double scale = 2/eigenvalues[2];
704 dir[0] = m_F*dir[0] + (1-m_F)*( (1-m_G)*dirOld[0] + scale*m_G*(tensor[0]*dirOld[0] + tensor[1]*dirOld[1] + tensor[2]*dirOld[2]));
705 dir[1] = m_F*dir[1] + (1-m_F)*( (1-m_G)*dirOld[1] + scale*m_G*(tensor[1]*dirOld[0] + tensor[3]*dirOld[1] + tensor[4]*dirOld[2]));
706 dir[2] = m_F*dir[2] + (1-m_F)*( (1-m_G)*dirOld[2] + scale*m_G*(tensor[2]*dirOld[0] + tensor[4]*dirOld[1] + tensor[5]*dirOld[2]));
709 double angle = dot_product(dirOld, dir);
716 vnl_vector_fixed<double,3> v3 = dir+dirOld; v3 *= m_StepSize;
717 double a = m_StepSize;
718 double b = m_StepSize;
719 double c = v3.magnitude();
720 double r = a*b*c/std::sqrt((a+b+c)*(a+b-c)*(b+c-a)*(a-b+c));
722 if (r<m_MinCurvatureRadius)
737 ThreadIdType threadId)
743 typedef itk::DiffusionTensor3D<TTensorPixelType> TensorType;
744 typedef ImageRegionConstIterator< InputImageType > InputIteratorType;
745 typedef ImageRegionConstIterator< ItkUcharImgType > MaskIteratorType;
746 typedef ImageRegionConstIterator< ItkFloatImgType > doubleIteratorType;
749 MaskIteratorType sit(m_SeedImage, outputRegionForThread );
750 doubleIteratorType fit(m_FaImage, outputRegionForThread );
751 MaskIteratorType mit(m_MaskImage, outputRegionForThread );
753 for (
int img=0; img<m_NumberOfInputs; img++)
758 itk::Point<double> worldPos;
759 while( !sit.IsAtEnd() )
761 if (sit.Value()==0 || fit.Value()<m_FaThreshold || mit.Value()==0)
769 for (
int s=0; s<m_SeedsPerVoxel; s++)
772 std::vector< vtkIdType > pointIDs;
773 typename InputImageType::IndexType index = sit.GetIndex();
774 itk::ContinuousIndex<double, 3> start;
775 unsigned int counter = 0;
777 if (m_SeedsPerVoxel>1)
779 start[0] = index[0]+(double)(rand()%99-49)/100;
780 start[1] = index[1]+(double)(rand()%99-49)/100;
781 start[2] = index[2]+(double)(rand()%99-49)/100;
791 double tractLength = FollowStreamline(start, 1, points, pointIDs, img);
794 counter += pointIDs.size();
795 while (!pointIDs.empty())
797 line->GetPointIds()->InsertNextId(pointIDs.back());
802 m_SeedImage->TransformContinuousIndexToPhysicalPoint( start, worldPos );
803 line->GetPointIds()->InsertNextId(points->InsertNextPoint(worldPos.GetDataPointer()));
806 tractLength += FollowStreamline(start, -1, points, pointIDs, img);
808 counter += pointIDs.size();
812 if (tractLength<m_MinTractLength || counter<2)
816 for (
unsigned int i=0; i<pointIDs.size(); i++)
817 line->GetPointIds()->InsertNextId(pointIDs.at(i));
819 Cells->InsertNextCell(line);
826 poly->SetPoints(points);
827 poly->SetLines(Cells);
829 std::cout <<
"Thread " << threadId <<
" finished tracking" << std::endl;
839 vtkSmartPointer<vtkCellArray> vNewLines = poly1->GetLines();
840 vtkSmartPointer<vtkPoints> vNewPoints = poly1->GetPoints();
842 for(
int i=0; i<poly2->GetNumberOfLines(); i++ )
844 vtkCell* cell = poly2->GetCell(i);
845 int numPoints = cell->GetNumberOfPoints();
846 vtkPoints* points = cell->GetPoints();
849 for (
int j=0; j<numPoints; j++)
852 points->GetPoint(j, p);
854 vtkIdType
id = vNewPoints->InsertNextPoint(p);
855 container->GetPointIds()->InsertNextId(
id);
857 vNewLines->InsertNextCell(container);
861 vNewPolyData->SetPoints(vNewPoints);
862 vNewPolyData->SetLines(vNewLines);
870 ::AfterThreadedGenerateData()
873 m_FiberPolyData = m_PolyDataContainer->GetElement(0);
874 for (
unsigned int i=1; i<this->GetNumberOfThreads(); i++)
876 m_FiberPolyData = AddPolyData(m_FiberPolyData, m_PolyDataContainer->GetElement(i));
885 ::PrintSelf(std::ostream&, Indent)
const
890 #endif // __itkDiffusionQballPrincipleDirectionsImageFilter_txx
itk::SmartPointer< Self > Pointer
Performes deterministic streamline tracking on the input tensor image.
void CalculateNewPosition(itk::ContinuousIndex< double, 3 > &pos, vnl_vector_fixed< double, 3 > &dir, typename InputImageType::IndexType &index)
Calculate next integration step.
double FollowStreamline(itk::ContinuousIndex< double, 3 > pos, int dirSign, vtkPoints *points, std::vector< vtkIdType > &ids, int imageIdx)
Start streamline in one direction.
Superclass::InputImageType InputImageType
vtkSmartPointer< vtkPolyData > FiberPolyDataType
bool IsValidPosition(itk::ContinuousIndex< double, 3 > &pos, typename InputImageType::IndexType &index, vnl_vector_fixed< double, 8 > &interpWeights, int imageIdx)
Are we outside of the mask image? Is the FA too low?
MITKCORE_EXPORT const ScalarType eps
Superclass::OutputImageRegionType OutputImageRegionType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.