diff --git a/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.cpp b/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.cpp index 3429186..27c1732 100644 --- a/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.cpp +++ b/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.cpp @@ -1,494 +1,906 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "mitkStreamlineInteractor.h" //#include "mitkStreamlineMapper2D.h" // MITK includes #include <mitkInteractionConst.h> #include <mitkInteractionPositionEvent.h> #include <mitkInternalEvent.h> #include <mitkLookupTableProperty.h> #include <mitkOperationEvent.h> #include <mitkRotationOperation.h> #include <mitkScaleOperation.h> #include <mitkSurface.h> #include <mitkUndoController.h> #include <mitkVtkMapper.h> // VTK includes #include <vtkCamera.h> #include <vtkInteractorObserver.h> #include <vtkInteractorStyle.h> #include <vtkMath.h> #include <vtkPointData.h> #include <vtkPolyData.h> #include <vtkRenderWindowInteractor.h> #include <vtkVector.h> #include <vtkPolyLine.h> #include <vtkVectorOperators.h> mitk::StreamlineInteractor::StreamlineInteractor() { m_ColorForHighlight[0] = 1.0; m_ColorForHighlight[1] = 0.5; m_ColorForHighlight[2] = 0.0; m_ColorForHighlight[3] = 1.0; // TODO if we want to get this configurable, the this is the recipe: // - make the 2D mapper add corresponding properties to control "enabled" and "color" // - make the interactor evaluate those properties // - in an ideal world, modify the state machine on the fly and skip mouse move handling } mitk::StreamlineInteractor::~StreamlineInteractor() { } void mitk::StreamlineInteractor::ConnectActionsAndFunctions() { // CONNECT_CONDITION("isoverstreamline", HasPickedHandle); CONNECT_FUNCTION("addnegstreamline", AddStreamlineNegBundle); CONNECT_FUNCTION("addposstreamline", AddStreamlinePosBundle); + CONNECT_FUNCTION("addnegtolabelstreamline", AddNegStreamlinetolabelsBundle); + CONNECT_FUNCTION("addpostolabelstreamline", AddPosStreamlinetolabelsBundle); // CONNECT_FUNCTION("FeedUndoStack", FeedUndoStack); } void mitk::StreamlineInteractor::SetNegativeNode(DataNode *node) { - DataInteractor::SetDataNode(node); +// DataInteractor::SetDataNode(node); + m_NegStreamlineNode = node; m_NegStreamline= dynamic_cast<mitk::FiberBundle *>(node->GetData()); MITK_INFO << "Negative Node added"; } void mitk::StreamlineInteractor::SetToLabelNode(DataNode *node) { - DataInteractor::SetDataNode(node); + m_manStreamlineNode = node; + DataInteractor::SetDataNode(m_manStreamlineNode); m_manStreamline = dynamic_cast<mitk::FiberBundle *>(node->GetData()); MITK_INFO << "Label node added"; } void mitk::StreamlineInteractor::SetPositiveNode(DataNode *node) { - DataInteractor::SetDataNode(node); + // DataInteractor::SetDataNode(node); + m_PosStreamlineNode = node; m_PosStreamline= dynamic_cast<mitk::FiberBundle *>(node->GetData()); MITK_INFO << "Positive Node added"; } void mitk::StreamlineInteractor::AddStreamlinePosBundle(StateMachineAction *, InteractionEvent *interactionEvent) { MITK_INFO << "PositiveBundle clicked"; + DataInteractor::SetDataNode(m_manStreamlineNode); auto positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent); if (positionEvent == nullptr) { MITK_INFO << "no position"; } if (interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D) { // m_PickedHandle = PickFrom2D(positionEvent); MITK_INFO << "2D"; BaseRenderer *renderer = positionEvent->GetSender(); auto &picker = m_Picker[renderer]; picker = vtkSmartPointer<vtkCellPicker>::New(); picker->SetTolerance(0.01); auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard2D); auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); if (vtk_mapper) { // doing this each time is bizarre picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); picker->PickFromListOn(); } // } auto displayPosition = positionEvent->GetPointerPositionOnScreen(); picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); vtkIdType pickedCellID = picker->GetCellId(); if (picker->GetCellId()==-1) { MITK_INFO << "Nothing picked"; } else { vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); unsigned int counter = 0; for ( int i=0; i<m_PosStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) { vtkCell* cell = m_PosStreamline->GetFiberPolyData()->GetCell(i); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } // weights->InsertValue(counter, fib->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(pickedCellID); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // m_PosStreamline = mitk::FiberBundle::New(vNewPolyData); m_PosStreamline->GetFiberPolyData()->SetPoints(vNewPoints); m_PosStreamline->GetFiberPolyData()->SetLines(vNewLines); m_PosStreamline->SetFiberColors(0, 255, 0); // m_PosStreamline->SetFiberWeights(m_PosStreamline->GetFiberWeights()); m_manStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); m_manStreamline->GetFiberPolyData()->RemoveDeletedCells(); } } else { BaseRenderer *renderer = positionEvent->GetSender(); auto &picker = m_Picker[renderer]; picker = vtkSmartPointer<vtkCellPicker>::New(); picker->SetTolerance(0.01); auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard3D); auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); if (vtk_mapper) { // doing this each time is bizarre picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); picker->PickFromListOn(); } // } auto displayPosition = positionEvent->GetPointerPositionOnScreen(); picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); vtkIdType pickedCellID = picker->GetCellId(); if (picker->GetCellId()==-1) { MITK_INFO << "Nothing picked"; } else { vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); unsigned int counter = 0; for ( int i=0; i<m_PosStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) { vtkCell* cell = m_PosStreamline->GetFiberPolyData()->GetCell(i); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } // weights->InsertValue(counter, fib->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(pickedCellID); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // m_PosStreamline = mitk::FiberBundle::New(vNewPolyData); m_PosStreamline->GetFiberPolyData()->SetPoints(vNewPoints); m_PosStreamline->GetFiberPolyData()->SetLines(vNewLines); m_PosStreamline->SetFiberColors(0, 255, 0); // m_PosStreamline->SetFiberWeights(m_PosStreamline->GetFiberWeights()); m_manStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); m_manStreamline->GetFiberPolyData()->RemoveDeletedCells(); } } RenderingManager::GetInstance()->RequestUpdateAll(); } void mitk::StreamlineInteractor::AddStreamlineNegBundle(StateMachineAction *, InteractionEvent *interactionEvent) { MITK_INFO << "NegativeBundle clicked"; -// auto positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent); -// if (positionEvent == nullptr) -// { -// return; -// } -// return true; + + DataInteractor::SetDataNode(m_manStreamlineNode); + auto positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent); if (positionEvent == nullptr) { MITK_INFO << "no position"; } if (interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D) { // m_PickedHandle = PickFrom2D(positionEvent); MITK_INFO << "2D"; BaseRenderer *renderer = positionEvent->GetSender(); auto &picker = m_Picker[renderer]; picker = vtkSmartPointer<vtkCellPicker>::New(); picker->SetTolerance(0.01); auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard2D); auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); if (vtk_mapper) { // doing this each time is bizarre picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); picker->PickFromListOn(); } // } auto displayPosition = positionEvent->GetPointerPositionOnScreen(); picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); vtkIdType pickedCellID = picker->GetCellId(); if (picker->GetCellId()==-1) { MITK_INFO << "Nothing picked"; } else { vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); unsigned int counter = 0; for ( int i=0; i<m_NegStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) { vtkCell* cell = m_NegStreamline->GetFiberPolyData()->GetCell(i); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } // weights->InsertValue(counter, fib->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(pickedCellID); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // m_NegStreamline = mitk::FiberBundle::New(vNewPolyData); m_NegStreamline->GetFiberPolyData()->SetPoints(vNewPoints); m_NegStreamline->GetFiberPolyData()->SetLines(vNewLines); - m_NegStreamline->SetFiberColors(0, 255, 0); + m_NegStreamline->SetFiberColors(255, 0, 0); // m_NegStreamline->SetFiberWeights(m_NegStreamline->GetFiberWeights()); m_manStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); m_manStreamline->GetFiberPolyData()->RemoveDeletedCells(); } } else { BaseRenderer *renderer = positionEvent->GetSender(); auto &picker = m_Picker[renderer]; // if (picker == nullptr) // { picker = vtkSmartPointer<vtkCellPicker>::New(); picker->SetTolerance(0.01); auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard3D); auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); if (vtk_mapper) { // doing this each time is bizarre picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); picker->PickFromListOn(); } // } auto displayPosition = positionEvent->GetPointerPositionOnScreen(); picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); vtkIdType pickedCellID = picker->GetCellId(); if (picker->GetCellId()==-1) { MITK_INFO << "Nothing picked"; } else { vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); unsigned int counter = 0; for ( int i=0; i<m_NegStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) { vtkCell* cell = m_NegStreamline->GetFiberPolyData()->GetCell(i); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } // weights->InsertValue(counter, fib->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(pickedCellID); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // m_NegStreamline = mitk::FiberBundle::New(vNewPolyData); m_NegStreamline->GetFiberPolyData()->SetPoints(vNewPoints); m_NegStreamline->GetFiberPolyData()->SetLines(vNewLines); m_NegStreamline->SetFiberColors(255, 0, 0); m_manStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); m_manStreamline->GetFiberPolyData()->RemoveDeletedCells(); } } RenderingManager::GetInstance()->RequestUpdateAll(); } + +void mitk::StreamlineInteractor::AddNegStreamlinetolabelsBundle(StateMachineAction *, InteractionEvent *interactionEvent) +{ + MITK_INFO << "TolabelBundle clicked"; + DataInteractor::SetDataNode(m_NegStreamlineNode); + + + auto positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent); + if (positionEvent == nullptr) + { + MITK_INFO << "no position"; + } + + if (interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D) + { +// m_PickedHandle = PickFrom2D(positionEvent); + + MITK_INFO << "2D"; + BaseRenderer *renderer = positionEvent->GetSender(); + + auto &picker = m_Picker[renderer]; + + picker = vtkSmartPointer<vtkCellPicker>::New(); + picker->SetTolerance(0.01); + auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard2D); + + auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); + if (vtk_mapper) + { // doing this each time is bizarre + picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); + picker->PickFromListOn(); + } +// } + + auto displayPosition = positionEvent->GetPointerPositionOnScreen(); + picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); + + vtkIdType pickedCellID = picker->GetCellId(); + + + + if (picker->GetCellId()==-1) + { + MITK_INFO << "Nothing picked"; + } + else { + + + vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); + vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); + vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); + + unsigned int counter = 0; + for ( int i=0; i<m_manStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) + { + + vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(i); + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + // weights->InsertValue(counter, fib->GetFiberWeight(i)); + vNewLines->InsertNextCell(container); + counter++; + + } + + + + vtkCell* cell = m_NegStreamline->GetFiberPolyData()->GetCell(pickedCellID); + + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + vNewLines->InsertNextCell(container); + + vNewPolyData->SetPoints(vNewPoints); + vNewPolyData->SetLines(vNewLines); + + // m_manStreamline = mitk::FiberBundle::New(vNewPolyData); + m_manStreamline->GetFiberPolyData()->SetPoints(vNewPoints); + m_manStreamline->GetFiberPolyData()->SetLines(vNewLines); + m_manStreamline->SetFiberColors(255, 255, 255); +// m_manStreamline->SetFiberWeights(m_manStreamline->GetFiberWeights()); + + m_NegStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); + m_NegStreamline->GetFiberPolyData()->RemoveDeletedCells(); + + + + + + } + } + else + { + BaseRenderer *renderer = positionEvent->GetSender(); + + auto &picker = m_Picker[renderer]; +// if (picker == nullptr) +// { + + + picker = vtkSmartPointer<vtkCellPicker>::New(); + picker->SetTolerance(0.01); + auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard3D); + + + auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); + if (vtk_mapper) + { // doing this each time is bizarre + picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); + picker->PickFromListOn(); + } +// } + + auto displayPosition = positionEvent->GetPointerPositionOnScreen(); + + picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); + + vtkIdType pickedCellID = picker->GetCellId(); + + + if (picker->GetCellId()==-1) + { + MITK_INFO << "Nothing picked"; + } + else + { + vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); + vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); + vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); + + unsigned int counter = 0; + for ( int i=0; i<m_manStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) + { + vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(i); + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + // weights->InsertValue(counter, fib->GetFiberWeight(i)); + vNewLines->InsertNextCell(container); + counter++; + + } + + + + vtkCell* cell = m_NegStreamline->GetFiberPolyData()->GetCell(pickedCellID); + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + vNewLines->InsertNextCell(container); + + vNewPolyData->SetPoints(vNewPoints); + vNewPolyData->SetLines(vNewLines); + + // m_manStreamline = mitk::FiberBundle::New(vNewPolyData); + m_manStreamline->GetFiberPolyData()->SetPoints(vNewPoints); + m_manStreamline->GetFiberPolyData()->SetLines(vNewLines); + m_manStreamline->SetFiberColors(255, 255, 255); + + m_NegStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); + m_NegStreamline->GetFiberPolyData()->RemoveDeletedCells(); + + } + } + RenderingManager::GetInstance()->RequestUpdateAll(); + } + +void mitk::StreamlineInteractor::AddPosStreamlinetolabelsBundle(StateMachineAction *, InteractionEvent *interactionEvent) +{ + MITK_INFO << "TolabelBundle clicked"; + DataInteractor::SetDataNode(m_PosStreamlineNode); + + + auto positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent); + if (positionEvent == nullptr) + { + MITK_INFO << "no position"; + } + + if (interactionEvent->GetSender()->GetMapperID() == BaseRenderer::Standard2D) + { +// m_PickedHandle = PickFrom2D(positionEvent); + + MITK_INFO << "2D"; + BaseRenderer *renderer = positionEvent->GetSender(); + + auto &picker = m_Picker[renderer]; + + picker = vtkSmartPointer<vtkCellPicker>::New(); + picker->SetTolerance(0.01); + auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard2D); + + auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); + if (vtk_mapper) + { // doing this each time is bizarre + picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); + picker->PickFromListOn(); + } +// } + + auto displayPosition = positionEvent->GetPointerPositionOnScreen(); + picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); + + vtkIdType pickedCellID = picker->GetCellId(); + + + + if (picker->GetCellId()==-1) + { + MITK_INFO << "Nothing picked"; + } + else { + + + vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); + vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); + vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); + + unsigned int counter = 0; + for ( int i=0; i<m_manStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) + { + + vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(i); + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + // weights->InsertValue(counter, fib->GetFiberWeight(i)); + vNewLines->InsertNextCell(container); + counter++; + + } + + + + vtkCell* cell = m_PosStreamline->GetFiberPolyData()->GetCell(pickedCellID); + + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + vNewLines->InsertNextCell(container); + + vNewPolyData->SetPoints(vNewPoints); + vNewPolyData->SetLines(vNewLines); + + // m_manStreamline = mitk::FiberBundle::New(vNewPolyData); + m_manStreamline->GetFiberPolyData()->SetPoints(vNewPoints); + m_manStreamline->GetFiberPolyData()->SetLines(vNewLines); + m_manStreamline->SetFiberColors(255, 255, 255); +// m_manStreamline->SetFiberWeights(m_manStreamline->GetFiberWeights()); + + m_PosStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); + m_PosStreamline->GetFiberPolyData()->RemoveDeletedCells(); + + + + + + } + } + else + { + BaseRenderer *renderer = positionEvent->GetSender(); + + auto &picker = m_Picker[renderer]; +// if (picker == nullptr) +// { + + + picker = vtkSmartPointer<vtkCellPicker>::New(); + picker->SetTolerance(0.01); + auto mapper = GetDataNode()->GetMapper(BaseRenderer::Standard3D); + + + auto vtk_mapper = dynamic_cast<VtkMapper *>(mapper); + if (vtk_mapper) + { // doing this each time is bizarre + picker->AddPickList(vtk_mapper->GetVtkProp(renderer)); + picker->PickFromListOn(); + } +// } + + auto displayPosition = positionEvent->GetPointerPositionOnScreen(); + + picker->Pick(displayPosition[0], displayPosition[1], 0, positionEvent->GetSender()->GetVtkRenderer()); + + vtkIdType pickedCellID = picker->GetCellId(); + + + if (picker->GetCellId()==-1) + { + MITK_INFO << "Nothing picked"; + } + else + { + vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); + vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); + vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); + + unsigned int counter = 0; + for ( int i=0; i<m_manStreamline->GetFiberPolyData()->GetNumberOfCells(); i++) + { + vtkCell* cell = m_manStreamline->GetFiberPolyData()->GetCell(i); + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + // weights->InsertValue(counter, fib->GetFiberWeight(i)); + vNewLines->InsertNextCell(container); + counter++; + + } + + + + vtkCell* cell = m_PosStreamline->GetFiberPolyData()->GetCell(pickedCellID); + auto numPoints = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + + vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); + for (unsigned int j=0; j<numPoints; j++) + { + double p[3]; + points->GetPoint(j, p); + + vtkIdType id = vNewPoints->InsertNextPoint(p); + container->GetPointIds()->InsertNextId(id); + } + vNewLines->InsertNextCell(container); + + vNewPolyData->SetPoints(vNewPoints); + vNewPolyData->SetLines(vNewLines); + + // m_manStreamline = mitk::FiberBundle::New(vNewPolyData); + m_manStreamline->GetFiberPolyData()->SetPoints(vNewPoints); + m_manStreamline->GetFiberPolyData()->SetLines(vNewLines); + m_manStreamline->SetFiberColors(255, 255, 255); + + m_PosStreamline->GetFiberPolyData()->DeleteCell(pickedCellID); + m_PosStreamline->GetFiberPolyData()->RemoveDeletedCells(); + + } + } + RenderingManager::GetInstance()->RequestUpdateAll(); + } + diff --git a/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.h b/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.h index 3c70b41..7b6fb30 100644 --- a/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.h +++ b/Modules/FiberDissection/Interactor/mitkStreamlineInteractor.h @@ -1,106 +1,112 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkStreamlineInteractor_h #define mitkStreamlineInteractor_h #include "MitkFiberDissectionExports.h" // MITK includes #include <mitkDataInteractor.h> #include <mitkDataNode.h> #include <mitkGeometry3D.h> #include <mitkFiberBundle.h> // VTK includes #include <vtkCellPicker.h> #include <vtkSmartPointer.h> // System includes #include <memory> namespace mitk { class InteractionPositionEvent; //! Data interactor to pick streamlines via interaction //! with a mitk::Streamline. //! //! //! To determine what parts of the object are clicked during interaction, //! the mappers (2D: custom mapper, 3D: regular surface mapper) are asked //! for their VTK objects, picking is performed, and the picked point is //! forwarded to the Streamline object for interpretation. //! //! The interactor fills the undo/redo stack with operations on the modified geometry. //! //! \sa Streamline class MITKFIBERDISSECTION_EXPORT StreamlineInteractor : public DataInteractor { public: mitkClassMacro(StreamlineInteractor, DataInteractor); itkFactorylessNewMacro(Self); itkCloneMacro(Self); //! The node holding the Fiberbundle for visual feedback. //! This is the node that the interactor is primarily working on //! (calls DataInteractor::SetDataNode). void SetNegativeNode(DataNode *node); void SetToLabelNode(DataNode *node); void SetPositiveNode(DataNode *node); protected: void AddStreamlineNegBundle(StateMachineAction *, InteractionEvent *interactionEvent); void AddStreamlinePosBundle(StateMachineAction *, InteractionEvent *interactionEvent); + void AddNegStreamlinetolabelsBundle(StateMachineAction *, InteractionEvent *interactionEvent); + + void AddPosStreamlinetolabelsBundle(StateMachineAction *, InteractionEvent *interactionEvent); std::map<BaseRenderer *, vtkSmartPointer<vtkCellPicker>> m_Picker; private: StreamlineInteractor(); ~StreamlineInteractor() override; //! Setup the relation between the XML state machine and this object's methods. void ConnectActionsAndFunctions() override; //! State machine condition: successful Streamline picking //! \return true when any part of the Streamline has been picked. // bool HasPickedHandle(const InteractionEvent *); // void DecideInteraction(StateMachineAction *, InteractionEvent *interactionEvent); // //! Pick a Streamline handle from a 2D event (passing by the 2D mapper) // Streamline::HandleType PickFrom2D(const InteractionPositionEvent *positionEvent); // //! Pick a Streamline handle from a 3D event // //! (passing by the general surface mapper and the Streamline object) // Streamline::HandleType PickFrom3D(const InteractionPositionEvent *positionEvent); // void UpdateHandleHighlight(); //! the Streamline used for visual feedback and picking - mitk::FiberBundle::Pointer m_NegStreamline; - mitk::FiberBundle::Pointer m_PosStreamline; - mitk::FiberBundle::Pointer m_manStreamline; + mitk::FiberBundle::Pointer m_NegStreamline; + mitk::FiberBundle::Pointer m_PosStreamline; + mitk::FiberBundle::Pointer m_manStreamline; + mitk::DataNode::Pointer m_NegStreamlineNode; + mitk::DataNode::Pointer m_PosStreamlineNode; + mitk::DataNode::Pointer m_manStreamlineNode; vtkSmartPointer<vtkPolyData> m_extracted_streamline; double m_ColorForHighlight[4]; }; } #endif diff --git a/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.cpp b/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.cpp index 1985ce1..b2804c6 100644 --- a/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.cpp +++ b/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.cpp @@ -1,671 +1,716 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkStreamlineFeatureExtractor.h" #define _USE_MATH_DEFINES #include <math.h> #include <boost/progress.hpp> #include <vnl/vnl_sparse_matrix.h> #include <mitkIOUtil.h> namespace mitk{ StreamlineFeatureExtractor::StreamlineFeatureExtractor() : m_NumPoints(40) { } StreamlineFeatureExtractor::~StreamlineFeatureExtractor() { } void StreamlineFeatureExtractor::SetTractogramPlus(const mitk::FiberBundle::Pointer &TractogramPlus) { m_TractogramPlus = TractogramPlus; } void StreamlineFeatureExtractor::SetTractogramMinus(const mitk::FiberBundle::Pointer &TractogramMinus) { m_TractogramMinus = TractogramMinus; } +void StreamlineFeatureExtractor::SetActiveCycle(int &activeCycle) +{ + m_activeCycle= activeCycle; +} + void StreamlineFeatureExtractor::SetTractogramTest(const mitk::FiberBundle::Pointer &TractogramTest, std::string TractogramTestName) { std::string path = "/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/storage/"; path.append(TractogramTestName); m_TractogramTest= TractogramTest; auto s = std::to_string(m_NumPoints); m_DistancesTestName= path.append("_distances" + s + ".csv"); } std::vector<vnl_matrix<float> > StreamlineFeatureExtractor::ResampleFibers(mitk::FiberBundle::Pointer tractogram) { mitk::FiberBundle::Pointer temp_fib = tractogram->GetDeepCopy(); temp_fib->ResampleToNumPoints(m_NumPoints); MITK_INFO << "Resampling Done"; std::vector< vnl_matrix<float> > out_fib(temp_fib->GetFiberPolyData()->GetNumberOfCells()); // std::vector< vnl_matrix<float> > out_fib(); // cv::parallel_for_(cv::Range(0, temp_fib->GetFiberPolyData()->GetNumberOfCells()), [&](const cv::Range &range) // { // for (int i = range.start; i < range.end; i++) // #pragma omp parallel for // #pragma omp parallel for num_threads(10) collapse(1) for (int i=0; i<temp_fib->GetFiberPolyData()->GetNumberOfCells(); i++) { vtkCell* cell = temp_fib->GetFiberPolyData()->GetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vnl_matrix<float> streamline; streamline.set_size(3, m_NumPoints); streamline.fill(0.0); for (int j=0; j<numPoints; j++) { double cand[3]; points->GetPoint(j, cand); vnl_vector_fixed< float, 3 > candV; candV[0]=cand[0]; candV[1]=cand[1]; candV[2]=cand[2]; streamline.set_column(j, candV); } // out_fib.push_back(streamline); out_fib.at(i)=streamline; } // }); return out_fib; } std::vector<vnl_matrix<float> > StreamlineFeatureExtractor::CalculateDmdf(std::vector<vnl_matrix<float> > tractogram, std::vector<vnl_matrix<float> > prototypes, - std::vector<vnl_matrix<float> > local_prototypes) + std::vector<vnl_matrix<float> > positive_local_prototypes, + std::vector<vnl_matrix<float> > negative_local_prototypes) { - unsigned int locals; - if (local_prototypes.size() >= 100) + unsigned int pos_locals; + unsigned int neg_locals; + if (positive_local_prototypes.size() >= 50) { - locals = 100; + pos_locals= 50; } else { - locals = local_prototypes.size(); + pos_locals= positive_local_prototypes.size(); + } + + if (pos_locals <= positive_local_prototypes.size()) + { + neg_locals = pos_locals; } + else { + neg_locals= negative_local_prototypes.size(); + } + + MITK_INFO << "Locals:"; - MITK_INFO << locals; + MITK_INFO << neg_locals + pos_locals; std::vector<vnl_matrix<float> > merged_prototypes; for (unsigned int k=0; k<prototypes.size(); k++ ) { merged_prototypes.push_back(prototypes.at(k)); } - for (unsigned int k=0; k<locals; k++ ) + for (unsigned int k=0; k<pos_locals; k++ ) { - merged_prototypes.push_back(local_prototypes.at(k)); + merged_prototypes.push_back(positive_local_prototypes.at(k)); } -// MITK_INFO << "merged_prototypes"; -// MITK_INFO << merged_prototypes.size(); + for (unsigned int k=0; k<neg_locals; k++ ) + { + merged_prototypes.push_back(negative_local_prototypes.at(k)); + } + + MITK_INFO << "merged_prototypes"; + MITK_INFO << merged_prototypes.size(); std::vector< vnl_matrix<float> > dist_vec(tractogram.size());// MITK_INFO << "Start Calculating Dmdf"; cv::parallel_for_(cv::Range(0, tractogram.size()), [&](const cv::Range &range) { for (int i = range.start; i < range.end; i++) // for (unsigned int i=0; i<tractogram.size(); i++) { vnl_matrix<float> distances; - distances.set_size(1, local_prototypes.size()); + distances.set_size(1, merged_prototypes.size()); distances.fill(0.0); - for (unsigned int j=0; j<local_prototypes.size(); j++) + for (unsigned int j=0; j<merged_prototypes.size(); j++) { vnl_matrix<float> single_distances; single_distances.set_size(1, tractogram.at(0).cols()); single_distances.fill(0.0); vnl_matrix<float> single_distances_flip; single_distances_flip.set_size(1, tractogram.at(0).cols()); single_distances_flip.fill(0.0); for (unsigned int ik=0; ik<tractogram.at(0).cols(); ik++) { double cur_dist; double cur_dist_flip; - cur_dist = sqrt(pow(tractogram.at(i).get(0,ik) - local_prototypes.at(j).get(0,ik), 2.0) + - pow(tractogram.at(i).get(1,ik) - local_prototypes.at(j).get(1,ik), 2.0) + - pow(tractogram.at(i).get(2,ik) - local_prototypes.at(j).get(2,ik), 2.0)); + cur_dist = sqrt(pow(tractogram.at(i).get(0,ik) - merged_prototypes.at(j).get(0,ik), 2.0) + + pow(tractogram.at(i).get(1,ik) - merged_prototypes.at(j).get(1,ik), 2.0) + + pow(tractogram.at(i).get(2,ik) - merged_prototypes.at(j).get(2,ik), 2.0)); - cur_dist_flip = sqrt(pow(tractogram.at(i).get(0,ik) - local_prototypes.at(j).get(0,local_prototypes.at(0).cols()-(ik+1)), 2.0) + - pow(tractogram.at(i).get(1,ik) - local_prototypes.at(j).get(1,local_prototypes.at(0).cols()-(ik+1)), 2.0) + - pow(tractogram.at(i).get(2,ik) - local_prototypes.at(j).get(2,local_prototypes.at(0).cols()-(ik+1)), 2.0)); + cur_dist_flip = sqrt(pow(tractogram.at(i).get(0,ik) - merged_prototypes.at(j).get(0,merged_prototypes.at(0).cols()-(ik+1)), 2.0) + + pow(tractogram.at(i).get(1,ik) - merged_prototypes.at(j).get(1,merged_prototypes.at(0).cols()-(ik+1)), 2.0) + + pow(tractogram.at(i).get(2,ik) - merged_prototypes.at(j).get(2,merged_prototypes.at(0).cols()-(ik+1)), 2.0)); single_distances.put(0,ik, cur_dist); single_distances_flip.put(0,ik, cur_dist_flip); } if (single_distances_flip.mean()> single_distances.mean()) { distances.put(0,j, single_distances.mean()); } else { distances.put(0,j, single_distances_flip.mean()); } } // dist_vec.push_back(distances); dist_vec.at(i) = distances; } }); MITK_INFO << "Done Calculation"; MITK_INFO << dist_vec.at(0).size(); return dist_vec; } std::vector<std::vector<unsigned int>> StreamlineFeatureExtractor::GetData() { MITK_INFO << "Start Function Get Data"; + MITK_INFO << m_DistancesPlus.at(0); /*Vector which saves Prediction and Fibers to label based on uncertainty*/ std::vector<std::vector<unsigned int>> index_vec; - int labels_arr [m_DistancesPlus.size()+m_DistancesMinus.size()]; +// int labels_arr [m_DistancesPlus.size()+m_DistancesMinus.size()]; cv::Mat data; cv::Mat labels_arr_vec; int size_plus = 0; /*Create Trainingdata: Go through positive and negative Bundle and save distances as cv::Mat and create vector with labels*/ for ( unsigned int i=0; i<m_DistancesPlus.size(); i++) { float data_arr [m_DistancesPlus.at(0).size()]; - labels_arr[i]=1; +// labels_arr[i]=1; labels_arr_vec.push_back(1); for ( unsigned int j=0; j<m_DistancesPlus.at(0).cols(); j++) { data_arr[j] = m_DistancesPlus.at(i).get(0,j); } cv::Mat curdata(1, m_DistancesPlus.at(0).size(), CV_32F, data_arr); data.push_back(curdata); size_plus++; } for ( unsigned int i=m_DistancesPlus.size(); i<m_DistancesPlus.size()+m_DistancesMinus.size(); i++) { int it = i - size_plus; float data_arr [m_DistancesMinus.at(0).size()]; - labels_arr[i]=0; +// labels_arr[i]=0; labels_arr_vec.push_back(0); for ( unsigned int j=0; j<m_DistancesMinus.at(0).cols(); j++) { data_arr[j] = m_DistancesMinus.at(it).get(0,j); } cv::Mat curdata(1, m_DistancesPlus.at(0).size(), CV_32F, data_arr); data.push_back(curdata); } + MITK_INFO << data.cols; + MITK_INFO << data.rows; /*Calculate weights*/ int zerosgt = labels_arr_vec.rows - cv::countNonZero(labels_arr_vec); int onesgt = cv::countNonZero(labels_arr_vec); float plusval = labels_arr_vec.rows / (2.0 * onesgt ); float minusval = labels_arr_vec.rows / (2.0 * zerosgt ); - cv::Mat newweight; newweight.push_back(minusval); newweight.push_back(plusval); MITK_INFO << "Weights"; MITK_INFO << newweight; - cv::Mat labels(m_DistancesPlus.size()+m_DistancesMinus.size(), 1, CV_32S, labels_arr); + /*Shuffle Data*/ + std::vector <int> seeds; + for (int cont = 0; cont < labels_arr_vec.rows; cont++) + { + seeds.push_back(cont); + } + + cv::randShuffle(seeds); + cv::Mat labels_shuffled; + cv::Mat samples_shuffled; + for (int cont = 0; cont < labels_arr_vec.rows; cont++) + { + labels_shuffled.push_back(labels_arr_vec.row(seeds[cont])); + } + + for (int cont = 0; cont < labels_arr_vec.rows; cont++) + { + samples_shuffled.push_back(data.row(seeds[cont])); + } + + // std::ofstream myfile1; // myfile1.open("/home/r948e/mycsv/labels.csv"); -// myfile1<< cv::format(labels, cv::Formatter::FMT_CSV) << std::endl; +// myfile1<< cv::format(labels_shuffled, cv::Formatter::FMT_CSV) << std::endl; // myfile1.close(); // std::ofstream myfile2; // myfile2.open("/home/r948e/mycsv/features.csv"); // myfile2<< cv::format(data, cv::Formatter::FMT_CSV) << std::endl; // myfile2.close(); - cv::Ptr<cv::ml::TrainData> m_traindata = cv::ml::TrainData::create(data, cv::ml::ROW_SAMPLE, labels); + + + /*Create Dataset and initialize Classifier*/ + cv::Ptr<cv::ml::TrainData> m_traindata = cv::ml::TrainData::create(samples_shuffled, cv::ml::ROW_SAMPLE, labels_shuffled); + MITK_INFO << m_traindata->getSamples(); // m_traindata->setTrainTestSplitRatio(0.95, true); - m_traindata->shuffleTrainTest(); + MITK_INFO << m_traindata->getResponses(); +// m_traindata->shuffleTrainTest(); MITK_INFO << m_traindata->getClassLabels(); MITK_INFO << "Start Training"; auto statistic_model = cv::ml::RTrees::create(); auto criteria = cv::TermCriteria(); criteria.type = cv::TermCriteria::MAX_ITER; // criteria.epsilon = 1e-8; criteria.maxCount = 800; -// statistic_model->setMaxCategories(2); statistic_model->setMaxDepth(50); //set to three // statistic_model->setMinSampleCount(m_traindata->getNTrainSamples()*0.01); statistic_model->setMinSampleCount(2); statistic_model->setTruncatePrunedTree(false); statistic_model->setUse1SERule(false); statistic_model->setUseSurrogates(false); statistic_model->setTermCriteria(criteria); statistic_model->setCVFolds(1); statistic_model->setPriors(newweight); + /*Train Classifier*/ statistic_model->train(m_traindata); - + /*Predict on Test Data*/ MITK_INFO << "Predicting"; - + /*Create Dataset as cv::Mat*/ cv::Mat dataTest; - for ( unsigned int i=0; i<m_DistancesTest.size(); i++) { float data_arr [m_DistancesTest.at(0).size()]; for ( unsigned int j=0; j<m_DistancesTest.at(0).cols(); j++) { data_arr[j] = m_DistancesTest.at(i).get(0,j); } cv::Mat curdata(1, m_DistancesTest.at(0).size(), CV_32F, data_arr); dataTest.push_back(curdata); } - std::vector<unsigned int> index; + std::vector<unsigned int> indexPrediction; std::vector<float> e(m_DistancesTest.size()); -// cv::setNumThreads(16); -// cv::parallel_for_(cv::Range(0, m_DistancesTest.size()), [&](const cv::Range &range) -// { -// for (int i = range.start; i < range.end; i++) -#pragma omp parallel for + + /*For every Sample/Streamline get Prediction and entropy (=based on counts of Random Forest)*/ +#pragma omp parallel for num_threads(18) for (unsigned int i=0; i<m_DistancesTest.size(); i++) { int val = statistic_model->predict(dataTest.row(i)); if (val==1) { - index.push_back(i); + indexPrediction.push_back(i); } cv::Mat vote; statistic_model->getVotes(dataTest.row(i), vote, 0); e.at(i) = ( -(vote.at<int>(1,0)*1.0)/ (vote.at<int>(1,0)+vote.at<int>(1,1)) * log2((vote.at<int>(1,0)*1.0)/ (vote.at<int>(1,0)+vote.at<int>(1,1))) - (vote.at<int>(1,1)*1.0)/ (vote.at<int>(1,0)+vote.at<int>(1,1))* log2((vote.at<int>(1,1)*1.0)/ (vote.at<int>(1,0)+vote.at<int>(1,1)))); if (isnan(e.at(i))) { e.at(i)=0; -// MITK_INFO << e.at(i); } - if (i==1) - { - MITK_INFO<< val; - MITK_INFO << vote; - } } -// }); -// std::ofstream myfile3; -// myfile3.open("/home/r948e/mycsv/entropydata.csv"); - -// for (unsigned int i = 0; i < e.size(); i++) { -// myfile3 << e.at(i) << ' '; -// } -// myfile3.close(); + /*Save entropy values for analysis*/ + std::ofstream myfile3; + auto s = std::to_string(m_activeCycle); + myfile3.open("/home/r948e/mycsv/entropydata" + s + ".csv"); + for (unsigned int i = 0; i < e.size(); i++) + { + myfile3 << e.at(i) << ' '; + } + myfile3.close(); MITK_INFO << "--------------"; MITK_INFO << "Prediction vector size:"; - MITK_INFO << index.size(); + MITK_INFO << indexPrediction.size(); MITK_INFO << "Entropy vector size:"; MITK_INFO << e.size(); MITK_INFO << "--------------"; - auto it = std::minmax_element(e.begin(), e.end()); - int min_idx = std::distance(e.begin(), it.first); - int max_idx = std::distance(e.begin(), it.second); - std::cout << min_idx << ", " << max_idx << std::endl; // 1, 5 - MITK_INFO << e.at(max_idx); + /*Get index of most unertain data (lengths defines how many data is saved)*/ + int lengths=1000; +// auto it = std::minmax_element(e.begin(), e.end()); +// int min_idx = std::distance(e.begin(), it.first); +// int max_idx = std::distance(e.begin(), it.second); - MITK_INFO << "Start the ordering"; - std::vector<unsigned int> indextolabel; + std::vector<unsigned int> indexUnc; std::priority_queue<std::pair<float, int>> q; for (unsigned int i = 0; i < e.size(); ++i) { q.push(std::pair<float, int>(e[i], i)); } -// int k = m_DistancesTest.size(); // number of indices we need - int lengths=500; -// int k = lengths; // number of indices we need + +// auto lengths = std::count_if(e.begin(), e.end(),[&](auto const& val){ return val >= 0.9; }); + MITK_INFO << "Streamlines with uncertainty higher than 0.9"; + MITK_INFO << lengths; + for (int i = 0; i < lengths; ++i) { int ki = q.top().second; - indextolabel.push_back(ki); + indexUnc.push_back(ki); q.pop(); } // std::ofstream myfile4; -// myfile4.open("/home/r948e/mycsv/indextolabel.csv"); -// for (unsigned int i = 0; i < indextolabel.size(); i++) +// myfile4.open("/home/r948e/mycsv/indexUnc.csv"); +// for (unsigned int i = 0; i < indexUnc.size(); i++) // { -// myfile4 << indextolabel.at(i) << ' '; +// myfile4 << indexUnc.at(i) << ' '; // } // myfile4.close(); + // Sorted depent on entropy now sort the 1/5 vnl_matrix<float> distances_matrix; distances_matrix.set_size(lengths, lengths); distances_matrix.fill(0.0); MITK_INFO << "Dist_start"; std::vector<float> distances_matrix_mean; for (int i=0; i<lengths; i++) { for (int k=0; k<lengths; k++) { - vnl_matrix<float> diff = m_DistancesTest.at(indextolabel.at(i)) - m_DistancesTest.at(indextolabel.at(k)); + vnl_matrix<float> diff = m_DistancesTest.at(indexUnc.at(i)) - m_DistancesTest.at(indexUnc.at(k)); distances_matrix.put(i,k,diff.absolute_value_sum()/m_DistancesTest.at(0).size()); } distances_matrix_mean.push_back(distances_matrix.get_row(i).mean()); // MITK_INFO << meanval.at(i); } vnl_vector<float> sum_matrix; sum_matrix.set_size(lengths); sum_matrix.fill(0.0); /*Index to find values is distancematrix*/ std::vector<unsigned int> myidx; - /*Index to find actual streamlines using indextolabel*/ - std::vector<unsigned int> distindextolabel; + /*Index to find actual streamlines using indexUnc*/ + std::vector<unsigned int> indexUncDist; myidx.push_back(0); // MITK_INFO << distances_matrix.get_row(myidx.at(i)+ sum_matrix.get_row(0) for (int i=0; i<lengths; i++) { -// unsigned int cur_i = indextolabel.at(myidx.at(i)); +// unsigned int cur_i = indexUnc.at(myidx.at(i)); sum_matrix = (sum_matrix + distances_matrix.get_row(myidx.at(i)))/=(i+1); // myidx.push_back(distances_matrix.get_row(myidx.at(i)).arg_max()); myidx.push_back(sum_matrix.arg_max()); - distindextolabel.push_back(indextolabel.at(myidx.at(i))); + indexUncDist.push_back(indexUnc.at(myidx.at(i))); distances_matrix.set_column(myidx.at(i), 0.0001); } - std::vector<unsigned int> indextolabeldist; + std::vector<unsigned int> indexUncdist; std::priority_queue<std::pair<float, int>> qq; for (unsigned int i = 0; i < distances_matrix_mean.size(); ++i) { qq.push(std::pair<float, int>(distances_matrix_mean[i], i)); } // int k = m_DistancesTest.size(); // number of indices we need // int k = lengths; // number of indices we need for (int i = 0; i < lengths; ++i) { int kki = qq.top().second; - indextolabeldist.push_back(indextolabel.at(kki)); + indexUncdist.push_back(indexUnc.at(kki)); qq.pop(); } MITK_INFO << "Dist_stop"; // std::ofstream myfile6; // myfile6.open("/home/r948e/mycsv/distances_matrix_mean.csv"); // for (unsigned int i = 0; i < distances_matrix_mean.size(); i++) // { // myfile6 << distances_matrix_mean.at(i) << ' '; // } // myfile6.close(); // std::ofstream myfile5; -// myfile5.open("/home/r948e/mycsv/indextolabeldist.csv"); -// for (unsigned int i = 0; i < indextolabeldist.size(); i++) +// myfile5.open("/home/r948e/mycsv/indexUncdist.csv"); +// for (unsigned int i = 0; i < indexUncdist.size(); i++) // { -// myfile5 << indextolabeldist.at(i) << ' '; +// myfile5 << indexUncdist.at(i) << ' '; // } // myfile5.close(); // MITK_INFO << distances_matrix; // MITK_INFO << distances_matrix.max_value(); // MITK_INFO << distances_matrix.arg_max(); -// vnl_matrix<float> myx = m_DistancesTest.at(indextolabel.at(0)) - m_DistancesTest.at(indextolabel.at(1)); -//// myx = (m_DistancesTest.at(indextolabel.at(0)) - m_DistancesTest.at(indextolabel.at(1))); -// MITK_INFO << m_DistancesTest.at(indextolabel.at(0)); -// MITK_INFO << m_DistancesTest.at(indextolabel.at(1)); +// vnl_matrix<float> myx = m_DistancesTest.at(indexUnc.at(0)) - m_DistancesTest.at(indexUnc.at(1)); +//// myx = (m_DistancesTest.at(indexUnc.at(0)) - m_DistancesTest.at(indexUnc.at(1))); +// MITK_INFO << m_DistancesTest.at(indexUnc.at(0)); +// MITK_INFO << m_DistancesTest.at(indexUnc.at(1)); // MITK_INFO << myx.get(0,0); // MITK_INFO << sqrt(pow(myx.get(0,0),2)); // MITK_INFO << myx.get(0,1); // MITK_INFO << myx.absolute_value_sum()/m_DistancesTest.at(0).size(); // MITK_INFO << "Done"; - - index_vec.push_back(index); - index_vec.push_back(indextolabel); - index_vec.push_back(distindextolabel); + /*Save Prediction*/ + index_vec.push_back(indexPrediction); + /*Save index of uncertainty measures*/ + index_vec.push_back(indexUnc); + /*Save index of uncertainty measures influenced by distance*/ + index_vec.push_back(indexUncDist); return index_vec; } mitk::FiberBundle::Pointer StreamlineFeatureExtractor::CreatePrediction(std::vector<unsigned int> &index) { mitk::FiberBundle::Pointer Prediction; MITK_INFO << "Create Bundle"; vtkSmartPointer<vtkPolyData> FibersData; FibersData = vtkSmartPointer<vtkPolyData>::New(); FibersData->SetPoints(vtkSmartPointer<vtkPoints>::New()); FibersData->SetLines(vtkSmartPointer<vtkCellArray>::New()); vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); unsigned int indexSize = index.size(); unsigned int counter = 0; MITK_INFO << "Start Loop"; for (unsigned int i=0; i<indexSize; i++) { vtkCell* cell = m_TractogramTest->GetFiberPolyData()->GetCell(index[i]); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } // weights->InsertValue(counter, fib->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } MITK_INFO << "Counter"; MITK_INFO << counter; vNewPolyData->SetLines(vNewLines); vNewPolyData->SetPoints(vNewPoints); FibersData = vtkSmartPointer<vtkPolyData>::New(); FibersData->SetPoints(vtkSmartPointer<vtkPoints>::New()); FibersData->SetLines(vtkSmartPointer<vtkCellArray>::New()); FibersData->SetPoints(vNewPoints); FibersData->SetLines(vNewLines); Prediction = mitk::FiberBundle::New(vNewPolyData); // Bundle->SetFiberColors(255, 255, 255); MITK_INFO << "Cells Prediciton"; MITK_INFO << Prediction->GetFiberPolyData()->GetNumberOfCells(); MITK_INFO << "Cells Tractorgram"; MITK_INFO << m_TractogramTest->GetFiberPolyData()->GetNumberOfCells(); return Prediction; } void StreamlineFeatureExtractor::GenerateData() { MITK_INFO << "Update"; mitk::FiberBundle::Pointer inputPrototypes = mitk::IOUtil::Load<mitk::FiberBundle>("/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/prototypes_599671.trk"); T_Prototypes = ResampleFibers(inputPrototypes); T_TractogramMinus= ResampleFibers(m_TractogramMinus); T_TractogramPlus= ResampleFibers(m_TractogramPlus); MITK_INFO << "Calculate Features"; - m_DistancesMinus = CalculateDmdf(T_TractogramMinus, T_Prototypes, T_TractogramPlus); - m_DistancesPlus = CalculateDmdf(T_TractogramPlus, T_Prototypes, T_TractogramPlus); + m_DistancesMinus = CalculateDmdf(T_TractogramMinus, T_Prototypes, T_TractogramPlus, T_TractogramMinus); + m_DistancesPlus = CalculateDmdf(T_TractogramPlus, T_Prototypes, T_TractogramPlus, T_TractogramMinus); std::ifstream f(m_DistancesTestName); MITK_INFO << m_DistancesTestName; if (f.good()) { MITK_INFO << "File exists"; m_DistancesTest.clear(); std::ifstream myFile(m_DistancesTestName); if(!myFile.is_open()) throw std::runtime_error("Could not open file"); std::string line; vnl_matrix<float> curline; curline.set_size(1, m_DistancesPlus.at(0).cols()); curline.fill(0.0); float val; while(std::getline(myFile, line)) { // Create a stringstream of the current line std::stringstream ss(line); // MITK_INFO << ss; // Keep track of the current column index int colIdx = 0; // Extract each integer while(ss >> val){ // // Add the current integer to the 'colIdx' column's values vector curline.put(0,colIdx, val); // // If the next token is a comma, ignore it and move on // if(ss.peek() == ',') ss.ignore(); // // Increment the column index colIdx++; } m_DistancesTest.push_back(curline); } // Close file myFile.close(); } else { MITK_INFO << m_DistancesTestName; MITK_INFO << "Resample Test Data"; T_TractogramTest= ResampleFibers(m_TractogramTest); MITK_INFO << "Calculate Features of Test Data"; - m_DistancesTest= CalculateDmdf(T_TractogramTest, T_Prototypes, T_TractogramPlus); + m_DistancesTest= CalculateDmdf(T_TractogramTest, T_Prototypes, T_TractogramPlus, T_TractogramMinus); // std::ofstream myFile(m_DistancesTestName); //// myFile << colname << "\n"; // for(long unsigned int i = 0; i < m_DistancesTest.size(); ++i) // { // myFile << m_DistancesTest.at(i); // } // myFile.close(); } MITK_INFO << m_DistancesTest.size(); MITK_INFO << "Sizes of Plus and Minus"; MITK_INFO << m_DistancesPlus.size() + m_DistancesMinus.size(); MITK_INFO << "Size of Test Data"; MITK_INFO << m_DistancesTest.size(); MITK_INFO << "Done with Datacreation"; m_index =GetData(); } } diff --git a/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.h b/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.h index 83c2d01..7cde2ef 100644 --- a/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.h +++ b/Modules/FiberDissection/MachineLearning/mitkStreamlineFeatureExtractor.h @@ -1,101 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef StreamlineFeatureExtractor_h #define StreamlineFeatureExtractor_h #include "MitkFiberDissectionExports.h" // MITK #include <mitkPlanarEllipse.h> #include <mitkFiberBundle.h> // ITK #include <itkProcessObject.h> // VTK #include <vtkSmartPointer.h> #include <vtkPolyData.h> #include <vtkCellArray.h> #include <vtkPoints.h> #include <vtkPolyLine.h> // OpenCV #include <opencv2/ml.hpp> #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> namespace mitk{ /** * \brief */ class MITKFIBERDISSECTION_EXPORT StreamlineFeatureExtractor { public: StreamlineFeatureExtractor(); ~StreamlineFeatureExtractor(); typedef itk::Image< float, 3 > FloatImageType; typedef itk::Image< unsigned char, 3 > UcharImageType; void Update(){ this->GenerateData(); } void SetTractogramPlus(const mitk::FiberBundle::Pointer &Tractogram); void SetTractogramMinus(const mitk::FiberBundle::Pointer &Tractogram); void SetTractogramTest(const mitk::FiberBundle::Pointer &Tractogram, std::string TractogramTestName); + void SetActiveCycle(int &activeCycle); void CreateClassifier(); std::vector<std::vector<unsigned int>> GetData(); // void CreatePrediction(std::vector<unsigned int> &index); mitk::FiberBundle::Pointer CreatePrediction(std::vector<unsigned int> &index); mitk::FiberBundle::Pointer m_Prediction; mitk::FiberBundle::Pointer m_ToLabel; std::vector<std::vector<unsigned int>> m_index; protected: void GenerateData(); std::vector< vnl_matrix<float> > ResampleFibers(FiberBundle::Pointer tractogram); - std::vector<vnl_matrix<float> > CalculateDmdf(std::vector<vnl_matrix<float> > tractogram, std::vector<vnl_matrix<float> > prototypes, std::vector<vnl_matrix<float> > local_prototypes); + std::vector<vnl_matrix<float> > CalculateDmdf(std::vector<vnl_matrix<float> > tractogram, + std::vector<vnl_matrix<float> > prototypes, + std::vector<vnl_matrix<float> > positive_local_prototypes, + std::vector<vnl_matrix<float> > negative_local_prototypes); unsigned int m_NumPoints; + int m_activeCycle; mitk::FiberBundle::Pointer m_TractogramPlus; mitk::FiberBundle::Pointer m_TractogramMinus; mitk::FiberBundle::Pointer m_TractogramTest; std::string m_DistancesTestName; std::vector<vnl_matrix<float> > T_Prototypes; std::vector<vnl_matrix<float> > T_TractogramPlus; std::vector<vnl_matrix<float> > T_TractogramMinus; std::vector<vnl_matrix<float> > T_TractogramTest; std::vector<vnl_matrix<float> > m_DistancesPlus; std::vector<vnl_matrix<float> > m_DistancesMinus; std::vector<vnl_matrix<float> > m_DistancesTest; cv::Ptr<cv::ml::TrainData> m_traindata; }; } #endif diff --git a/Modules/FiberDissection/resource/Interactions/Streamline3DConfig.xml b/Modules/FiberDissection/resource/Interactions/Streamline3DConfig.xml index 3377f69..d852e6a 100644 --- a/Modules/FiberDissection/resource/Interactions/Streamline3DConfig.xml +++ b/Modules/FiberDissection/resource/Interactions/Streamline3DConfig.xml @@ -1,10 +1,18 @@ <config> <event_variant class="MousePressEvent" name="AddNegStreamlineClick"> <attribute name="EventButton" value="RightMouseButton"/> <attribute name="Modifiers" value="shift"/> - </event_variant> + </event_variant>addtolabelstreamline <event_variant class="MousePressEvent" name="AddPosStreamlineClick"> <attribute name="EventButton" value="RightMouseButton"/> <attribute name="Modifiers" value="alt"/> </event_variant> + <event_variant class="MousePressEvent" name="AddNegStreamlinetolabelClick"> + <attribute name="EventButton" value="RightMouseButton"/> + <attribute name="Modifiers" value="shift,ctrl"/> + </event_variant> + <event_variant class="MousePressEvent" name="AddPosStreamlinetolabelClick"> + <attribute name="EventButton" value="RightMouseButton"/> + <attribute name="Modifiers" value="alt,ctrl"/> + </event_variant> </config> diff --git a/Modules/FiberDissection/resource/Interactions/Streamline3DStates.xml b/Modules/FiberDissection/resource/Interactions/Streamline3DStates.xml index 76dcdf1..ca26d76 100644 --- a/Modules/FiberDissection/resource/Interactions/Streamline3DStates.xml +++ b/Modules/FiberDissection/resource/Interactions/Streamline3DStates.xml @@ -1,10 +1,16 @@ <statemachine NAME="StreamlineInteractor3D"> <state name="start" startstate="true" > <transition event_class="InteractionPositionEvent" event_variant="AddNegStreamlineClick" target="start"> <action name="addnegstreamline"/> </transition> <transition event_class="InteractionPositionEvent" event_variant="AddPosStreamlineClick" target="start"> <action name="addposstreamline"/> </transition> + <transition event_class="InteractionPositionEvent" event_variant="AddNegStreamlinetolabelClick" target="start"> + <action name="addnegtolabelstreamline"/> + </transition> + <transition event_class="InteractionPositionEvent" event_variant="AddPosStreamlinetolabelClick" target="start"> + <action name="addpostolabelstreamline"/> + </transition> </state> </statemachine> diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.fiberprocessing/CMakeLists.txt.user b/Plugins/org.mitk.gui.qt.diffusionimaging.fiberprocessing/CMakeLists.txt.user new file mode 100644 index 0000000..ab39197 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging.fiberprocessing/CMakeLists.txt.user @@ -0,0 +1,434 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE QtCreatorProject> +<!-- Written by QtCreator 6.0.2, 2022-07-14T14:22:18. --> +<qtcreator> + <data> + <variable>EnvironmentId</variable> + <value type="QByteArray">{7fc4674f-cf78-4922-8cee-e8273e158382}</value> + </data> + <data> + <variable>ProjectExplorer.Project.ActiveTarget</variable> + <value type="qlonglong">0</value> + </data> + <data> + <variable>ProjectExplorer.Project.EditorSettings</variable> + <valuemap type="QVariantMap"> + <value type="bool" key="EditorConfiguration.AutoIndent">true</value> + <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value> + <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value> + <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0"> + <value type="QString" key="language">Cpp</value> + <valuemap type="QVariantMap" key="value"> + <value type="QByteArray" key="CurrentPreferences">CppGlobal</value> + </valuemap> + </valuemap> + <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1"> + <value type="QString" key="language">QmlJS</value> + <valuemap type="QVariantMap" key="value"> + <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value> + </valuemap> + </valuemap> + <value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value> + <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value> + <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value> + <value type="int" key="EditorConfiguration.IndentSize">4</value> + <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value> + <value type="int" key="EditorConfiguration.MarginColumn">80</value> + <value type="bool" key="EditorConfiguration.MouseHiding">true</value> + <value type="bool" key="EditorConfiguration.MouseNavigation">true</value> + <value type="int" key="EditorConfiguration.PaddingMode">1</value> + <value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value> + <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value> + <value type="bool" key="EditorConfiguration.ShowMargin">false</value> + <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value> + <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value> + <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value> + <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value> + <value type="int" key="EditorConfiguration.TabSize">8</value> + <value type="bool" key="EditorConfiguration.UseGlobal">true</value> + <value type="bool" key="EditorConfiguration.UseIndenter">false</value> + <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value> + <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value> + <value type="bool" key="EditorConfiguration.cleanIndentation">true</value> + <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value> + <value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value> + <value type="bool" key="EditorConfiguration.inEntireDocument">false</value> + <value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value> + </valuemap> + </data> + <data> + <variable>ProjectExplorer.Project.PluginSettings</variable> + <valuemap type="QVariantMap"> + <valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks"> + <value type="bool" key="AutoTest.Framework.Boost">true</value> + <value type="bool" key="AutoTest.Framework.CTest">false</value> + <value type="bool" key="AutoTest.Framework.Catch">true</value> + <value type="bool" key="AutoTest.Framework.GTest">true</value> + <value type="bool" key="AutoTest.Framework.QtQuickTest">true</value> + <value type="bool" key="AutoTest.Framework.QtTest">true</value> + </valuemap> + <valuemap type="QVariantMap" key="AutoTest.CheckStates"/> + <value type="int" key="AutoTest.RunAfterBuild">0</value> + <value type="bool" key="AutoTest.UseGlobal">true</value> + <valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/> + <value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value> + <value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.BuildSystem</value> + <valuemap type="QVariantMap" key="ClangTools"> + <value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value> + <value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value> + <value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value> + <value type="int" key="ClangTools.ParallelJobs">12</value> + <valuelist type="QVariantList" key="ClangTools.SelectedDirs"/> + <valuelist type="QVariantList" key="ClangTools.SelectedFiles"/> + <valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/> + <value type="bool" key="ClangTools.UseGlobalSettings">true</value> + </valuemap> + </valuemap> + </data> + <data> + <variable>ProjectExplorer.Project.Target.0</variable> + <valuemap type="QVariantMap"> + <value type="QString" key="DeviceType">Desktop</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.12.12 GCC 64bit</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.12.12 GCC 64bit</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{696d7eab-256e-4d8a-89bd-eaa6ae60deb2}</value> + <value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value> + <value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> + <value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> + <value type="QString" key="CMake.Build.Type">Debug</value> + <value type="QString" key="CMake.Initial.Parameters">-GUnix Makefiles +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/repo_mitk_diff/mitk-diffusion/Plugins/build-org.mitk.gui.qt.diffusionimaging.fiberprocessing-Qt_5_12_12_GCC_64bit_temporary-Debug</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">all</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">clean</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> + <value type="QString" key="CMake.Build.Type">Release</value> + <value type="QString" key="CMake.Initial.Parameters">-GUnix Makefiles +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/repo_mitk_diff/mitk-diffusion/Plugins/build-org.mitk.gui.qt.diffusionimaging.fiberprocessing-Qt_5_12_12_GCC_64bit_temporary-Release</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">all</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">clean</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> + <value type="QString" key="CMake.Build.Type">RelWithDebInfo</value> + <value type="QString" key="CMake.Initial.Parameters">-GUnix Makefiles +-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo +-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/repo_mitk_diff/mitk-diffusion/Plugins/build-org.mitk.gui.qt.diffusionimaging.fiberprocessing-Qt_5_12_12_GCC_64bit_temporary-RelWithDebInfo</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">all</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">clean</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release with Debug Information</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.3"> + <value type="QString" key="CMake.Build.Type">MinSizeRel</value> + <value type="QString" key="CMake.Initial.Parameters">-GUnix Makefiles +-DCMAKE_BUILD_TYPE:STRING=MinSizeRel +-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/repo_mitk_diff/mitk-diffusion/Plugins/build-org.mitk.gui.qt.diffusionimaging.fiberprocessing-Qt_5_12_12_GCC_64bit_temporary-MinSizeRel</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">all</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">clean</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Minimum Size Release</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.4"> + <value type="QString" key="CMake.Build.Type">Release</value> + <value type="QString" key="CMake.Initial.Parameters">-GUnix Makefiles +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value> + <value type="QString" key="CMake.Source.Directory">/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/mitk</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/r948e/MITK_Diff/git_build</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">all</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">clean</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release2</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.5"> + <value type="QString" key="CMake.Build.Type">Release</value> + <value type="QString" key="CMake.Initial.Parameters">-GUnix Makefiles +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value> + <value type="QString" key="CMake.Source.Directory">/home/r948e/E132-Projekte/Projects/2022_Peretzke_Interactive_Fiber_Dissection/mitk_diff/mitk</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/r948e/MITK_Diff/qt_build</value> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">all</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value> + </valuemap> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"> + <value type="QString">clean</value> + </valuelist> + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/> + <value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value> + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release3</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">6</value> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0"> + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> + <value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value> + </valuemap> + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value> + <valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/> + <value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value> + <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0"> + <value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value> + <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value> + <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value> + <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds"> + <value type="QString">0</value> + <value type="QString">1</value> + <value type="QString">2</value> + <value type="QString">3</value> + <value type="QString">4</value> + <value type="QString">5</value> + <value type="QString">6</value> + <value type="QString">7</value> + <value type="QString">8</value> + <value type="QString">9</value> + <value type="QString">10</value> + <value type="QString">11</value> + <value type="QString">12</value> + <value type="QString">13</value> + <value type="QString">14</value> + </valuelist> + <valuelist type="QVariantList" key="CustomOutputParsers"/> + <value type="int" key="PE.EnvironmentAspect.Base">2</value> + <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value> + <value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value> + <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> + <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> + <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> + <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> + </valuemap> + <value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value> + </valuemap> + </data> + <data> + <variable>ProjectExplorer.Project.TargetCount</variable> + <value type="qlonglong">1</value> + </data> + <data> + <variable>ProjectExplorer.Project.Updater.FileVersion</variable> + <value type="int">22</value> + </data> + <data> + <variable>Version</variable> + <value type="int">22</value> + </data> +</qtcreator> diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging.fiberprocessing/src/internal/QmitkInteractiveFiberDissectionView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging.fiberprocessing/src/internal/QmitkInteractiveFiberDissectionView.cpp index bb7f40f..09e1173 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging.fiberprocessing/src/internal/QmitkInteractiveFiberDissectionView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging.fiberprocessing/src/internal/QmitkInteractiveFiberDissectionView.cpp @@ -1,847 +1,869 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include <berryISelectionService.h> #include <berryIWorkbenchPart.h> #include <berryIWorkbenchWindow.h> // Qmitk #include "QmitkInteractiveFiberDissectionView.h" #include <QmitkRenderWindow.h> //Pointset #include <QmitkPointListWidget.h> //Pointset #include <QMessageBox> #include <mitkNodePredicateProperty.h> #include <mitkImageCast.h> #include <mitkPointSet.h> #include <mitkImageAccessByItk.h> #include <mitkDataNodeObject.h> #include <mitkTensorImage.h> #include "mitkNodePredicateDataType.h" #include <mitkNodePredicateProperty.h> #include <mitkNodePredicateAnd.h> #include <mitkNodePredicateNot.h> #include <mitkNodePredicateOr.h> //#include <mitkStreamlineFeatureExtractor.h> #include <mitkInteractionConst.h> #include "usModuleRegistry.h" //#include <itkFiberCurvatureFilter.h> #include <itkResampleImageFilter.h> #include <itkGaussianInterpolateImageFunction.h> #include <itkImageRegionIteratorWithIndex.h> #include <itkTractsToFiberEndingsImageFilter.h> #include <itkTractDensityImageFilter.h> #include <itkImageRegion.h> #include <itkTractsToRgbaImageFilter.h> #include <itkFiberExtractionFilter.h> #include <mitkInteractionEventObserver.h> #include <vtkCellPicker.h> #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> #include <vnl/vnl_sparse_matrix.h> const std::string QmitkInteractiveFiberDissectionView::VIEW_ID = "org.mitk.views.interactivefiberdissection"; const std::string id_DataManager = "org.mitk.views.datamanager"; using namespace mitk; QmitkInteractiveFiberDissectionView::QmitkInteractiveFiberDissectionView() : QmitkAbstractView() , m_Controls( 0 ) , m_IterationCounter(0) , m_RandomExtractionCounter(0) , m_activeCycleCounter(0) , m_StreamlineInteractor(nullptr) { } // Destructor QmitkInteractiveFiberDissectionView::~QmitkInteractiveFiberDissectionView() { //disable interactor if (m_StreamlineInteractor != nullptr) { // m_StreamlineInteractor->SetStreamlineNode(nullptr); m_StreamlineInteractor->EnableInteraction(false); } } void QmitkInteractiveFiberDissectionView::CreateQtPartControl( QWidget *parent ) { // build up qt view, unless already done if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkInteractiveFiberDissectionViewControls; m_Controls->setupUi( parent ); m_Controls->m_selectedPointSetWidget->SetDataStorage(GetDataStorage());//pointset m_Controls->m_selectedPointSetWidget->SetNodePredicate(mitk::NodePredicateAnd::New(//pointset mitk::TNodePredicateDataType<mitk::PointSet>::New(),//pointset mitk::NodePredicateNot::New(mitk::NodePredicateOr::New(//pointset mitk::NodePredicateProperty::New("helper object"),//pointset mitk::NodePredicateProperty::New("hidden object")))));//pointset m_Controls->m_selectedPointSetWidget->SetSelectionIsOptional(true);//pointset m_Controls->m_selectedPointSetWidget->SetAutoSelectNewNodes(true);//pointset m_Controls->m_selectedPointSetWidget->SetEmptyInfo(QString("Please select a point set"));//pointset m_Controls->m_selectedPointSetWidget->SetPopUpTitel(QString("Select point set"));//pointsett // m_Controls->m_trainbundleWidget->SetDataStorage(GetDataStorage());//testdata // m_Controls->m_trainbundleWidget->SetNodePredicate(mitk::NodePredicateAnd::New(//testdata // mitk::TNodePredicateDataType<mitk::FiberBundle>::New(),//testdata // mitk::NodePredicateNot::New(mitk::NodePredicateOr::New(//testdata // mitk::NodePredicateProperty::New("helper object"),//testdata // mitk::NodePredicateProperty::New("hidden object")))));//testdatat // m_Controls->m_trainbundleWidget->SetSelectionIsOptional(true);//testdata // m_Controls->m_trainbundleWidget->SetAutoSelectNewNodes(true);//testdat // m_Controls->m_trainbundleWidget->SetEmptyInfo(QString("Please select a tractogram"));//testdat // m_Controls->m_trainbundleWidget->SetPopUpTitel(QString("Select tractogram"));//testdat connect(m_Controls->m_ErazorButton, SIGNAL(toggled(bool)), this, SLOT( RemovefromBundle(bool) ) ); //need connect(m_Controls->m_StreamlineCreation, SIGNAL( clicked() ), this, SLOT( CreateStreamline())); connect(m_Controls->m_AddRandomFibers, SIGNAL( clicked() ), this, SLOT( ExtractRandomFibersFromTractogram() ) ); //need connect(m_Controls->m_TrainClassifier, SIGNAL( clicked() ), this, SLOT( StartAlgorithm( ))); connect(m_Controls->m_CreatePrediction, SIGNAL( clicked() ), this, SLOT( CreatePredictionNode( ))); connect(m_Controls->m_AddUncertainFibers, SIGNAL( clicked() ), this, SLOT( CreateUncertaintySampleNode( ))); connect(m_Controls->m_AddDistanceFibers, SIGNAL( clicked() ), this, SLOT( CreateDistanceSampleNode( ))); connect(m_Controls->m_unclabeling, SIGNAL(toggled(bool)), this, SLOT( RemovefromUncertainty(bool) ) ); //need connect(m_Controls->m_distlabeling, SIGNAL(toggled(bool)), this, SLOT( RemovefromDistance(bool) ) ); //need connect(m_Controls->m_predlabeling, SIGNAL(toggled(bool)), this, SLOT( RemovefromPrediction(bool) ) ); //need connect(m_Controls->m_addPointSetPushButton, &QPushButton::clicked,//pointset this, &QmitkInteractiveFiberDissectionView::OnAddPointSetClicked);//pointset connect(m_Controls->m_selectedPointSetWidget, &QmitkSingleNodeSelectionWidget::CurrentSelectionChanged,//pointset this, &QmitkInteractiveFiberDissectionView::OnCurrentSelectionChanged);//pointset auto renderWindowPart = this->GetRenderWindowPart();//pointset if (nullptr != renderWindowPart)//pointset this->RenderWindowPartActivated(renderWindowPart);//pointset this->OnCurrentSelectionChanged(m_Controls->m_selectedPointSetWidget->GetSelectedNodes());//pointset } UpdateGui(); } void QmitkInteractiveFiberDissectionView::SetFocus() { m_Controls->toolBoxx->setFocus(); //m_Controls->m_addPointSetPushButton->setFocus();//pointset } void QmitkInteractiveFiberDissectionView::UpdateGui() { m_Controls->m_FibLabel->setText("<font color='red'>mandatory</font>"); m_Controls->m_InputData->setTitle("Please Select Input Data"); // disable alle frames m_Controls->m_ErazorButton->setCheckable(true); m_Controls->m_ErazorButton->setEnabled(false); m_Controls->m_unclabeling->setCheckable(true); m_Controls->m_unclabeling->setEnabled(false); m_Controls->m_predlabeling->setCheckable(true); m_Controls->m_predlabeling->setEnabled(false); m_Controls->m_distlabeling->setCheckable(true); m_Controls->m_distlabeling->setEnabled(false); m_Controls->m_addPointSetPushButton->setEnabled(false); m_Controls->m_StreamlineCreation->setEnabled(false); m_Controls->m_TrainClassifier->setEnabled(false); m_Controls->m_CreatePrediction->setEnabled(false); m_Controls->m_CreateUncertantyMap->setEnabled(false); m_Controls->m_Numtolabel->setEnabled(false); m_Controls->m_Numtolabel2->setEnabled(false); m_Controls->m_addPointSetPushButton->setEnabled(false); m_Controls->m_AddRandomFibers->setEnabled(false); m_Controls->m_AddDistanceFibers->setEnabled(false); m_Controls->m_AddUncertainFibers->setEnabled(false); m_Controls->m_unclabeling->setEnabled(false); m_Controls->m_predlabeling->setEnabled(false); m_Controls->m_distlabeling->setEnabled(false); bool fibSelected = !m_SelectedFB.empty(); bool multipleFibsSelected = (m_SelectedFB.size()>1); bool sthSelected = m_SelectedImageNode.IsNotNull(); bool psSelected = m_SelectedPS.IsNotNull(); // bool nfibSelected = !m_newfibersSelectedBundles.empty(); // bool posSelected = !m_positivBundlesNode.empty(); bool nfibSelected = m_newfibersSelectedBundles.IsNotNull(); // bool posSelected = !m_positivBundlesNode.IsNotNull(); // bool negSelected = !m_negativeSelectedBundles.IsNotNull(); bool posSelected = this->GetDataStorage()->Exists(m_positivBundlesNode); bool negSelected = this->GetDataStorage()->Exists(m_negativeSelectedBundles); bool indexSelected = !m_index.empty(); bool uncertaintySelected = this->GetDataStorage()->Exists(m_UncertaintyLabelNode); bool distanceSelected = this->GetDataStorage()->Exists(m_DistanceLabelNode); bool predictionSelected = this->GetDataStorage()->Exists(m_PredictionNode); // toggle visibility of elements according to selected method // are fiber bundles selected? if ( fibSelected ) { m_Controls->m_FibLabel->setText(QString(m_SelectedFB.at(0)->GetName().c_str())); m_Controls->m_addPointSetPushButton->setEnabled(true); m_Controls->m_AddRandomFibers->setEnabled(true); // more than two bundles needed to join/subtract if (multipleFibsSelected) { m_Controls->m_FibLabel->setText("multiple bundles selected"); } } // is image selected if (sthSelected) { m_Controls->m_addPointSetPushButton->setEnabled(true); } if (psSelected) { m_Controls->m_StreamlineCreation->setEnabled(true); } if (nfibSelected && posSelected) { m_Controls->m_ErazorButton->setEnabled(true); } if (posSelected && negSelected) { m_Controls->m_TrainClassifier->setEnabled(true); } if (indexSelected) { m_Controls->m_CreatePrediction->setEnabled(true); m_Controls->m_AddUncertainFibers->setEnabled(true); m_Controls->m_Numtolabel->setEnabled(true); m_Controls->m_AddDistanceFibers->setEnabled(true); m_Controls->m_Numtolabel2->setEnabled(true); } if (uncertaintySelected) { m_Controls->m_unclabeling->setEnabled(true); } if (predictionSelected) { m_Controls->m_predlabeling->setEnabled(true); } if (distanceSelected) { m_Controls->m_distlabeling->setEnabled(true); } } void QmitkInteractiveFiberDissectionView::OnEndInteraction() { } void QmitkInteractiveFiberDissectionView::OnAddPointSetClicked()//pointset { // ask for the name of the point set bool ok = false; QString name = QInputDialog::getText(QApplication::activeWindow(), tr("Add point set..."), tr("Enter name for the new point set"), QLineEdit::Normal, tr("PointSet").arg(++m_IterationCounter), &ok); // QString name = "PointSet"; if (!ok || name.isEmpty()) { return; } mitk::PointSet::Pointer pointSet = mitk::PointSet::New(); mitk::DataNode::Pointer pointSetNode = mitk::DataNode::New(); pointSetNode->SetData(pointSet); pointSetNode->SetProperty("name", mitk::StringProperty::New(name.toStdString())); pointSetNode->SetProperty("opacity", mitk::FloatProperty::New(1)); pointSetNode->SetColor(1.0, 1.0, 0.0); this->GetDataStorage()->Add(pointSetNode, m_SelectedImageNode); m_Controls->m_selectedPointSetWidget->SetCurrentSelectedNode(pointSetNode); } void QmitkInteractiveFiberDissectionView::OnCurrentSelectionChanged(QmitkSingleNodeSelectionWidget::NodeList /*nodes*/)//pointset { m_Controls->m_poinSetListWidget->SetPointSetNode(m_Controls->m_selectedPointSetWidget->GetSelectedNode()); m_SelectedPS = m_Controls->m_selectedPointSetWidget->GetSelectedNode(); // m_Controls->m_trainbundleWidget->SetPointSetNode(m_Controls->m_trainbundleWidget->GetSelectedNode()); // m_trainbundle = m_Controls->m_trainbundleWidget->GetSelectedNode(); UpdateGui(); } void QmitkInteractiveFiberDissectionView::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*part*/, const QList<mitk::DataNode::Pointer>& nodes) { m_SelectedFB.clear(); if (nodes.empty() || nodes.front().IsNull()) { m_SelectedImageNode = nullptr; } else { m_SelectedImageNode = nodes.front(); } for (auto node: nodes) { if (dynamic_cast<mitk::Image*>(node->GetData())) m_SelectedImage = dynamic_cast<mitk::Image*>(node->GetData()); else if ( dynamic_cast<mitk::FiberBundle*>(node->GetData()) ) m_SelectedFB.push_back(node); } UpdateGui(); } void QmitkInteractiveFiberDissectionView::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart)//pointset { if (nullptr != m_Controls) { m_Controls->m_poinSetListWidget->AddSliceNavigationController(renderWindowPart->GetQmitkRenderWindow("axial")->GetSliceNavigationController()); m_Controls->m_poinSetListWidget->AddSliceNavigationController(renderWindowPart->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()); m_Controls->m_poinSetListWidget->AddSliceNavigationController(renderWindowPart->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()); } } void QmitkInteractiveFiberDissectionView::RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart)//pointset { if (nullptr != m_Controls) { m_Controls->m_poinSetListWidget->RemoveSliceNavigationController(renderWindowPart->GetQmitkRenderWindow("axial")->GetSliceNavigationController()); m_Controls->m_poinSetListWidget->RemoveSliceNavigationController(renderWindowPart->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()); m_Controls->m_poinSetListWidget->RemoveSliceNavigationController(renderWindowPart->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()); } } void QmitkInteractiveFiberDissectionView::CreateStreamline() { if (m_positivBundlesNode.IsNull()) { mitk::DataNode::Pointer node = mitk::DataNode::New(); m_positiveFibersData = vtkSmartPointer<vtkPolyData>::New(); m_positiveFibersData->SetPoints(vtkSmartPointer<vtkPoints>::New()); m_positiveFibersData->SetLines(vtkSmartPointer<vtkCellArray>::New()); m_positiveBundle = mitk::FiberBundle:: New(m_positiveFibersData); node->SetData( m_positiveBundle ); m_positivBundlesNode = node; this->GetDataStorage()->Add(m_positivBundlesNode); MITK_INFO << "Create Bundle"; } if (!m_positivBundlesNode.IsNull()) { this->GetDataStorage()->Remove(m_positivBundlesNode); MITK_INFO << "Adding fibers"; MITK_INFO << m_positiveBundle->GetFiberPolyData()->GetNumberOfCells(); m_positiveFibersData = m_positiveBundle->GetFiberPolyData(); } vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); unsigned int counter = 0; for (unsigned int i=0; i<m_positiveFibersData->GetNumberOfCells(); ++i) { MITK_INFO<< "New Line"; vtkCell* cell = m_positiveFibersData->GetCell(i); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; ++j) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); counter++; } mitk::PointSet::Pointer pointSet = dynamic_cast<mitk::PointSet *>(m_SelectedPS->GetData()); vnl_matrix<float> streamline; streamline.set_size(3, pointSet->GetSize()); streamline.fill(0.0); mitk::PointSet::PointsIterator begin = pointSet->Begin(); mitk::PointSet::PointsIterator end = pointSet->End(); unsigned int i; mitk::PointSet::PointsContainer::Iterator it; for (it = begin, i = 0; it != end; ++it, ++i) { PointSet::PointType pt = pointSet->GetPoint(it->Index()); vnl_vector_fixed< float, 3 > candV; candV[0]=pt[0]; candV[1]=pt[1]; candV[2]=pt[2]; streamline.set_column(i, candV); } // build Fiber vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<streamline.cols(); j++) { double p[3]; p[0] = streamline.get(0,j); p[1] = streamline.get(1,j); p[2] = streamline.get(2,j); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } MITK_INFO<< "Last Line from current pointset"; vNewLines->InsertNextCell(container); vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); m_positiveFibersData = vtkSmartPointer<vtkPolyData>::New(); m_positiveFibersData->SetPoints(vtkSmartPointer<vtkPoints>::New()); m_positiveFibersData->SetLines(vtkSmartPointer<vtkCellArray>::New()); m_positiveFibersData->SetPoints(vNewPoints); m_positiveFibersData->SetLines(vNewLines); m_positiveBundle = mitk::FiberBundle::New(vNewPolyData); // m_positiveBundle->SetTrackVisHeader(dynamic_cast<mitk::Image*>(m_SelectedImageNode->GetData())->GetGeometry()); m_positiveBundle->SetFiberColors(0, 255, 0); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(m_positiveBundle); node->SetName("+Bundle"); m_positivBundlesNode= node; MITK_INFO << "The + Bundle has Streamlines:"; auto m_NegStreamline= dynamic_cast<mitk::FiberBundle *>(m_positivBundlesNode->GetData()); MITK_INFO << m_NegStreamline->GetFiberPolyData()->GetNumberOfCells(); this->GetDataStorage()->Add(m_positivBundlesNode); // m_Controls->m_selectedPointSetWidget->m_ToggleAddPoint->setEnabled(false); UpdateGui(); } void QmitkInteractiveFiberDissectionView::ExtractRandomFibersFromTractogram() { m_SelectedFB.at(0)->SetVisibility(false); m_Controls->m_ErazorButton->setChecked(false); MITK_INFO << "Number of Fibers to extract from Tractogram: "; MITK_INFO << m_Controls->m_NumRandomFibers->value(); if (this->GetDataStorage()->Exists(m_newfibersSelectedBundles)) { MITK_INFO << "To Label Bundle Exists"; mitk::FiberBundle::Pointer Stack = dynamic_cast<mitk::FiberBundle *>(m_newfibersSelectedBundles->GetData()); this->GetDataStorage()->Remove(m_newfibersSelectedBundles); mitk::DataNode::Pointer node = mitk::DataNode::New(); m_newfibersFibersData = vtkSmartPointer<vtkPolyData>::New(); m_newfibersFibersData->SetPoints(vtkSmartPointer<vtkPoints>::New()); m_newfibersBundle = mitk::FiberBundle:: New(m_newfibersFibersData); m_newfibersFibersData->SetLines(vtkSmartPointer<vtkCellArray>::New()); // node->SetData( m_newfibersBundle ); // m_newfibersSelectedBundles = node ; MITK_INFO << "Create Bundle"; } mitk::FiberBundle::Pointer fib = dynamic_cast<mitk::FiberBundle*>(m_SelectedFB.at(0)->GetData()); // mitk::FiberBundle::Pointer fib = dynamic_cast<mitk::FiberBundle *>(m_trainbundle->GetData()); vtkSmartPointer<vtkPolyData> vNewPolyData = vtkSmartPointer<vtkPolyData>::New(); vtkSmartPointer<vtkCellArray> vNewLines = vtkSmartPointer<vtkCellArray>::New(); vtkSmartPointer<vtkPoints> vNewPoints = vtkSmartPointer<vtkPoints>::New(); - + /* Check weather all Streamlines of the bundles are labeled... If all are labeled Skip for Loop*/ unsigned int counter = 0; - for ( int i=m_Controls->m_NumRandomFibers->value()*m_RandomExtractionCounter; i<m_Controls->m_NumRandomFibers->value()*(m_RandomExtractionCounter+1); i++) + int thresh1; + int thresh2; + thresh2 = m_Controls->m_NumRandomFibers->value()*(m_RandomExtractionCounter+1); + thresh1 = m_Controls->m_NumRandomFibers->value()*(m_RandomExtractionCounter); + if (thresh1>fib->GetFiberPolyData()->GetNumberOfCells()) + { + thresh1=fib->GetFiberPolyData()->GetNumberOfCells(); + } + if (thresh2>fib->GetFiberPolyData()->GetNumberOfCells()) + { + thresh2=fib->GetFiberPolyData()->GetNumberOfCells(); + } + + if (thresh1!=fib->GetFiberPolyData()->GetNumberOfCells()) + { + for ( int i=thresh1; i<thresh2; i++) { vtkCell* cell = fib->GetFiberPolyData()->GetCell(i); auto numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer<vtkPolyLine> container = vtkSmartPointer<vtkPolyLine>::New(); for (unsigned int j=0; j<numPoints; j++) { double p[3]; points->GetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } // weights->InsertValue(counter, fib->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } + vNewPolyData->SetLines(vNewLines); vNewPolyData->SetPoints(vNewPoints); m_newfibersFibersData = vtkSmartPointer<vtkPolyData>::New(); m_newfibersFibersData->SetPoints(vtkSmartPointer<vtkPoints>::New()); m_newfibersFibersData->SetLines(vtkSmartPointer<vtkCellArray>::New()); m_newfibersFibersData->SetPoints(vNewPoints); m_newfibersFibersData->SetLines(vNewLines); m_newfibersBundle = mitk::FiberBundle::New(vNewPolyData); m_newfibersBundle->SetFiberColors(255, 255, 255); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(m_newfibersBundle); node->SetName("ToLabel"); m_newfibersSelectedBundles = node; // MITK_INFO << "Number of Streamlines in first function"; // MITK_INFO << m_newfibersSelectedBundles->GetData()->GetFiberPolyData()->GetNumberOfCells(); this->GetDataStorage()->Add(m_newfibersSelectedBundles); m_RandomExtractionCounter++; + } UpdateGui(); } void QmitkInteractiveFiberDissectionView::RemovefromBundle( bool checked ) { if (checked) { if (m_StreamlineInteractor.IsNull()) { this->CreateStreamlineInteractor(); // if (m_negativeSelectedBundles.IsNull()) // { mitk::FiberBundle::Pointer m_negativeBundle = mitk::FiberBundle::New(); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetName("-Bundle"); node->SetData(m_negativeBundle); m_negativeSelectedBundles = node; this->GetDataStorage()->Add(m_negativeSelectedBundles); // } // if (m_positivBundlesNode.IsNull()) // { // mitk::FiberBundle::Pointer m_positiveBundle = mitk::FiberBundle::New(); // mitk::DataNode::Pointer m_positiveSelectedBundles = mitk::DataNode::New(); // m_positiveSelectedBundles->SetName("+Bundle"); // m_positiveSelectedBundles->SetData(m_positiveBundle); // this->GetDataStorage()->Add(m_positiveSelectedBundles);) // } m_StreamlineInteractor->EnableInteraction(true); m_StreamlineInteractor->SetNegativeNode(m_negativeSelectedBundles); m_StreamlineInteractor->SetPositiveNode(m_positivBundlesNode); m_StreamlineInteractor->SetToLabelNode(m_newfibersSelectedBundles); } else { m_StreamlineInteractor->EnableInteraction(true); m_StreamlineInteractor->SetPositiveNode(m_positivBundlesNode); // MITK_INFO << "Number of Streamlines"; // MITK_INFO << m_newfibersSelectedBundles->GetData()->GetFiberPolyData()->GetNumberOfCells(); m_StreamlineInteractor->SetToLabelNode(m_newfibersSelectedBundles); } } else { m_StreamlineInteractor->EnableInteraction(false); // m_StreamlineInteractor = nullptr; } UpdateGui(); } void QmitkInteractiveFiberDissectionView::CreateStreamlineInteractor() { m_StreamlineInteractor = mitk::StreamlineInteractor::New(); m_StreamlineInteractor->LoadStateMachine("Streamline3DStates.xml", us::ModuleRegistry::GetModule("MitkFiberDissection")); m_StreamlineInteractor->SetEventConfig("Streamline3DConfig.xml", us::ModuleRegistry::GetModule("MitkFiberDissection")); // m_StreamlineInteractor->SetRotationEnabled(rotationEnabled); } void QmitkInteractiveFiberDissectionView::StartAlgorithm() { this->GetDataStorage()->Remove(m_UncertaintyLabelNode); this->GetDataStorage()->Remove(m_DistanceLabelNode); m_Controls->m_unclabeling->setChecked(false); m_Controls->m_distlabeling->setChecked(false); m_Controls->m_predlabeling->setChecked(false); clusterer.reset(); MITK_INFO << "Extract Features"; m_negativeBundle = dynamic_cast<mitk::FiberBundle*>(m_negativeSelectedBundles->GetData()); clusterer = std::make_shared<mitk::StreamlineFeatureExtractor>(); clusterer->SetTractogramPlus(m_positiveBundle); + clusterer->SetActiveCycle(m_activeCycleCounter); clusterer->SetTractogramMinus(m_negativeBundle); clusterer->SetTractogramTest(dynamic_cast<mitk::FiberBundle*>(m_SelectedFB.at(0)->GetData()), m_SelectedFB.at(0)->GetName()); // clusterer->SetTractogramTest(dynamic_cast<mitk::FiberBundle*>(m_trainbundle->GetData()), m_trainbundle->GetName()); // m_distances = clusterer->get clusterer->Update(); m_index = clusterer->m_index; MITK_INFO << "Number of Cycles"; MITK_INFO << m_activeCycleCounter; m_activeCycleCounter += 1; // m_Prediction = clusterer->CreatePrediction(m_index.at(0)); // mitk::DataNode::Pointer node = mitk::DataNode::New(); // node->SetData(m_Prediction); // node->SetName("Prediction"); // m_PredictionNode = node; // this->GetDataStorage()->Add(m_PredictionNode); // m_UncertaintyLabel = clusterer->m_UncertaintyLabel; // mitk::DataNode::Pointer node2 = mitk::DataNode::New(); // node2->SetData(m_UncertaintyLabel); // node2->SetName("UncertaintyLabels"); // m_UncertaintyLabelNode = node2; // MITK_INFO << "Number of Streamlines in first function"; // MITK_INFO << m_newfibersSelectedBundles->GetData()->GetFiberPolyData()->GetNumberOfCells(); // this->GetDataStorage()->Add(m_UncertaintyLabelNode); // this->GetDataStorage()->Add(m_PredictionNode); // clusterer->GetData(); // MITK_INFO << data.at(0); // MITK_INFO << data.at(1); // cv::Ptr<cv::ml::TrainData> m_traindata = clusterer->GetData(); // MITK_INFO << clusterer->m_labels; // MITK_INFO << data.at(1); // MITK_INFO << "Start Classification"; // clusterer->CreateClassifier(); // cv::Mat curdata = clusterer->StartAlgorithm(); // MITK_INFO << curdata; MITK_INFO << "Algorithm run succesfully"; m_Controls->m_CreatePrediction->setEnabled(true); UpdateGui(); } void QmitkInteractiveFiberDissectionView::CreatePredictionNode() { MITK_INFO << "Create Prediction"; m_Prediction = clusterer->CreatePrediction(m_index.at(0)); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(m_Prediction); - node->SetName("Prediction"); + auto s = std::to_string(m_activeCycleCounter); + node->SetName("Prediction"+s); m_PredictionNode = node; this->GetDataStorage()->Add(m_PredictionNode); UpdateGui(); } void QmitkInteractiveFiberDissectionView::CreateUncertaintySampleNode() { MITK_INFO << "Create Fibers to label based on Uncertainty"; std::vector<unsigned int> myvec = m_index.at(1); myvec.resize(m_Controls->m_Numtolabel->value()); MITK_INFO << m_index.at(1).size(); MITK_INFO << myvec.size(); - m_UncertaintyLabel = clusterer->CreatePrediction(myvec); - mitk::DataNode::Pointer node = mitk::DataNode::New(); - node->SetData(m_UncertaintyLabel); - node->SetName("UncertaintyLabel"); - m_UncertaintyLabelNode = node; - this->GetDataStorage()->Add(m_UncertaintyLabelNode); - UpdateGui(); + m_UncertaintyLabel = clusterer->CreatePrediction(myvec); + mitk::DataNode::Pointer node = mitk::DataNode::New(); + node->SetData(m_UncertaintyLabel); + + auto s = std::to_string(m_activeCycleCounter); + node->SetName("UncertaintyLabel"+s); + m_UncertaintyLabelNode = node; + this->GetDataStorage()->Add(m_UncertaintyLabelNode); + UpdateGui(); } void QmitkInteractiveFiberDissectionView::CreateDistanceSampleNode() { MITK_INFO << "Create Fibers to label based on Distance in Features-Space"; std::vector<unsigned int> myvec = m_index.at(2); myvec.resize(m_Controls->m_Numtolabel2->value()); MITK_INFO << m_index.at(2).size(); MITK_INFO << myvec.size(); - m_DistanceLabel = clusterer->CreatePrediction(myvec); - mitk::DataNode::Pointer node = mitk::DataNode::New(); - node->SetData(m_DistanceLabel); - node->SetName("DistanceLabel"); - m_DistanceLabelNode = node; - this->GetDataStorage()->Add(m_DistanceLabelNode); - UpdateGui(); + m_DistanceLabel = clusterer->CreatePrediction(myvec); + mitk::DataNode::Pointer node = mitk::DataNode::New(); + node->SetData(m_DistanceLabel); + auto s = std::to_string(m_activeCycleCounter); + node->SetName("DistanceLabel"+s); + m_DistanceLabelNode = node; + this->GetDataStorage()->Add(m_DistanceLabelNode); + UpdateGui(); } void QmitkInteractiveFiberDissectionView::RemovefromUncertainty( bool checked ) { if (checked) { m_UncertaintyLabel->SetFiberColors(255, 255, 255); m_StreamlineInteractor->EnableInteraction(true); m_StreamlineInteractor->SetToLabelNode(m_UncertaintyLabelNode); } else { m_StreamlineInteractor->EnableInteraction(false); // m_StreamlineInteractor = nullptr; } RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkInteractiveFiberDissectionView::RemovefromDistance( bool checked ) { if (checked) { m_DistanceLabel->SetFiberColors(255, 255, 255); m_StreamlineInteractor->EnableInteraction(true); m_StreamlineInteractor->SetToLabelNode(m_DistanceLabelNode); } else { m_StreamlineInteractor->EnableInteraction(false); // m_StreamlineInteractor = nullptr; } RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkInteractiveFiberDissectionView::RemovefromPrediction( bool checked ) { if (checked) { m_Prediction->SetFiberColors(255, 255, 255); m_StreamlineInteractor->EnableInteraction(true); m_StreamlineInteractor->SetToLabelNode(m_PredictionNode); } else { m_StreamlineInteractor->EnableInteraction(false); // m_StreamlineInteractor = nullptr; } }