@@ -77,15 +77,19 @@ CemrgScarAdvanced::CemrgScarAdvanced() {
7777 _fill_threshold = 0.5 ;
7878 _max_scalar = -1 ;
7979 _run_count = 0 ;
80- fandi1_largestSurfaceArea=-1 ;
81- fandi2_percentage=-1 ;
82- fandi2_largestSurfaceArea=-1 ;
83- fandi2_corridorSurfaceArea=-1 ;
84- fandi2_connectedAreasTotal=-1 ;
85- fandi3_preSurfacePercentage=-1 ;
86- fandi3_postSurfacePercentage=-1 ;
87- fandi3_preScarScore=-1 ;
88- fandi3_postScarScore=-1 ;
80+ fi1_largestSurfaceArea=-1 ;
81+ fi2_percentage=-1 ;
82+ fi2_largestSurfaceArea=-1 ;
83+ fi2_corridorSurfaceArea=-1 ;
84+ fi2_connectedAreasTotal=-1 ;
85+ fi3_preScarScoreSimple=-1 ;
86+ fi3_postScarScoreSimple=-1 ;
87+ fi3_totalPoints=-1 ;
88+ fi3_emptyPoints=-1 ;
89+ fi3_healthy = -1 ;
90+ fi3_preScar = -1 ;
91+ fi3_postScar = -1 ;
92+ fi3_overlapScar = -1 ;
8993 _debugScarAdvanced = false ;
9094}
9195
@@ -158,12 +162,34 @@ std::string CemrgScarAdvanced::ScarOverlap(
158162 temp->DeepCopy (prepd);
159163
160164 int valueassigned = 0 ;
165+ fi3_totalPoints = (double ) prepd->GetNumberOfPoints ();
166+ fi3_emptyPoints=0.0 ;
167+ fi3_healthy=0.0 ;
168+ fi3_preScar=0.0 ;
169+ fi3_postScar=0.0 ;
170+ fi3_overlapScar=0.0 ;
161171 for (int i=0 ;i<prepd->GetNumberOfPoints ();i++) {
162- if (scalars_pre->GetTuple1 (i)>=prethresh)
163- valueassigned +=1 ;
172+ if (scalars_post->GetTuple1 (i)==0 ){ // Veins were clipped here, no value
173+ valueassigned=-1 ;
174+ fi3_emptyPoints++;
175+ } else {
176+ if (scalars_pre->GetTuple1 (i)>=prethresh){
177+ valueassigned +=1 ;
178+ }
179+ if (scalars_post->GetTuple1 (i)>=postthresh){
180+ valueassigned +=2 ;
181+ }
164182
165- if (scalars_post->GetTuple1 (i)>=postthresh)
166- valueassigned +=2 ;
183+ if (valueassigned==0 ){
184+ fi3_healthy++;
185+ } else if (valueassigned==1 ){
186+ fi3_preScar++;
187+ } else if (valueassigned==2 ){
188+ fi3_postScar++;
189+ } else if (valueassigned==3 ){
190+ fi3_overlapScar++;
191+ }
192+ }
167193
168194 exploration_values->InsertNextTuple1 (valueassigned);
169195 valueassigned = 0 ;
@@ -205,8 +231,8 @@ std::string CemrgScarAdvanced::PrintThresholdResults(double mean, double stdv, d
205231 " \t STDev: " + num2str (stdv, 2 ) +
206232 " \n\n Value chosen: " + num2str (val,1 ) + " \n "
207233 " Threshold value: " + num2str (this ->_fill_threshold ,2 ) + " \n\n " +
208- " Surface Area of Ablation: " + num2str (this ->fandi1_largestSurfaceArea ,2 ) + " mm^2 \n " +
209- " Scar Score: " + num2str (this ->fandi1_scarScore ,2 ) + " %" ;
234+ " Surface Area of Ablation: " + num2str (this ->fi1_largestSurfaceArea ,2 ) + " mm^2 \n " +
235+ " Scar Score: " + num2str (this ->fi1_scarScore ,2 ) + " %" ;
210236
211237 SaveStrToFile (GetOutputPath (), _prefix + " _" + GetSurfaceAreaFilename (), out);
212238
@@ -220,10 +246,10 @@ std::string CemrgScarAdvanced::PrintAblationGapsResults(double mean, double stdv
220246 " \t STDev: " + num2str (stdv, 2 ) +
221247 " \n\n Value chosen: " + num2str (val,1 ) + " \n "
222248 " Threshold value: " + num2str (this ->_fill_threshold ,2 ) + " \n\n " +
223- " Num connected sections: " + num2str (this ->fandi2_connectedAreasTotal ,0 ) + " \n " +
224- " Percentage of scar in corridor : " + num2str (this ->fandi2_percentage ,2 ) + " %\t\n " +
225- " Largest thresholded area in corridor: " + num2str (this ->fandi2_largestSurfaceArea ,0 ) + " mm^2 \n " +
226- " Area of corridor: " + num2str (this ->fandi2_corridorSurfaceArea ,0 ) + " mm^2 \n " ;
249+ " Num connected sections: " + num2str (this ->fi2_connectedAreasTotal ,0 ) + " \n " +
250+ " Percentage of scar in corridor : " + num2str (this ->fi2_percentage ,2 ) + " %\t\n " +
251+ " Largest thresholded area in corridor: " + num2str (this ->fi2_largestSurfaceArea ,0 ) + " mm^2 \n " +
252+ " Area of corridor: " + num2str (this ->fi2_corridorSurfaceArea ,0 ) + " mm^2 \n " ;
227253 std::string strisweighted = (_weightedcorridor) ? " Weighted path" : " Geodesic" ;
228254 out = out + " \n Shortest path calculation: " + strisweighted + " \n " ;
229255
@@ -233,24 +259,31 @@ std::string CemrgScarAdvanced::PrintAblationGapsResults(double mean, double stdv
233259}
234260std::string CemrgScarAdvanced::PrintScarOverlapResults (double valpre, double valpost) {
235261
236- double ros = this ->fandi3_preScarScore / this ->fandi3_postScarScore ;
237- std::string out = " RESULTS:\n\n Scar Score in PRE-ablation: " ;
262+ std::string out = " RESULTS:\n\n Simple Scar Score in PRE-ablation: " ;
238263 if (valpre != valpost) {
239- out += num2str (this ->fandi3_preScarScore ,2 ) + " % \t (" +
264+ out += num2str (this ->fi3_preScarScoreSimple ,2 ) + " % \t (" +
240265 " Threshold value: " + num2str (valpre,1 ) + " )\n " +
241- " Scar Score in POST-ablation: " +
242- num2str (this ->fandi3_postScarScore ,2 ) + " % \t (" +
266+ " Simple Scar Score in POST-ablation: " +
267+ num2str (this ->fi3_postScarScoreSimple ,2 ) + " % \t (" +
243268 " Threshold value: " + num2str (valpost,1 ) + " )\n\n " ;
244269 } else {
245- out += num2str (this ->fandi3_preScarScore ,2 ) + " % \n " +
246- " Scar Score in POST-ablation: " +
247- num2str (this ->fandi3_postScarScore ,2 ) + " % \n " +
270+ out += num2str (this ->fi3_preScarScoreSimple ,2 ) + " % \n " +
271+ " Simple Scar Score in POST-ablation: " +
272+ num2str (this ->fi3_postScarScoreSimple ,2 ) + " % \n " +
248273 " (Both at threshold value: " + num2str (valpre,1 ) +" )" + " \n\n " ;
249274 }
250- out += " Percentage of PRE scar in POST scar: " + num2str (ros*100 ,3 ) + " %\n " ;
251275
276+ double total = fi3_totalPoints - fi3_emptyPoints;
277+ if (total>0 ){
278+ out += " \n OVERLAP RESULTS:\n\n HEALTHY % : " +
279+ num2str (100 *(fi3_healthy/total)) +
280+ " \n PRE-SCAR % : " + num2str (100 *(fi3_preScar/total)) +
281+ " \n POST-SCAR %: " + num2str (100 *(fi3_postScar/total)) +
282+ " \n OVERLAP % : " + num2str (100 *(fi3_overlapScar/total));
283+ } else {
284+ MITK_WARN << (" Points: " + QString::number (total)).toStdString ();
285+ }
252286 SaveStrToFile (GetOutputPath (), GetComparisonFilename (), out);
253-
254287 return out;
255288}
256289
@@ -290,12 +323,8 @@ void CemrgScarAdvanced::GetSurfaceAreaFromThreshold(double thres, double maxscal
290323 MITK_INFO << " MASS PROPERTIES (threshold):" ;
291324 MITK_INFO << mp->GetSurfaceArea ();
292325
293- this ->fandi1_largestSurfaceArea = mp->GetSurfaceArea ();
326+ this ->fi1_largestSurfaceArea = mp->GetSurfaceArea ();
294327
295- if (QString::fromStdString (_prefix).compare (" pre" , Qt::CaseInsensitive)==0 )
296- this ->fandi3_preSurfacePercentage = mp->GetSurfaceArea ();
297- else
298- this ->fandi3_postSurfacePercentage = mp->GetSurfaceArea ();
299328}
300329
301330void CemrgScarAdvanced::ScarScore (double thres) {
@@ -315,14 +344,14 @@ void CemrgScarAdvanced::ScarScore(double thres) {
315344 }
316345 double percentage = (ctr2*100.0 ) / (scalars->GetNumberOfTuples () - ctr1);
317346
318- fandi1_scarScore = percentage;
347+ fi1_scarScore = percentage;
319348
320349 if (QString::fromStdString (_prefix).compare (" pre" , Qt::CaseInsensitive)==0 ) {
321- this ->fandi3_preScarScore = percentage;
350+ this ->fi3_preScarScoreSimple = percentage;
322351 MITK_INFO << " PRE SCAR SCORE (" + _prefix + " ): " + num2str (percentage,2 );
323352 }
324353 else {
325- this ->fandi3_postScarScore = percentage;
354+ this ->fi3_postScarScoreSimple = percentage;
326355 MITK_INFO << " POST SCAR SCORE (" + _prefix + " ): " + num2str (percentage,2 );
327356 }
328357}
@@ -464,7 +493,7 @@ void CemrgScarAdvanced::ExtractCorridorData(
464493 MITK_INFO << connectivityFilter->GetNumberOfExtractedRegions ();
465494 connectivityFilter->SetExtractionModeToLargestRegion ();
466495 connectivityFilter->Update ();
467- fandi2_connectedAreasTotal = connectivityFilter->GetNumberOfExtractedRegions ();
496+ fi2_connectedAreasTotal = connectivityFilter->GetNumberOfExtractedRegions ();
468497
469498 vtkSmartPointer<vtkPolyDataConnectivityFilter> cf =
470499 vtkSmartPointer<vtkPolyDataConnectivityFilter>::New ();
@@ -490,13 +519,13 @@ void CemrgScarAdvanced::ExtractCorridorData(
490519 mp->SetInputConnection (cf->GetOutputPort ());
491520 MITK_INFO << " SURFACE AREA IN CORRIDOR (threshold):" ;
492521 MITK_INFO << mp->GetSurfaceArea ();
493- fandi2_largestSurfaceArea = mp->GetSurfaceArea ();
522+ fi2_largestSurfaceArea = mp->GetSurfaceArea ();
494523
495524 vtkSmartPointer<vtkMassProperties> mp2 = vtkSmartPointer<vtkMassProperties>::New ();
496525 mp2->SetInputConnection (cf2->GetOutputPort ());
497526 MITK_INFO << " SURFACE AREA IN CORRIDOR (full):" ;
498527 MITK_INFO << mp2->GetSurfaceArea ();
499- fandi2_corridorSurfaceArea = mp2->GetSurfaceArea ();
528+ fi2_corridorSurfaceArea = mp2->GetSurfaceArea ();
500529
501530 vtkSmartPointer<vtkPolyDataWriter> writercf =
502531 vtkSmartPointer<vtkPolyDataWriter>::New ();
@@ -524,7 +553,7 @@ void CemrgScarAdvanced::NeighbourhoodFillingPercentage(std::vector<int> points)
524553 }
525554
526555 double percentage_in_neighbourhood = 100 *(fillingcounter/total);
527- this ->fandi2_percentage = percentage_in_neighbourhood;
556+ this ->fi2_percentage = percentage_in_neighbourhood;
528557 MITK_INFO << (" [INFO] % scar in this neighbourhood = "
529558 + QString::number (percentage_in_neighbourhood) + " , threshold satisfy? "
530559 + (percentage_in_neighbourhood > _neighbourhood_size ? " Yes" :" No" )).toStdString ();
@@ -643,7 +672,7 @@ void CemrgScarAdvanced::getCorridorPoints(
643672 this ->_corridoridarray = pointIDsInCorridor;
644673}
645674
646- void CemrgScarAdvanced::CorridorFromPointList (std::vector<int > points) {
675+ void CemrgScarAdvanced::CorridorFromPointList (std::vector<int > points, bool circleToStart ) {
647676
648677 vtkSmartPointer<vtkPolyData> poly_data = vtkSmartPointer<vtkPolyData>::New ();
649678 poly_data = this ->GetSourcePolyData ();
@@ -654,16 +683,17 @@ void CemrgScarAdvanced::CorridorFromPointList(std::vector<int> points) {
654683 vtkSmartPointer<vtkDijkstraGraphGeodesicPath> dijkstra = vtkSmartPointer<vtkDijkstraGraphGeodesicPath>::New ();
655684 dijkstra->SetInputData (poly_data);
656685
657- if (this ->IsWeighted ())
686+ if (this ->IsWeighted ()){
658687 dijkstra->UseScalarWeightsOn ();
688+ }
659689
660690 dijkstra->Update ();
661691
662692 if (i<lim-1 ) {
663693 dijkstra->SetStartVertex (this ->_pointidarray [i]);
664694 dijkstra->SetEndVertex (this ->_pointidarray [i+1 ]);
665695 }
666- else {
696+ else if (circleToStart) {
667697 dijkstra->SetStartVertex (this ->_pointidarray [i]);
668698 dijkstra->SetEndVertex (this ->_pointidarray [0 ]);
669699 }
0 commit comments