17 #ifndef __mitkTractAnalyzer_cpp
18 #define __mitkTractAnalyzer_cpp
25 #include <itkImageRegionIteratorWithIndex.h>
38 TractAnalyzer::TractAnalyzer() { }
41 void TractAnalyzer::MakeRoi()
47 if(m_PointSetNode.IsNotNull())
49 n = m_PointSetNode->GetSize();
52 mitkThrow() <<
"No points have been set yet.";
56 mitkThrow() <<
"No points have been set yet.";
59 std::string pathDescription =
"";
60 std::vector< itk::Index<3> > totalPath;
64 for(
int i=0; i<n-1; ++i)
76 m_InputImage->GetGeometry()->WorldToIndex(p,startPoint);
77 m_InputImage->GetGeometry()->WorldToIndex(p2,endPoint);
81 std::vector< itk::Index<3> > path = CreateSegment(startPoint, endPoint);
83 for(
auto it = path.begin();
84 it != path.end(); it++)
92 totalPath.push_back(ix);
94 ss << ix[0] <<
" " << ix[1] <<
" " << ix[2] <<
"\n";
95 pathDescription += ss.str();
103 totalPath.push_back(endPoint);
104 std::stringstream ss;
105 ss << endPoint[0] <<
" " << endPoint[1] <<
" " << endPoint[2] <<
"\n";
106 pathDescription += ss.str();
117 m_PathDescription = pathDescription;
123 roiImg->SetRegions(itkImg->GetLargestPossibleRegion().GetSize());
124 roiImg->SetOrigin(itkImg->GetOrigin());
125 roiImg->SetSpacing(itkImg->GetSpacing());
126 roiImg->SetDirection(itkImg->GetDirection());
128 roiImg->FillBuffer(0);
131 std::vector< itk::Index<3> > roi;
133 std::vector< itk::Index<3> >::iterator it;
134 for(it = totalPath.begin();
135 it != totalPath.end();
139 roiImg->SetPixel(ix, 1);
146 m_TbssRoi->SetRoi(roi);
148 m_TbssRoi->SetImage(roiImg);
150 m_TbssRoi->InitializeFromImage();
180 costFunction->SetImage(meanSkeleton);
181 costFunction->SetStartIndex(startPoint);
182 costFunction->SetEndIndex(endPoint);
183 costFunction->SetThreshold(m_Threshold);
186 pathFinder->SetCostFunction(costFunction);
187 pathFinder->SetFullNeighborsMode(
true);
188 pathFinder->SetGraph_fullNeighbors(
true);
190 pathFinder->SetInput(meanSkeleton);
191 pathFinder->SetStartIndex(startPoint);
192 pathFinder->SetEndIndex(endPoint);
193 pathFinder->Update();
195 double segmentCost = 0.0;
196 std::vector< itk::Index<3> > path = pathFinder->GetVectorPath();
198 for(
unsigned int i=0; i<path.size()-1; i++)
203 segmentCost += costFunction->GetCost(ix1, ix2);
206 m_CostSum += segmentCost;
209 return pathFinder->GetVectorPath();
213 return std::vector< itk::Index<3> >();
void Progress(unsigned int steps=1)
Sets the current amount of progress to current progress + steps.
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
static ProgressBar * GetInstance()
static method to get the GUI dependent ProgressBar-instance so the methods for steps to do and progre...
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.