コード例 #1
0
ファイル: mitkPAVector.cpp プロジェクト: Cdebus/MITK
bool mitk::pa::Equal(const Vector::Pointer leftHandSide, const Vector::Pointer rightHandSide, double eps, bool verbose)
{
  MITK_INFO(verbose) << "=== mitk::pa::Vector Equal ===";

  if (rightHandSide.IsNull() || leftHandSide.IsNull())
  {
    MITK_INFO(verbose) << "Cannot compare nullpointers";
    return false;
  }

  if (leftHandSide->GetElement(0) - rightHandSide->GetElement(0) > eps)
  {
    MITK_INFO(verbose) << "Element[0] not equal";
    return false;
  }

  if (leftHandSide->GetElement(1) - rightHandSide->GetElement(1) > eps)
  {
    MITK_INFO(verbose) << "Element[1] not equal";
    return false;
  }

  if (leftHandSide->GetElement(2) - rightHandSide->GetElement(2) > eps)
  {
    MITK_INFO(verbose) << "Element[2] not equal";
    return false;
  }

  return true;
}
コード例 #2
0
ファイル: mitkPAVessel.cpp プロジェクト: junaidnaseer/MITK
bool mitk::pa::Equal(const Vessel::Pointer leftHandSide, const Vessel::Pointer rightHandSide, double eps, bool verbose)
{
  MITK_INFO(verbose) << "=== mitk::pa::Vessel Equal ===";

  if (rightHandSide.IsNull() || leftHandSide.IsNull())
  {
    MITK_INFO(verbose) << "Cannot compare nullpointers";
    return false;
  }

  if (leftHandSide->IsFinished() != rightHandSide->IsFinished())
  {
    MITK_INFO(verbose) << "Not same finished state.";
    return false;
  }

  if (leftHandSide->CanBifurcate() != rightHandSide->CanBifurcate())
  {
    MITK_INFO(verbose) << "Not same bifurcation state.";
    return false;
  }

  if (!Equal(leftHandSide->GetVesselProperties(), rightHandSide->GetVesselProperties(), eps, verbose))
  {
    MITK_INFO(verbose) << "Vesselproperties not equal";
    return false;
  }

  return true;
}
コード例 #3
0
void mitk::pa::SpectralUnmixingSO2::GenerateData()
{
  MITK_INFO(m_Verbose) << "GENERATING DATA..";

  // Get input image
  mitk::Image::Pointer inputHbO2 = GetInput(0);
  mitk::Image::Pointer inputHb = GetInput(1);

  CheckPreConditions(inputHbO2, inputHb);

  unsigned int xDim = inputHbO2->GetDimensions()[0];
  unsigned int yDim = inputHbO2->GetDimensions()[1];
  unsigned int zDim = inputHbO2->GetDimensions()[2];

  InitializeOutputs();

  mitk::ImageReadAccessor readAccessHbO2(inputHbO2);
  mitk::ImageReadAccessor readAccessHb(inputHb);

  const float* inputDataArrayHbO2 = ((const float*)readAccessHbO2.GetData());
  const float* inputDataArrayHb = ((const float*)readAccessHb.GetData());

  auto output = GetOutput(0);
  auto output1 = GetOutput(1);

  mitk::ImageWriteAccessor writeOutput(output);
  float* writeBuffer = (float *)writeOutput.GetData();

  mitk::ImageWriteAccessor writeOutput1(output1);
  float* writeBuffer1 = (float *)writeOutput1.GetData();

  for (unsigned int x = 0; x < xDim; x++)
  {
    for (unsigned int y = 0; y < yDim; y++)
    {
      for (unsigned int z = 0;z < zDim; z++)
      {
        unsigned int pixelNumber = (xDim*yDim * z) + x * yDim + y;
        float pixelHb = inputDataArrayHb[pixelNumber];
        float pixelHbO2 = inputDataArrayHbO2[pixelNumber];
        float resultSO2 = CalculateSO2(pixelHb, pixelHbO2);
        writeBuffer[(xDim*yDim * z) + x * yDim + y] = resultSO2;
        float resultTHb = CalculateTHb(pixelHb, pixelHbO2);
        writeBuffer1[(xDim*yDim * z) + x * yDim + y] = resultTHb;
      }
    }
  }
  MITK_INFO(m_Verbose) << "GENERATING DATA...[DONE]";
}
コード例 #4
0
void QmitkIGTLDeviceSetupConnectionWidget::OnConnect()
{
  if (m_IGTLDevice->GetState() == mitk::IGTLDevice::Setup)
  {
    QString port = m_Controls->editPort->text();
    m_IGTLDevice->SetPortNumber(port.toInt());
    std::string hostname = m_Controls->editIP->text().toStdString();
    m_IGTLDevice->SetHostname(hostname);
    //connect with the other OpenIGTLink device => changes the state from Setup
    //to Ready
    if (m_IGTLDevice->OpenConnection())
    {
      //starts the communication thread => changes the state from Ready to
      //Running
      if (m_IGTLDevice->StartCommunication())
      {
        if (this->m_IsClient)
        {
          MITK_INFO("IGTLDeviceSourceManagementWidget")
            << "Successfully connected to " << hostname
            << " on port " << port.toStdString();
        }
      }
      else
      {
        MITK_ERROR("QmitkIGTLDeviceSetupConnectionWidget") <<
          "Could not start a communication with the"
          "server because the client is in the wrong state";
      }
    }
    else
    {
      MITK_ERROR("QmitkIGTLDeviceSetupConnectionWidget") <<
        "Could not connect to the server. "
        "Please check the hostname and port.";
    }
  }
  else if (m_IGTLDevice->GetState() == mitk::IGTLDevice::Ready || m_IGTLDevice->GetState() == mitk::IGTLDevice::Running)
  {
    m_IGTLDevice->CloseConnection();
    MITK_INFO("QmitkIGTLDeviceSetupConnectionWidget") << "Closed connection";
  }
  else
  {
    mitkThrow() << "Invalid state of IGTLDevice";
  }
  this->AdaptGUIToState();
}
コード例 #5
0
  void mitk::NodeDisplacementFilter::GenerateData()
  {
    // copy the navigation data from the inputs to the outputs
    mitk::NavigationDataPassThroughFilter::GenerateData();

    // if no reference has been set yet, warn and abort
    if (m_SelectedInput == -1)
    {
      MITK_INFO("NodeDisplacementFilter")
        << "No input has been selected. Only forwarding NavigationData...";
      return;
    }

    // cancel, if selected tool is currently not being tracked
    if ( ! this->GetInput(m_SelectedInput)->IsDataValid() ) { return; }

    // outputs have been updated, now to transform the nodes
    // 1) Generate Pseudo-Geometry for Reference
    mitk::Geometry3D::Pointer refGeom = this->TransformToGeometry(
      this->GetInput(m_SelectedInput)->GetAffineTransform3D());

    // 2) For each node, calculate new position
    for (unsigned int index=0; index < m_Nodes.size(); index++)
    {
      mitk::Geometry3D::Pointer transformGeometry = refGeom->Clone();

      // create transformation to the reference position and from there to
      // the node position (node has fixed transformation from reference position)
      transformGeometry->Compose(m_Transforms.at(index), true);

      m_Nodes.at(index)->GetData()->SetGeometry(transformGeometry);
    }
  }
コード例 #6
0
ファイル: mitkIGTLServer.cpp プロジェクト: Alex10er/MITK
void mitk::IGTLServer::StopCommunicationWithSocket(igtl::Socket* client)
{
  m_SentListMutex->Lock();
  m_ReceiveListMutex->Lock();
  auto i = m_RegisteredClients.begin();
  auto end = m_RegisteredClients.end();
  while (i != end)
  {
    if ((*i) == client)
    {
      //    //close the socket
      (*i)->CloseSocket();
      //and remove it from the list
      i = this->m_RegisteredClients.erase(i);
    }
    else
    {
      ++i;
    }
  }
  m_SentListMutex->Unlock();
  m_ReceiveListMutex->Unlock();

  MITK_INFO("IGTLServer") << "Removed client socket from server client list.";
}
コード例 #7
0
void QmitkIGTLDeviceSetupConnectionWidget::OnCommandReceived()
{
  if( this->m_Controls->logMessageStatusCheckBox->isChecked() )
  {
    MITK_INFO("IGTLDeviceSetupConnectionWidget") << "Received a command.";
  }
}
コード例 #8
0
void QmitkUSNavigationStepZoneMarking::OnZoneAdded()
{
  m_CurrentlyAddingZone = false;

  ui->freezeButton->Unfreeze();

  ui->zoneAddingExplanationLabel->setEnabled(ui->freezeButton->isChecked());

  mitk::DataStorage::SetOfObjects::ConstPointer zoneNodesSet = ui->zonesWidget->GetZoneNodes();
  for (mitk::DataStorage::SetOfObjects::ConstIterator it = zoneNodesSet->Begin();
       it != zoneNodesSet->End(); ++it)
  {
    // add all zones to zone filter which aren't added until now
    if ( std::find(m_ZoneNodes.begin(), m_ZoneNodes.end(), it->Value()) == m_ZoneNodes.end() )
    {
      // logging center point and radius
      float radius = -1;
      it->Value()->GetFloatProperty("zone.size", radius);
      MITK_INFO("QmitkUSNavigationStepZoneMarking")("QmitkUSAbstractNavigationStep")
        << "Risk zone (" << it->Value()->GetName() << ") added with center "
        << it->Value()->GetData()->GetGeometry()->GetOrigin() << " and radius " << radius << ".";

      m_ZoneNodes.push_back(it->Value());
      m_ZoneDisplacementFilter->AddNode(it->Value());
    }
  }
}
コード例 #9
0
void mitk::USZonesInteractor::AddCenter(mitk::StateMachineAction*, mitk::InteractionEvent* interactionEvent)
{
  // cast InteractionEvent to a position event in order to read out the mouse position
  mitk::InteractionPositionEvent* positionEvent = dynamic_cast<mitk::InteractionPositionEvent*>(interactionEvent);
  if (positionEvent == NULL); // { return false; }
  mitk::DataNode::Pointer dataNode = this->GetDataNode();
  dataNode->SetBoolProperty(DATANODE_PROPERTY_CREATED, false);

  // make sure that data node contains data
  mitk::BaseData::Pointer dataNodeData = this->GetDataNode()->GetData();
  if (dataNodeData.IsNull())
  {
    dataNodeData = mitk::Surface::New();
    this->GetDataNode()->SetData(dataNodeData);
  }

  // set origin of the data node to the mouse click position
  dataNodeData->GetGeometry()->SetOrigin(positionEvent->GetPositionInWorld());
  MITK_INFO("USNavigationLogging") << "Critical Structure added on position " << positionEvent->GetPointerPositionOnScreen() << " (Image Coordinates); "
    << positionEvent->GetPositionInWorld() << " (World Coordinates)";

  dataNode->SetFloatProperty("opacity", 0.60f);

  //return true;
}
コード例 #10
0
void QmitkUSNavigationStepZoneMarking::OnZoneRemoved()
{
  mitk::DataStorage::SetOfObjects::ConstPointer zoneNodesSet = ui->zonesWidget->GetZoneNodes();

  for ( int n = m_ZoneNodes.size() - 1; n >= 0; --n )
  {
    bool found = false;

    // test if the node can be found in the set of zone nodes
    for (mitk::DataStorage::SetOfObjects::ConstIterator itSet = zoneNodesSet->Begin();
       itSet != zoneNodesSet->End(); ++itSet)
    {
      if ( m_ZoneNodes.at(n) == itSet->Value() ) { found = true; break; }
    }

    if ( ! found )
    {
      MITK_INFO("QmitkUSNavigationStepZoneMarking")("QmitkUSAbstractNavigationStep")
        << "Risk zone (" << m_ZoneNodes.at(n)->GetName() << ") removed.";

      m_ZoneNodes.erase(m_ZoneNodes.begin()+n);
      m_ZoneDisplacementFilter->RemoveNode(n);
    }
  }
}
コード例 #11
0
void QmitkUSNavigationStepPlacementPlanning::OnRemoveCurrentTargetClicked()
{
  if ( m_CurrentTargetIndex >= m_PlannedTargetNodes.size() )
  {
    MITK_WARN << "Cannot remove current target as there aren't as much planned target nodes.";
    return;
  }

  this->GetDataStorage()->Remove(m_PlannedTargetNodes.at(m_CurrentTargetIndex));
  m_PlannedTargetNodes.remove(m_CurrentTargetIndex);
  this->GetDataStorage()->Remove(m_PlannedNeedlePaths.at(m_CurrentTargetIndex));
  m_PlannedNeedlePaths.remove(m_CurrentTargetIndex);
  this->ReinitNodeDisplacementFilter();

  for ( unsigned int n = 0; n < m_PlannedTargetNodes.size(); ++n )
  {
    // set name of the target node according to its new index
    m_PlannedTargetNodes.at(n)->SetName(
      QString("Target %1").arg(n+1, m_NumberOfTargets / 10 + 1, 10, QLatin1Char('0')).toStdString());

    m_PlannedNeedlePaths.at(n)->SetName(
      QString("Target Path %1").arg(n+1, m_NumberOfTargets / 10 + 1, 10, QLatin1Char('0')).toStdString());
  }

  m_TargetUpdateFilter->RemovePositionOfTarget(m_CurrentTargetIndex);

  m_CurrentTargetIndex = m_PlannedTargetNodes.size();

  this->UpdateTargetDescriptions();

  MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepPlacementPlanning")
    << "Planned target " << m_CurrentTargetIndex + 1 << " removed.";
}
コード例 #12
0
void QmitkUSNavigationStepMarkerIntervention::UpdateTargetViolationStatus()
{
  // transform vtk polydata according to mitk geometry
  vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
  transformFilter->SetInputData(0, m_TargetSurface->GetVtkPolyData());
  transformFilter->SetTransform(m_TargetSurface->GetGeometry()->GetVtkTransform());
  transformFilter->Update();

  vtkSmartPointer<vtkSelectEnclosedPoints> enclosedPoints = vtkSmartPointer<vtkSelectEnclosedPoints>::New();
  enclosedPoints->Initialize(transformFilter->GetOutput());

  mitk::Point3D needleTip = m_NeedleProjectionFilter->GetProjection()->GetPoint(0);

  // show warning if the needle tip is inside the target surface
  if (enclosedPoints->IsInsideSurface(needleTip[0], needleTip[1], needleTip[2]))
  {
    if (!m_TargetStructureWarnOverlay->IsVisible())
    {
      m_TargetStructureWarnOverlay->SetVisibility(true);

      mitk::DataNode::Pointer targetViolationResult = mitk::DataNode::New();
      targetViolationResult->SetName("TargetViolation");
      targetViolationResult->SetProperty("USNavigation::TargetViolationPoint", mitk::Point3dProperty::New(needleTip));

      emit SignalIntermediateResult(targetViolationResult);
    }

    MITK_INFO("QmitkUSAbstractNavigationStep")
      ("QmitkUSNavigationStepMarkerIntervention") << "Target surface violated at " << needleTip << ".";
  }
  else
  {
    m_TargetStructureWarnOverlay->SetVisibility(false);
  }
}
コード例 #13
0
void QmitkUSNavigationStepMarkerIntervention::OnBackToLastTargetClicked()
{
  if (m_CurrentTargetIndex < 1)
  {
    MITK_WARN << "Cannot go back to last target as there is no last target.";
    return;
  }

  m_CurrentTargetIndex--;

  if (m_ReachedTargetsNodes.size() > m_CurrentTargetIndex)
  {
    this->GetDataStorage()->Remove(m_ReachedTargetsNodes.last());
    MITK_INFO("QmitkUSAbstractNavigationStep")
      ("QmitkUSNavigationStepMarkerIntervention") << "Removed Target " << m_ReachedTargetsNodes.size();
    m_ReachedTargetsNodes.pop_back();
  }

  if (m_CurrentTargetIndex == 0)
  {
    ui->backToLastTargetButton->setDisabled(true);
  }
  if (m_CurrentTargetIndex >= 0 && static_cast<unsigned int>(m_CurrentTargetIndex) < m_NumberOfTargets)
  {
    ui->targetReachedButton->setEnabled(true);
  }

  ui->freezeImageButton->setEnabled(false);
  ui->freezeImageButton->Unfreeze();

  this->UpdateTargetProgressDisplay();

  m_TargetUpdateFilter->RemovePositionOfTarget(m_CurrentTargetIndex);
}
コード例 #14
0
ファイル: mitkUSDevice.cpp プロジェクト: Cdebus/MITK
bool mitk::USDevice::Connect()
{
  MITK_DEBUG << "mitk::USDevice::Connect() called";

  if (this->GetIsConnected())
  {
    MITK_INFO("mitkUSDevice") << "Tried to connect an ultrasound device that "
      "was already connected. Ignoring call...";
    return true;
  }

  if (!this->GetIsInitialized())
  {
    MITK_ERROR("mitkUSDevice")
      << "Cannot connect device if it is not in initialized state.";
    return false;
  }

  // Prepare connection, fail if this fails.
  if (!this->OnConnection())
  {
    return false;
  }

  // Update state
  m_DeviceState = State_Connected;

  this->UpdateServiceProperty(
    mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISCONNECTED, true);
  return true;
}
void QmitkIGTLDeviceSetupConnectionWidget::OnMessageSent()
{
   if (this->m_Controls->logOutgoingMsg->isChecked())
   {
      MITK_INFO("IGTLDeviceSetupConnectionWidget") << "Sent a message.";
   }
}
void QmitkIGTLDeviceSetupConnectionWidget::OnCommandReceived()
{
   if (this->m_Controls->logIncomingMsg->isChecked())
  {
    MITK_INFO("IGTLDeviceSetupConnectionWidget") << "Received a command: "
        << this->m_IGTLDevice->GetCommandQueue()->GetLatestMsgInformationString();
  }
}
コード例 #17
0
void QmitkUSNavigationStepTumourSelection::OnTumourSizeChanged(int size)
{
  m_TumourNode->SetFloatProperty("zone.size", static_cast<float>(size));
  mitk::USZonesInteractor::UpdateSurface(m_TumourNode);

  MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepTumourSelection")
    << "Changing tumour radius to " << size << ".";
}
コード例 #18
0
void QmitkIGTLDeviceSetupConnectionWidget::OnMessageSent()
{
  if( this->m_Controls->logMessageStatusCheckBox->isChecked() )
  {
    MITK_INFO("IGTLDeviceSetupConnectionWidget") << "Sent a message.";
  }
  m_NumSentFramesSinceLastUpdate++;
}
コード例 #19
0
STDMETHODIMP USTelemedScanConverterPlugin::SetScanConverterPlugin(IDispatch* plugin)
{
  // make sure that there is no scan converter plugin registered already
  this->ReleasePlugin();

  HRESULT hr;

  // it is ok to call this method with a nullptr plugin to remove
  // a previous callback
  if (plugin == nullptr)
  {
    MITK_INFO("IUsgfwScanConverterPluginCB")("ScanConverterPlugin")
      << "nullptr plugin set to the scan converter. The callback for the previous plugin is removed now.";
    return S_OK;
  }

  // get Telemed API plugin from the COM library
  Usgfw2Lib::IUsgScanConverterPlugin* tmp_plugin;
  hr = plugin->QueryInterface(__uuidof(Usgfw2Lib::IUsgScanConverterPlugin), (void**)&tmp_plugin);

  if (FAILED(hr))
  {
    MITK_WARN("IUsgfwScanConverterPluginCB")("ScanConverterPlugin")
      << "Could not query com interface for IUsgScanConverterPlugin (" << hr << ").";
    return hr;
  }

  // get the converter for scan lines from the COM library and
  // save it as a member attribute
  hr = tmp_plugin->get_ScanConverter((IUnknown**)&m_Plugin);

  if (FAILED(hr))
  {
    MITK_WARN("IUsgfwScanConverterPluginCB")("ScanConverterPlugin")
      << "Could not get ScanConverter from plugin (" << hr << ").";
    return hr;
  }

  SAFE_RELEASE(tmp_plugin);

  // now the callback can be set -> interface functions of this
  // object will be called from now on when new image data is
  // available
  hr = m_Plugin->SetCallback(this,USPC_BUFFER_INTERIM_OUTPUT);

  if (FAILED(hr))
  {
    MITK_WARN("IUsgfwScanConverterPluginCB")("ScanConverterPlugin")
      << "Could not set callback for plugin (" << hr << ").";
    return hr;
  }

  return S_OK;
}
コード例 #20
0
bool QmitkUSNavigationStepPunctuationIntervention::OnFinishStep()
{
  mitk::DataNode::Pointer finishPunctionResult = mitk::DataNode::New();
  finishPunctionResult->SetName("PunctionResult");
  mitk::Point3D needlePos = m_NeedleProjectionFilter->GetOutput(0)->GetPosition();
  mitk::Quaternion needleRot = m_NeedleProjectionFilter->GetOutput(0)->GetOrientation();
  finishPunctionResult->SetProperty("USNavigation::TipPositionEnd", mitk::Point3dProperty::New(needlePos));
  MITK_INFO("USNavigationLogging") << "Instrument tip at end: " <<needlePos<< " / " << needleRot;
  emit SignalIntermediateResult(finishPunctionResult);
  return true;
}
コード例 #21
0
ファイル: mitkLabel.cpp プロジェクト: MITK/MITK
bool mitk::Equal(const mitk::Label &leftHandSide, const mitk::Label &rightHandSide, ScalarType /*eps*/, bool verbose)
{
    MITK_INFO(verbose) << "--- Label Equal ---";

    bool returnValue = true;
    // have to be replaced until a PropertyList Equal was implemented :
    // returnValue = mitk::Equal((const mitk::PropertyList &)leftHandSide,(const mitk::PropertyList
    // &)rightHandSide,eps,verbose);

    const mitk::PropertyList::PropertyMap *lhsmap = leftHandSide.GetMap();
    const mitk::PropertyList::PropertyMap *rhsmap = rightHandSide.GetMap();

    returnValue = lhsmap->size() == rhsmap->size();

    if (!returnValue)
    {
        MITK_INFO(verbose) << "Labels in label container are not equal.";
        return returnValue;
    }

    auto lhsmapIt = lhsmap->begin();
    auto lhsmapItEnd = lhsmap->end();

    for (; lhsmapIt != lhsmapItEnd; ++lhsmapIt)
    {
        if (rhsmap->find(lhsmapIt->first) == rhsmap->end())
        {
            returnValue = false;
            break;
        }
    }

    if (!returnValue)
    {
        MITK_INFO(verbose) << "Labels in label container are not equal.";
        return returnValue;
    }

    return returnValue;
}
コード例 #22
0
void QmitkUSNavigationStepTumourSelection::TumourNodeChanged(const mitk::DataNode* dataNode)
{
  // only changes of tumour node are of interest
  if (dataNode != m_TumourNode) { return; }

  float size;
  dataNode->GetFloatProperty("zone.size", size);

  ui->tumourSizeSlider->setValue(static_cast<int>(size));

  bool created;
  if (dataNode->GetBoolProperty("zone.created", created) && created)
  {
    if (ui->freezeImageButton->isChecked())
    {
      m_NodeDisplacementFilter->AddNode(const_cast<mitk::DataNode*>(dataNode));

      m_TargetSurfaceNode->SetData(this->CreateTargetSurface());
      m_NodeDisplacementFilter->AddNode(m_TargetSurfaceNode);

      MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepTumourSelection")
        << "Tumour created with center " << dataNode->GetData()->GetGeometry()->GetOrigin()
        << " and radius " << size << ".";

      mitk::DataNode::Pointer tumourResultNode = mitk::DataNode::New();
      tumourResultNode->SetName("TumourResult");
      tumourResultNode->SetProperty("USNavigation::TumourCenter",
        mitk::Point3dProperty::New(dataNode->GetData()->GetGeometry()->GetOrigin()));
      tumourResultNode->SetProperty("USNavigation::TumourRadius", mitk::DoubleProperty::New(size));

      emit SignalIntermediateResult(tumourResultNode);

      ui->freezeImageButton->Unfreeze();
    }

    ui->tumourSearchExplanationLabel->setEnabled(false);
    ui->tumourSizeExplanationLabel->setEnabled(true);
    ui->tumourSizeLabel->setEnabled(true);
    ui->tumourSizeSlider->setEnabled(true);
    ui->deleteTumourButton->setEnabled(true);

    emit SignalReadyForNextStep();
  }
}
コード例 #23
0
void QmitkUSNavigationStepPlacementPlanning::UpdateTargetCoordinates(mitk::DataNode* dataNode)
{
  bool surfaceEmpty;
  if ( dataNode->GetBoolProperty("surface_empty", surfaceEmpty) && surfaceEmpty )
  {
    mitk::Point3D origin = dataNode->GetData()->GetGeometry()->GetOrigin();
    dataNode->SetData(this->CreateSphere(5));
    dataNode->SetBoolProperty("surface_empty", false);
    dataNode->GetData()->GetGeometry()->SetOrigin(origin);
  }

  this->ReinitNodeDisplacementFilter();

  mitk::BaseData* baseData = dataNode->GetData();
  if ( ! baseData )
  {
    mitkThrow() << "Data of the data node must not be null.";
  }

  mitk::BaseGeometry::Pointer geometry = baseData->GetGeometry();
  if ( geometry.IsNull() )
  {
    mitkThrow() << "Geometry of the data node must not be null.";
  }

  m_TargetUpdateFilter->SetControlNode(m_CurrentTargetIndex, dataNode);

  MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepPlacementPlanning")
    << "Target " << m_CurrentTargetIndex+1 << " planned at position " << geometry->GetOrigin() << ".";

  if ( ui->freezeImageButton->isChecked() )
  {
    ui->freezeImageButton->Unfreeze();

    if ( m_CurrentTargetIndex < m_NumberOfTargets - 1 )
    {
      this->OnGoToNextTarget();
    }
  }

  this->UpdateTargetDescriptions();
}
コード例 #24
0
ファイル: mitkIGTLServer.cpp プロジェクト: Alex10er/MITK
void mitk::IGTLServer::Connect()
{
  igtl::Socket::Pointer socket;
  //check if another igtl device wants to connect to this socket
  socket =
    ((igtl::ServerSocket*)(this->m_Socket.GetPointer()))->WaitForConnection(1);
  //if there is a new connection the socket is not null
  if (socket.IsNotNull())
  {
    //add the new client socket to the list of registered clients
    m_SentListMutex->Lock();
    m_ReceiveListMutex->Lock();
    this->m_RegisteredClients.push_back(socket);
    m_SentListMutex->Unlock();
    m_ReceiveListMutex->Unlock();
    //inform observers about this new client
    this->InvokeEvent(NewClientConnectionEvent());
    MITK_INFO("IGTLServer") << "Connected to a new client: " << socket;
  }
}
コード例 #25
0
void mitk::IGTLClient::Send()
{
  igtl::MessageBase::Pointer curMessage;

  //get the latest message from the queue
  curMessage = this->m_SendQueue->PullMessage();

  // there is no message => return
  if ( curMessage.IsNull() )
    return;

  if ( this->SendMessagePrivate(curMessage.GetPointer(), this->m_Socket) )
  {
    MITK_INFO("IGTLDevice") << "Successfully sent the message.";
  }
  else
  {
    MITK_WARN("IGTLDevice") << "Could not send the message.";
  }
}
コード例 #26
0
void mitk::pa::SpectralUnmixingSO2::CheckPreConditions(mitk::Image::Pointer inputHbO2, mitk::Image::Pointer inputHb)
{
  unsigned int xDimHb = inputHb->GetDimensions()[0];
  unsigned int yDimHb = inputHb->GetDimensions()[1];
  unsigned int zDimHb = inputHb->GetDimensions()[2];

  unsigned int xDimHbO2 = inputHbO2->GetDimensions()[0];
  unsigned int yDimHbO2 = inputHbO2->GetDimensions()[1];
  unsigned int zDimHbO2 = inputHbO2->GetDimensions()[2];

  if (xDimHb != xDimHbO2 || yDimHb != yDimHbO2 || zDimHb != zDimHbO2)
    mitkThrow() << "DIMENTIONALITY ERROR!";

  if (inputHbO2->GetPixelType() != mitk::MakeScalarPixelType<float>())
    mitkThrow() << "PIXELTYPE ERROR! FLOAT REQUIRED";

  if (inputHb->GetPixelType() != mitk::MakeScalarPixelType<float>())
    mitkThrow() << "PIXELTYPE ERROR! FLOAT REQUIRED";

  MITK_INFO(m_Verbose) << "CHECK PRECONDITIONS ...[DONE]";
}
コード例 #27
0
ファイル: mitkUSDevice.cpp プロジェクト: Cdebus/MITK
bool mitk::USDevice::Activate()
{
  if (!this->GetIsConnected())
  {
    MITK_INFO("mitkUSDevice")
      << "Cannot activate device if it is not in connected state.";
    return true;
  }

  if (OnActivation())
  {
    m_DeviceState = State_Activated;

    m_FreezeBarrier = itk::ConditionVariable::New();

    // spawn thread for aquire images if us device is active
    if (m_SpawnAcquireThread)
    {
      this->m_ThreadID =
        this->m_MultiThreader->SpawnThread(this->Acquire, this);
    }

    this->UpdateServiceProperty(
      mitk::USDevice::GetPropertyKeys().US_PROPKEY_ISACTIVE, true);
    this->UpdateServiceProperty(
      mitk::USDevice::GetPropertyKeys().US_PROPKEY_LABEL,
      this->GetServicePropertyLabel());
    // initialize the b mode control properties of the micro service
    mitk::USControlInterfaceBMode::Pointer bmodeControls =
      this->GetControlInterfaceBMode();
    if (bmodeControls.IsNotNull())
    {
      bmodeControls->Initialize();
    }
  }

  this->ProvideViaOIGTL();

  return m_DeviceState == State_Activated;
}
コード例 #28
0
void QmitkUSNavigationStepPlacementPlanning::OnPlaceTargetButtonClicked()
{
  this->CreateTargetNodesIfNecessary();

  mitk::DataNode::Pointer currentNode = m_PlannedTargetNodes.at(m_CurrentTargetIndex);

  currentNode->SetData(this->CreateSphere(5));
  currentNode->SetBoolProperty("surface_empty", false);

  mitk::PointSet::Pointer needleProjection = m_NeedleProjectionFilter->GetProjection();

  m_TargetIntersectionFilter->SetTargetSurface(dynamic_cast<mitk::Surface*>(m_TargetNode->GetData()));
  m_TargetIntersectionFilter->SetLine(m_NeedleProjectionFilter->GetProjection());
  m_TargetIntersectionFilter->CalculateIntersection();
  mitk::Point3D intersectionPoint = m_TargetIntersectionFilter->GetIntersectionPoint();

  currentNode->GetData()->GetGeometry()->SetOrigin(intersectionPoint);
  m_TargetUpdateFilter->SetControlNode(m_CurrentTargetIndex, currentNode);

  mitk::PointSet::Pointer plannedPath = mitk::PointSet::New();
  m_PlannedNeedlePaths.at(m_CurrentTargetIndex)->SetData(plannedPath);
  plannedPath->SetPoint(0, needleProjection->GetPoint(0));
  plannedPath->SetPoint(1, intersectionPoint);

  if ( m_CurrentTargetIndex < m_NumberOfTargets - 1 )
  {
    this->OnGoToNextTarget();
  }
  else
  {
    this->UpdateTargetDescriptions();
  }

  this->ReinitNodeDisplacementFilter();

  MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepPlacementPlanning")
    << "Target " << m_CurrentTargetIndex+1 << " planned at position " << intersectionPoint << ".";
}
コード例 #29
0
void QmitkUSNavigationStepMarkerIntervention::UpdateTargetCoordinates(mitk::DataNode *dataNode)
{
  m_NodeDisplacementFilter->ResetNodes();
  for (QVector<itk::SmartPointer<mitk::DataNode>>::iterator it = m_ReachedTargetsNodes.begin();
    it != m_ReachedTargetsNodes.end();
    ++it)
  {
    if (it->IsNotNull() && (*it)->GetData() != 0)
    {
      m_NodeDisplacementFilter->AddNode(*it);
    }
  }

  mitk::BaseData *baseData = dataNode->GetData();
  if (!baseData)
  {
    mitkThrow() << "Data of the data node must not be null.";
  }

  mitk::BaseGeometry::Pointer geometry = baseData->GetGeometry();
  if (geometry.IsNull())
  {
    mitkThrow() << "Geometry of the data node must not be null.";
  }

  m_TargetUpdateFilter->SetControlNode(m_CurrentTargetIndex - 1, dataNode);

  if (m_PlannedTargetsNodes.size() > m_CurrentTargetIndex - 1)
  {
    m_PlannedTargetsNodes.at(m_CurrentTargetIndex - 1)->SetVisibility(false);
  }

  MITK_INFO("QmitkUSAbstractNavigationStep")
    ("QmitkUSNavigationStepMarkerIntervention") << "Target " << m_CurrentTargetIndex << " reached at position "
    << geometry->GetOrigin();

  this->CalculateTargetPlacementQuality();
}
コード例 #30
0
bool QmitkUSNavigationStepTumourSelection::OnStopStep()
{
  // make sure that imaging isn't freezed anymore
  ui->freezeImageButton->Unfreeze();

  m_NodeDisplacementFilter->ResetNodes();

  mitk::DataStorage::Pointer dataStorage = this->GetDataStorage(false);
  if (dataStorage.IsNotNull())
  {
    // remove target surface node from data storage, if available there
    if (m_TargetSurfaceNode.IsNotNull()) { dataStorage->Remove(m_TargetSurfaceNode); }

    dataStorage->ChangedNodeEvent.RemoveListener(m_ListenerChangeNode);
    dataStorage->Remove(m_TumourNode);
    m_TumourNode = 0;
  }

  MITK_INFO("QmitkUSAbstractNavigationStep")("QmitkUSNavigationStepTumourSelection")
    << "Removing tumour.";

  return true;
}