コード例 #1
0
bool QmitkDataStorageTableModel::DataNodeCompareFunction::operator()(const mitk::DataNode::Pointer &_Left,
                                                                     const mitk::DataNode::Pointer &_Right) const
{
  switch (m_CompareCriteria)
  {
    case CompareByClassName:
      if (m_CompareOperator == Less)
        return (_Left->GetData()->GetNameOfClass() < _Right->GetData()->GetNameOfClass());
      else
        return (_Left->GetData()->GetNameOfClass() > _Right->GetData()->GetNameOfClass());
      break;

    case CompareByVisibility:
    {
      bool _LeftVisibility = false;
      bool _RightVisibility = false;
      _Left->GetVisibility(_LeftVisibility, nullptr);
      _Right->GetVisibility(_RightVisibility, nullptr);

      if (m_CompareOperator == Less)
        return (_LeftVisibility < _RightVisibility);
      else
        return (_LeftVisibility > _RightVisibility);
    }
    break;

    // CompareByName:
    default:
      if (m_CompareOperator == Less)
        return (_Left->GetName() < _Right->GetName());
      else
        return (_Left->GetName() > _Right->GetName());
      break;
  }
}
コード例 #2
0
ファイル: gmMaskingItem.cpp プロジェクト: GraphMIC/GraphMIC
        void MaskingItem::receive(mitk::DataNode::Pointer node)
        {
            if(!node)
            {
                setEnabled(false);
                emit this->setStatus(false);
                return;
            }

            bool isMasking = false;
            node->GetBoolProperty("masking", isMasking);
            mitk::LabelSetImage* labelSetImage = dynamic_cast<mitk::LabelSetImage*>(node->GetData());
            
            if(isMasking && !labelSetImage)
            {
                setEnabled(true);
                this->m_node = node;
                this->createNewMask(node);
                emit this->setStatus(true);
            }
            else if(isMasking && labelSetImage)
            {
                setEnabled(true);
                this->m_node = node;
                this->initNode(node);
                emit this->setStatus(true);
            }
            else
            {
                setEnabled(false);
                deactivateTool();
                emit this->setStatus(false);
            }
        }
コード例 #3
0
void QmitkNavigationToolCreationAdvancedWidget::SetToolTipSurface( bool cone, mitk::DataNode::Pointer node /*= NULL*/ )
{
  m_ToolTipSurface = NULL;
  if(cone)
  {
    m_ToolTipSurface = mitk::Surface::New();
    vtkConeSource *vtkData = vtkConeSource::New();
    vtkData->SetAngle(5.0);
    vtkData->SetResolution(50);
    vtkData->SetHeight(6.0f);
    vtkData->SetRadius(2.0f);
    vtkData->SetCenter(0.0, 0.0, 0.0);

    vtkData->Update();
    m_ToolTipSurface->SetVtkPolyData(vtkData->GetOutput());

    vtkData->Delete();
    m_SurfaceNodeName ="";
  }
  else if(!cone && node.IsNotNull())
  {
    m_ToolTipSurface = dynamic_cast<mitk::Surface*>(node->GetData());
    m_SurfaceNodeName = node->GetName();
  }
}
コード例 #4
0
  foreach ( mitk::DataNode::Pointer referenceNode, selectedNodes )
  {
    if (referenceNode.IsNotNull())
    {
      mitk::LabelSetImage::Pointer referenceImage = dynamic_cast<mitk::LabelSetImage*>( referenceNode->GetData() );
      assert(referenceImage);

      if(referenceImage->GetNumberOfLabels() <= 1)
      {
        QMessageBox::information(nullptr, "Create LabelSetImage Preset", "Could not create a LabelSetImage preset.\nNo Labels defined!\n");\
        return;
      }

      std::string sName = referenceNode->GetName();
      QString qName;
      qName.sprintf("%s.lsetp",sName.c_str());
      QString filename = QFileDialog::getSaveFileName( nullptr,"save file dialog",QString(),"LabelSet Preset(*.lsetp)");
      if ( filename.isEmpty() )
        return;

      std::string fileName = filename.toStdString();
      bool wasSaved = mitk::LabelSetIOHelper::SaveLabelSetImagePreset(fileName,referenceImage);

      if(!wasSaved)
      {
        QMessageBox::information(nullptr, "Create LabelSetImage Preset", "Could not save a LabelSetImage preset as Xml.\n");\
        return;
      }
    }
  }
コード例 #5
0
ファイル: QmitkTemplateView.cpp プロジェクト: test-fd301/MITK
 // iterate all selected objects, adjust warning visibility
 foreach( mitk::DataNode::Pointer node, nodes )
 {
   if( node.IsNotNull() && dynamic_cast<mitk::Image*>(node->GetData()) )
   {
     m_Controls.labelWarning->setVisible( false );
     m_Controls.buttonPerformImageProcessing->setEnabled( true );
     return;
   }
 }
コード例 #6
0
void QmitkDiffusionDicomImport::SetDwiNodeProperties(mitk::DataNode::Pointer node, std::string name)
{

  node->SetProperty( "IsDWIRawVolume", mitk::BoolProperty::New( true ) );

  // set foldername as string property
  mitk::StringProperty::Pointer nameProp = mitk::StringProperty::New( name );
  node->SetProperty( "name", nameProp );
}
コード例 #7
0
// Helper function to get an image from a data node.
static mitk::Image::Pointer GetImage(mitk::DataNode::Pointer dataNode)
{
  if (dataNode.IsNull())
    mitkThrow();

  mitk::Image::Pointer image = dynamic_cast<mitk::Image*>(dataNode->GetData());

  if (image.IsNull())
    mitkThrow();

  return image;
}
コード例 #8
0
ファイル: QmitkTubeGraphView.cpp プロジェクト: 151706061/MITK
  foreach( mitk::DataNode::Pointer node, nodes )
  {
    if( node.IsNotNull() && dynamic_cast< mitk::TubeGraph* >(node->GetData()) )
    {
      m_Controls.activeGraphComboBox->SetSelectedNode(node);
      m_ActiveTubeGraph = dynamic_cast< mitk::TubeGraph* >(node->GetData());

      m_ActiveProperty = dynamic_cast<mitk::TubeGraphProperty*>(m_ActiveTubeGraph->GetProperty( "Tube Graph.Visualization Information" ).GetPointer());

      this->UpdateActiveTubeGraphInInteractors();
      this->UpdateLabelGroups();
      this->UpdateAnnotation();
    }
  }
コード例 #9
0
ファイル: mitkFiberMapper3DTest.cpp プロジェクト: m4271n/MITK
  void Ribbon3D()
  {
    node->SetBoolProperty( "light.enable_light", true);
    node->SetFloatProperty("shape.ribbonwidth", 1);

    mitk::RenderingTestHelper renderingHelper(640, 480);
    renderingHelper.AddNodeToStorage(node);
    renderingHelper.SetMapperIDToRender3D();

    renderingHelper.SaveReferenceScreenShot(mitk::IOUtil::GetTempPath()+"fib_ribbon_3D.png");
    mitk::Image::Pointer test_image = mitk::IOUtil::Load<mitk::Image>(mitk::IOUtil::GetTempPath()+"fib_ribbon_3D.png");
    mitk::Image::Pointer ref_image = mitk::IOUtil::Load<mitk::Image>(GetTestDataFilePath("DiffusionImaging/Rendering/fib_ribbon_3D.png"));
    MITK_ASSERT_EQUAL(test_image, ref_image, "Check if images are equal.");
  }
コード例 #10
0
void QmitkTensorReconstructionView::SetDefaultNodeProperties(mitk::DataNode::Pointer node, std::string name)
{
    node->SetProperty( "ShowMaxNumber", mitk::IntProperty::New( 500 ) );
    node->SetProperty( "Scaling", mitk::FloatProperty::New( 1.0 ) );
    node->SetProperty( "Normalization", mitk::OdfNormalizationMethodProperty::New());
    node->SetProperty( "ScaleBy", mitk::OdfScaleByProperty::New());
    node->SetProperty( "IndexParam1", mitk::FloatProperty::New(2));
    node->SetProperty( "IndexParam2", mitk::FloatProperty::New(1));
    node->SetProperty( "visible", mitk::BoolProperty::New( true ) );
    node->SetProperty( "VisibleOdfs", mitk::BoolProperty::New( false ) );
    node->SetProperty ("layer", mitk::IntProperty::New(100));
    node->SetProperty( "DoRefresh", mitk::BoolProperty::New( true ) );

    node->SetProperty( "name", mitk::StringProperty::New(name) );
}
コード例 #11
0
ファイル: mitkFiberMapper3DTest.cpp プロジェクト: m4271n/MITK
 void setUp() override
 {
   fib = mitk::IOUtil::Load<mitk::FiberBundle>(GetTestDataFilePath("DiffusionImaging/Rendering/test_fibers.fib"));
   MITK_INFO << fib->GetNumFibers();
   node = mitk::DataNode::New();
   node->SetData(fib);
 }
コード例 #12
0
  bool mitk::NodeDisplacementFilter::AddNode( mitk::DataNode::Pointer node )
  {
    // Consistency Checks
    if (node.IsNull())
    {
      MITK_WARN("NodeDisplacementFilter")
        << "Null Node passed to NodeDisplacementFilter. Ignoring Node....";
      return false;
    }
    if (node->GetData() == 0)
    {
      MITK_WARN("NodeDisplacementFilter")
        << "Empty Node passed to NodeDisplacementFilter. Ignoring Node....";
      return false;
    }
    if(m_SelectedInput == -1)
    {
      MITK_ERROR("NodeDisplacementFilter")
        << "Cannot add nodes before input Stream was selected";
      mitkThrow() << "Cannot add nodes before input Stream was selected";
    }

    this->Update(); // make sure we are working on current data
    mitk::NavigationData::Pointer reference = this->GetOutput(m_SelectedInput);

    if (! reference->IsDataValid())
    {
      MITK_WARN("NodeDisplacementFilter")
        << "Cannot add node while selected tool is not tracked. Ignoring Node....";
      return false;
    }

    // find transformation and add node
    mitk::AffineTransform3D::Pointer inverseAffineTransform = mitk::AffineTransform3D::New();
    if ( ! reference->GetAffineTransform3D()->GetInverse(inverseAffineTransform) )
    {
      MITK_ERROR("NodeDisplacementFilter")
        << "Could not get the inverse transformation of the navigation data transformation.";
      mitkThrow() << "Could not get the inverse transformation of the navigation data transformation.";
    }

    inverseAffineTransform->Compose(node->GetData()->GetGeometry()->GetIndexToWorldTransform(), true);
    m_Transforms.push_back(inverseAffineTransform);
    m_Nodes.push_back(node);

    return true;
  }
コード例 #13
0
 foreach( mitk::DataNode::Pointer node, nodes )
 {
   if( node.IsNotNull() )
   {
     m_Controls.m_AddInteractor->setEnabled( true );
     return;
   }
 }
コード例 #14
0
  foreach ( mitk::DataNode::Pointer referenceNode, selectedNodes )
  {

    if (referenceNode.IsNull()) return;

    mitk::LabelSetImage::Pointer referenceImage = dynamic_cast<mitk::LabelSetImage*>( referenceNode->GetData() );
    assert(referenceImage);

    std::string sName = referenceNode->GetName();
    QString qName;
    qName.sprintf("%s.lsetp",sName.c_str());
    QString filename = QFileDialog::getOpenFileName(nullptr,"Load file",QString(),"LabelSet Preset(*.lsetp)");
    if ( filename.isEmpty() )
      return;

    std::string fileName = filename.toStdString();
    mitk::LabelSetIOHelper::LoadLabelSetImagePreset(fileName, referenceImage);
  }
コード例 #15
0
void QmitkIGTTrackingLabView::OnToolLoaded(int index, mitk::DataNode::Pointer toolNode)
{
  if(m_Source.IsNull() || m_Visualizer.IsNull())
    return;

  mitk::DataStorage* ds = this->GetDefaultDataStorage();
  if(ds == NULL)
  {
    QMessageBox::warning(NULL,"DataStorage Access Error", "Could not access DataStorage. Loaded tool representation can not be shown!");
    return;
  }

  mitk::NavigationData::Pointer tempND = m_Source->GetOutput(index);
  if(tempND.IsNull())
    return;

  // try to find DataNode for tool in DataStorage
  const char* toolName = tempND->GetName();
  mitk::DataNode::Pointer tempNode = ds->GetNamedNode(toolName);

  if(tempNode.IsNull())
  {
    tempNode = mitk::DataNode::New();  // create new node, if none was found
    ds->Add(tempNode);
  }

  tempNode->SetData(toolNode->GetData());
  tempNode->SetName(toolNode->GetName());

  m_PSRecToolSelectionComboBox->setItemText(index,toolNode->GetName().c_str());

  m_VirtualViewToolSelectionWidget->ChangeToolName(index, QString(toolNode->GetName().c_str()));
  m_PermanentRegistrationToolSelectionWidget->ChangeToolName(index, QString(toolNode->GetName().c_str()));

  m_Visualizer->SetRepresentationObject(index, tempNode->GetData());
  m_Visualizer->Update();

  tempNode->Modified();
  this->GlobalReinit();
}
コード例 #16
0
void mitk::USZonesInteractor::UpdateSurface(mitk::DataNode::Pointer dataNode)
{
  if (!dataNode->GetData())
  {
    MITK_WARN("USZonesInteractor")("DataInteractor")
      << "Cannot update surface for node as no data is set to the node.";
    return;
  }

  mitk::Point3D origin = dataNode->GetData()->GetGeometry()->GetOrigin();

  float radius;
  if (!dataNode->GetFloatProperty(DATANODE_PROPERTY_SIZE, radius))
  {
    MITK_WARN("USZonesInteractor")("DataInteractor")
      << "Cannut update surface for node as no radius is specified in the node properties.";
    return;
  }

  mitk::Surface::Pointer zone = mitk::Surface::New();

  // create a vtk sphere with given radius
  vtkSphereSource *vtkData = vtkSphereSource::New();
  vtkData->SetRadius(radius);
  vtkData->SetCenter(0, 0, 0);
  vtkData->SetPhiResolution(20);
  vtkData->SetThetaResolution(20);
  vtkData->Update();
  zone->SetVtkPolyData(vtkData->GetOutput());
  vtkData->Delete();

  // set vtk sphere and origin to data node (origin must be set
  // again, because of the new sphere set as data)
  dataNode->SetData(zone);
  dataNode->GetData()->GetGeometry()->SetOrigin(origin);

  // update the RenderWindow to show the changed surface
  mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
コード例 #17
0
ファイル: QmitkSliceWidget.cpp プロジェクト: Cdebus/MITK
void QmitkSliceWidget::SetData(mitk::DataNode::Pointer node, mitk::SliceNavigationController::ViewDirection view)
{
  mitk::Image::Pointer image = dynamic_cast<mitk::Image *>(node->GetData());

  if (image.IsNull())
  {
    MITK_WARN << "QmitkSliceWidget data is not an image!";
    return;
  }

  m_SlicedGeometry = image->GetSlicedGeometry();
  this->InitWidget(view);
}
コード例 #18
0
static std::string CreateFileName(mitk::DataNode::Pointer dataNode)
{
  std::string path;
  dataNode->GetStringProperty("path", path);

  std::string name;
  dataNode->GetStringProperty("name", name);

  if (name.length() < 5)
  {
    name += ".scn";
  }
  else
  {
    std::string ext = name.substr(name.length() - 4);
    std::transform(ext.begin(), ext.end(), ext.begin(), tolower);

    if (ext != ".scn" && ext != ".xml")
      name += ".scn";
  }

  return path + "/" + name;
}
コード例 #19
0
void QmitkFiducialRegistrationWidget::SetTrackerFiducialsNode( mitk::DataNode::Pointer trackerFiducialsNode )
{
  if(trackerFiducialsNode.IsNull())
  {
    FRW_WARN<< "tracker fiducial node is NULL";
    return;
  }
  m_Controls->m_RegistrationTrackingPoints->SetPointSetNode(trackerFiducialsNode); // pass node to pointListWidget
  if(m_MultiWidget == NULL)
  {
    FRW_WARN<< "stdMultiWidget is NULL";
    return;
  }
  m_Controls->m_RegistrationTrackingPoints->SetMultiWidget(m_MultiWidget); // pass multiWidget to pointListWidget
}
コード例 #20
0
ファイル: mitkFiberMapper3DTest.cpp プロジェクト: m4271n/MITK
  void Color3D()
  {
    mitk::FiberBundle::Pointer fib = dynamic_cast<mitk::FiberBundle*>(node->GetData());
    fib->SetFiberColors(255, 255, 255);

    mitk::RenderingTestHelper renderingHelper(640, 480);
    renderingHelper.AddNodeToStorage(node);
    renderingHelper.SetMapperIDToRender3D();
    renderingHelper.GetVtkRenderer()->SetBackground(0.0, 0.0, 0.0);

    renderingHelper.SaveReferenceScreenShot(mitk::IOUtil::GetTempPath()+"fib_color_3D.png");
    mitk::Image::Pointer test_image = mitk::IOUtil::Load<mitk::Image>(mitk::IOUtil::GetTempPath()+"fib_color_3D.png");
    mitk::Image::Pointer ref_image = mitk::IOUtil::Load<mitk::Image>(GetTestDataFilePath("DiffusionImaging/Rendering/fib_color_3D.png"));
    MITK_ASSERT_EQUAL(test_image, ref_image, "Check if images are equal.");
  }
コード例 #21
0
void QmitkNavigationDataPlayerView::AddTrajectory(mitk::DataStorage* ds, mitk::DataNode::Pointer trajectoryNode)
{
  if(ds == NULL)
    return;

  if(m_Trajectory.IsNotNull())
    ds->Remove(m_Trajectory);  // remove trajectory from DataStorage if already exists


  // add trajectory to DataStorage
  if(ds != NULL && trajectoryNode.IsNotNull())
  {
    m_Trajectory = trajectoryNode;
    ds->Add(m_Trajectory);
  }
}
コード例 #22
0
    void setUp()
    {
        //Create DataNode as a container for our PointSet to be tested
        m_TestPointSetNode = mitk::DataNode::New();

        // Create PointSetData Interactor
        m_DataInteractor = mitk::PointSetDataInteractor::New();
        // Load the according state machine for regular point set interaction
        m_DataInteractor->LoadStateMachine("PointSet.xml");
        // Set the configuration file that defines the triggers for the transitions
        m_DataInteractor->SetEventConfig("PointSetConfig.xml");
        // set the DataNode (which already is added to the DataStorage)
        m_DataInteractor->SetDataNode(m_TestPointSetNode);

        //Create new PointSet which will receive the interaction input
        m_TestPointSet = mitk::PointSet::New();
        m_TestPointSetNode->SetData(m_TestPointSet);
    }
コード例 #23
0
ファイル: QtFreeRender.cpp プロジェクト: zomboir/MITK
void AddDisplayPlaneSubTree()
{
  // add the displayed planes of the multiwidget to a node to which the subtree
  // @a planesSubTree points ...

  float white[3] =
  { 1.0f, 1.0f, 1.0f };
  mitk::Geometry2DDataMapper2D::Pointer mapper;
  mitk::IntProperty::Pointer layer = mitk::IntProperty::New(1000);

  // ... of widget 1
  m_PlaneNode1 = (mitk::BaseRenderer::GetInstance(mitkWidget1->GetVtkRenderWindow()))->GetCurrentWorldGeometry2DNode();
  m_PlaneNode1->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow()));
  m_PlaneNode1->SetProperty("visible", mitk::BoolProperty::New(true));
  m_PlaneNode1->SetProperty("name", mitk::StringProperty::New("widget1Plane"));
  m_PlaneNode1->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false));
  m_PlaneNode1->SetProperty("helper object", mitk::BoolProperty::New(true));
  m_PlaneNode1->SetProperty("layer", layer);
  m_PlaneNode1->SetColor(1.0, 0.0, 0.0);
  mapper = mitk::Geometry2DDataMapper2D::New();
  m_PlaneNode1->SetMapper(mitk::BaseRenderer::Standard2D, mapper);

  // ... of widget 2
  m_PlaneNode2 = (mitk::BaseRenderer::GetInstance(mitkWidget2->GetVtkRenderWindow()))->GetCurrentWorldGeometry2DNode();
  m_PlaneNode2->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow()));
  m_PlaneNode2->SetProperty("visible", mitk::BoolProperty::New(true));
  m_PlaneNode2->SetProperty("name", mitk::StringProperty::New("widget2Plane"));
  m_PlaneNode2->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false));
  m_PlaneNode2->SetProperty("helper object", mitk::BoolProperty::New(true));
  m_PlaneNode2->SetProperty("layer", layer);
  m_PlaneNode2->SetColor(0.0, 1.0, 0.0);
  mapper = mitk::Geometry2DDataMapper2D::New();
  m_PlaneNode2->SetMapper(mitk::BaseRenderer::Standard2D, mapper);

  // ... of widget 3
  m_PlaneNode3 = (mitk::BaseRenderer::GetInstance(mitkWidget3->GetVtkRenderWindow()))->GetCurrentWorldGeometry2DNode();
  m_PlaneNode3->SetColor(white, mitk::BaseRenderer::GetInstance(mitkWidget4->GetVtkRenderWindow()));
  m_PlaneNode3->SetProperty("visible", mitk::BoolProperty::New(true));
  m_PlaneNode3->SetProperty("name", mitk::StringProperty::New("widget3Plane"));
  m_PlaneNode3->SetProperty("includeInBoundingBox", mitk::BoolProperty::New(false));
  m_PlaneNode3->SetProperty("helper object", mitk::BoolProperty::New(true));
  m_PlaneNode3->SetProperty("layer", layer);
  m_PlaneNode3->SetColor(0.0, 0.0, 1.0);
  mapper = mitk::Geometry2DDataMapper2D::New();
  m_PlaneNode3->SetMapper(mitk::BaseRenderer::Standard2D, mapper);

  m_Node = mitk::DataNode::New();
  m_Node->SetProperty("name", mitk::StringProperty::New("Widgets"));
  m_Node->SetProperty("helper object", mitk::BoolProperty::New(true));

  //AddPlanesToDataStorage
  if (m_PlaneNode1.IsNotNull() && m_PlaneNode2.IsNotNull() && m_PlaneNode3.IsNotNull() && m_Node.IsNotNull())
  {
    if (m_DataStorage.IsNotNull())
    {
      m_DataStorage->Add(m_Node);
      m_DataStorage->Add(m_PlaneNode1, m_Node);
      m_DataStorage->Add(m_PlaneNode2, m_Node);
      m_DataStorage->Add(m_PlaneNode3, m_Node);
      static_cast<mitk::Geometry2DDataMapper2D*>(m_PlaneNode1->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(
          m_DataStorage, m_Node);
      static_cast<mitk::Geometry2DDataMapper2D*>(m_PlaneNode2->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(
          m_DataStorage, m_Node);
      static_cast<mitk::Geometry2DDataMapper2D*>(m_PlaneNode3->GetMapper(mitk::BaseRenderer::Standard2D))->SetDatastorageAndGeometryBaseNode(
          m_DataStorage, m_Node);
    }
  }
}
コード例 #24
0
ファイル: QmitkAutocropAction.cpp プロジェクト: Cdebus/MITK
  foreach ( mitk::DataNode::Pointer node, selectedNodes )
  {
    if (node)
    {
      mitk::Image::Pointer image = dynamic_cast<mitk::Image*>( node->GetData() );
      if (image.IsNull()) return;

      mitk::ProgressBar::GetInstance()->AddStepsToDo(10);
      mitk::ProgressBar::GetInstance()->Progress(2);

      qApp->processEvents();

      mitk::AutoCropImageFilter::Pointer cropFilter = mitk::AutoCropImageFilter::New();
      cropFilter->SetInput( image );
      cropFilter->SetBackgroundValue( 0 );
      cropFilter->SetMarginFactor(1.5);
      try
      {
        cropFilter->Update();

        image = cropFilter->GetOutput();

        if (image.IsNotNull())
        {

          if (image->GetDimension() == 4)
          {
            MITK_INFO << "4D AUTOCROP DOES NOT WORK AT THE MOMENT";
            throw "4D AUTOCROP DOES NOT WORK AT THE MOMENT";

            unsigned int timesteps = image->GetDimension(3);
            for (unsigned int i = 0; i < timesteps; i++)
            {
              mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New();
              imageTimeSelector->SetInput(image);
              imageTimeSelector->SetTimeNr(i);
              imageTimeSelector->UpdateLargestPossibleRegion();

              // We split a long nested code line into separate calls for debugging:
              mitk::ImageSource::OutputImageType *_3dSlice = imageTimeSelector->GetOutput();
              mitk::Image::Pointer _cropped3dSlice = this->IncreaseCroppedImageSize(_3dSlice);

              // +++ BUG +++ BUG +++ BUG +++ BUG +++ BUG +++ BUG +++ BUG +++
              {
                mitk::ImageWriteAccessor writeAccess(_cropped3dSlice);
                void *_data = writeAccess.GetData();

                // <ToBeRemoved>
                // We write some stripes into the image
                if ((i & 1) == 0)
                {
                  int depth = _cropped3dSlice->GetDimension(2);
                  int height = _cropped3dSlice->GetDimension(1);
                  int width = _cropped3dSlice->GetDimension(0);

                  for (int z = 0; z < depth; ++z)
                    for (int y = 0; y < height; ++y)
                      for (int x = 0; x < width; ++x)
                        reinterpret_cast<unsigned char *>(_data)[(width * height * z) + (width * y) + x] = x & 1;
                }
                // </ToBeRemoved>

                image->SetVolume(_data, i);
              }
            }
            node->SetData( image ); // bug fix 3145
          }
          else
          {
            node->SetData( this->IncreaseCroppedImageSize(image) ); // bug fix 3145
          }
          // Reinit node
          mitk::RenderingManager::GetInstance()->InitializeViews(
            node->GetData()->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true );
          mitk::RenderingManager::GetInstance()->RequestUpdateAll();

        }
      }
      catch(...)
      {
        MITK_ERROR << "Cropping image failed...";
      }
      mitk::ProgressBar::GetInstance()->Progress(8);
    }
    else
    {
      MITK_INFO << "   a nullptr node selected";
    }
  }
コード例 #25
0
mitk::NavigationTool::Pointer mitk::NavigationToolReader::ConvertDataNodeToNavigationTool(mitk::DataNode::Pointer node, std::string toolPath)
{
  mitk::NavigationTool::Pointer returnValue = mitk::NavigationTool::New();

  //DateTreeNode with Name and Surface
  returnValue->SetDataNode(node);

  //Identifier
  std::string identifier;
  node->GetStringProperty("identifier", identifier);
  returnValue->SetIdentifier(identifier);

  node->RemoveProperty("identifier");

  //Serial Number
  std::string serial;
  node->GetStringProperty("serial number", serial);
  returnValue->SetSerialNumber(serial);

  node->RemoveProperty("serial number");

  //Tracking Device
  mitk::TrackingDeviceType device_type;
  node->GetStringProperty("tracking device type", device_type);

  //For backward compability with old tool stroages (before 12/2015 device_type was an int value, now it is string)
  if (device_type.size() == 0)
  {
    /*
    This was the old enum. Numbers inserted for better readibility. Don't delete this if-case to allow loading of ols storages...
    enum TrackingDeviceType
    {
    0 NDIPolaris,                 ///< Polaris: optical Tracker from NDI
    1 NDIAurora,                  ///< Aurora: electromagnetic Tracker from NDI
    2 ClaronMicron,               ///< Micron Tracker: optical Tracker from Claron
    3 IntuitiveDaVinci,           ///< Intuitive Surgical: DaVinci Telemanipulator API Interface
    4 AscensionMicroBird,         ///< Ascension microBird / PCIBird family
    5 VirtualTracker,             ///< Virtual Tracking device class that produces random tracking coordinates
    6 TrackingSystemNotSpecified, ///< entry for not specified or initialized tracking system
    7 TrackingSystemInvalid,      ///< entry for invalid state (mainly for testing)
    8 NPOptitrack,                          ///< NaturalPoint: Optitrack optical Tracking System
    9 OpenIGTLinkTrackingDeviceConnection   ///< Device which is connected via open igt link
    };
    */
    int device_type_old;
    node->GetIntProperty("tracking device type", device_type_old);
    switch (device_type_old)
    {
    case 0:device_type = mitk::NDIPolarisTypeInformation::GetTrackingDeviceName(); break;
    case 1:device_type = mitk::NDIAuroraTypeInformation::GetTrackingDeviceName(); break;
    case 2:device_type = mitk::MicronTrackerTypeInformation::GetTrackingDeviceName(); break;
    case 3:device_type = "IntuitiveDaVinci"; break;
    case 4:device_type = "AscensionMicroBird"; break;
    case 5:device_type = mitk::VirtualTrackerTypeInformation::GetTrackingDeviceName(); break;
    case 6:device_type = mitk::UnspecifiedTrackingTypeInformation::GetTrackingDeviceName(); break;
    case 7:device_type = "TrackingSystemInvalid"; break;
    case 8:device_type = mitk::NPOptitrackTrackingTypeInformation::GetTrackingDeviceName(); break;
    case 9:device_type = mitk::OpenIGTLinkTypeInformation::GetTrackingDeviceName(); break;
    default: device_type = mitk::UnspecifiedTrackingTypeInformation::GetTrackingDeviceName(); break; //default... unknown...
    }
  }

  node->RemoveProperty("tracking device type");

  returnValue->SetTrackingDeviceType(static_cast<mitk::TrackingDeviceType>(device_type));

  //Tool Type
  int type;
  node->GetIntProperty("tracking tool type", type);
  returnValue->SetType(static_cast<mitk::NavigationTool::NavigationToolType>(type));

  node->RemoveProperty("tracking tool type");

  //Calibration File Name
  std::string calibration_filename;
  node->GetStringProperty("toolfileName", calibration_filename);
  if (calibration_filename == "none")
  {
    returnValue->SetCalibrationFile("none");
  }
  else
  {
    std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename;
    returnValue->SetCalibrationFile(calibration_filename_with_path);
  }

  node->RemoveProperty("toolfileName");

  //Tool Landmarks
  mitk::PointSet::Pointer ToolRegLandmarks = mitk::PointSet::New();
  mitk::PointSet::Pointer ToolCalLandmarks = mitk::PointSet::New();
  std::string RegLandmarksString;
  std::string CalLandmarksString;
  node->GetStringProperty("ToolRegistrationLandmarks", RegLandmarksString);
  node->GetStringProperty("ToolCalibrationLandmarks", CalLandmarksString);
  ToolRegLandmarks = ConvertStringToPointSet(RegLandmarksString);
  ToolCalLandmarks = ConvertStringToPointSet(CalLandmarksString);
  returnValue->SetToolLandmarks(ToolRegLandmarks);
  returnValue->SetToolControlPoints(ToolCalLandmarks);

  node->RemoveProperty("ToolRegistrationLandmarks");
  node->RemoveProperty("ToolCalibrationLandmarks");

  //Tool Tip
  std::string toolTipPositionString;
  std::string toolTipOrientationString;
  bool positionSet = node->GetStringProperty("ToolTipPosition", toolTipPositionString);
  bool orientationSet = node->GetStringProperty("ToolAxisOrientation", toolTipOrientationString);

  if (positionSet && orientationSet) //only define tooltip if it is set
  {
    returnValue->SetToolTipPosition(ConvertStringToPoint(toolTipPositionString));
    returnValue->SetToolAxisOrientation(ConvertStringToQuaternion(toolTipOrientationString));
  }
  else if (positionSet != orientationSet)
  {
    MITK_WARN << "Tooltip definition incomplete: position and orientation have to be set! Skipping tooltip definition.";
  }

  node->RemoveProperty("ToolTipPosition");
  node->RemoveProperty("ToolAxisOrientation");

  return returnValue;
}
コード例 #26
0
mitk::NavigationTool::Pointer mitk::NavigationToolReader::ConvertDataNodeToNavigationTool(mitk::DataNode::Pointer node, std::string toolPath)
  {
  mitk::NavigationTool::Pointer returnValue = mitk::NavigationTool::New();

  //DateTreeNode with Name and Surface
  mitk::DataNode::Pointer newNode = mitk::DataNode::New();
  newNode->SetName(node->GetName());
  newNode->SetData(node->GetData());
  returnValue->SetDataNode(newNode);

  //Identifier
  std::string identifier;
  node->GetStringProperty("identifier",identifier);
  returnValue->SetIdentifier(identifier);

  //Serial Number
  std::string serial;
  node->GetStringProperty("serial number",serial);
  returnValue->SetSerialNumber(serial);

  //Tracking Device
  int device_type;
  node->GetIntProperty("tracking device type",device_type);
  returnValue->SetTrackingDeviceType(static_cast<mitk::TrackingDeviceType>(device_type));

  //Tool Type
  int type;
  node->GetIntProperty("tracking tool type",type);
  returnValue->SetType(static_cast<mitk::NavigationTool::NavigationToolType>(type));

  //Calibration File Name
  std::string calibration_filename;
  node->GetStringProperty("toolfileName",calibration_filename);
  if (calibration_filename=="none")
    {
    returnValue->SetCalibrationFile("none");
    }
  else
    {
    std::string calibration_filename_with_path = toolPath + Poco::Path::separator() + calibration_filename;
    returnValue->SetCalibrationFile(calibration_filename_with_path);
    }

  //Tool Landmarks
  mitk::PointSet::Pointer ToolRegLandmarks = mitk::PointSet::New();
  mitk::PointSet::Pointer ToolCalLandmarks = mitk::PointSet::New();
  std::string RegLandmarksString;
  std::string CalLandmarksString;
  node->GetStringProperty("ToolRegistrationLandmarks",RegLandmarksString);
  node->GetStringProperty("ToolCalibrationLandmarks",CalLandmarksString);
  ToolRegLandmarks = ConvertStringToPointSet(RegLandmarksString);
  ToolCalLandmarks = ConvertStringToPointSet(CalLandmarksString);
  returnValue->SetToolRegistrationLandmarks(ToolRegLandmarks);
  returnValue->SetToolCalibrationLandmarks(ToolCalLandmarks);

  //Tool Tip
  std::string toolTipPositionString;
  std::string toolTipOrientationString;
  bool positionSet = node->GetStringProperty("ToolTipPosition",toolTipPositionString);
  bool orientationSet = node->GetStringProperty("ToolTipOrientation",toolTipOrientationString);

  if(positionSet && orientationSet) //only define tooltip if it is set
    {
    returnValue->SetToolTipPosition(ConvertStringToPoint(toolTipPositionString));
    returnValue->SetToolTipOrientation(ConvertStringToQuaternion(toolTipOrientationString));
    }
  else if(positionSet != orientationSet)
    {
    MITK_WARN << "Tooltip definition incomplete: position and orientation have to be set! Skipping tooltip definition.";
    }

  return returnValue;
  }
コード例 #27
0
void QmitkToFUtilView::CreateNode(const char* nodename, mitk::DataNode::Pointer& node)
{
  node = mitk::DataNode::New();
  node->SetProperty( "name", mitk::StringProperty::New(nodename));
}
コード例 #28
0
bool MRFRegistrationDisplay::setMITKImageSeries(mitk::DataNode::Pointer imageSeries)
{
	// try and cast the image
	mitk::Image::Pointer mitkImage = dynamic_cast<mitk::Image*>(imageSeries->GetData());
	if(mitkImage.IsNull())
	{
		std::cout << "Problem with the data you are tying to register" << std::endl;
		return false;
	}

	this->mitkImageSeries = imageSeries;



	// convert this image series into a stack of itk images
	int numImages = mitkImage->GetTimeSteps();

	// get each image from the series and create a itk image for each one
	for(int i = 0; i < numImages; i++)
	{
		mitk::Image::Pointer timeStep = mitk::Image::New();

		mitk::ImageSliceSelector::Pointer timeImageSelector = mitk::ImageSliceSelector::New();
		timeImageSelector->SetInput(mitkImage);
		timeImageSelector->SetTimeNr(i);
		timeImageSelector->SetSliceNr(0);

		try
		{
			timeImageSelector->Update();
		}
		catch( mitk::Exception &e )
		{
			std::cerr << "Problem extracting the time slice from the series" << std::endl;
			std::cerr << e << std::endl;
			return false;
		}


		timeStep = timeImageSelector->GetOutput();


		typedef mitk::ImageToItk<ImageType> ImageToItkFilterType;
		ImageToItkFilterType::Pointer itkFilter = ImageToItkFilterType::New();
		itkFilter->SetInput(timeStep);

		try
		{
			itkFilter->Update();
		}
		catch( mitk::Exception &e)
		{
			std::cerr << "Problem in converting to ITK image" << std::endl;
			std::cerr << e << std::endl;
			return false;
		}


		if(i == 0)
		{
			this->itkFixedImage = itkFilter->GetOutput();
		}
		else
		{
			this->itkMovingImages.push_back(itkFilter->GetOutput());
		}
	}

	showParameters();

	return true;


}