Ejemplo n.º 1
0
void QmitkPreprocessingView::CallMultishellToSingleShellFilter(itk::DWIVoxelFunctor * functor, mitk::DiffusionImage<DiffusionPixelType>::Pointer ImPtr, QString imageName)
{
  typedef itk::RadialMultishellToSingleshellImageFilter<DiffusionPixelType, DiffusionPixelType> FilterType;

  // filter input parameter
  const mitk::DiffusionImage<DiffusionPixelType>::BValueMap
      &originalShellMap  = ImPtr->GetBValueMap();

  const mitk::DiffusionImage<DiffusionPixelType>::ImageType
      *vectorImage       = ImPtr->GetVectorImage();

  const mitk::DiffusionImage<DiffusionPixelType>::GradientDirectionContainerType::Pointer
      gradientContainer = ImPtr->GetDirections();

  const unsigned int
      &bValue            = ImPtr->GetReferenceBValue();

  mitk::DataNode::Pointer imageNode = 0;

  // filter call
  FilterType::Pointer filter = FilterType::New();
  filter->SetInput(vectorImage);
  filter->SetOriginalGradientDirections(gradientContainer);
  filter->SetOriginalBValueMap(originalShellMap);
  filter->SetOriginalBValue(bValue);
  filter->SetFunctor(functor);
  filter->Update();

  // create new DWI image
  mitk::DiffusionImage<DiffusionPixelType>::Pointer outImage = mitk::DiffusionImage<DiffusionPixelType>::New();
  outImage->SetVectorImage( filter->GetOutput() );
  outImage->SetReferenceBValue( m_Controls->m_targetBValueSpinBox->value() );
  outImage->SetDirections( filter->GetTargetGradientDirections() );
  outImage->InitializeFromVectorImage();

  imageNode = mitk::DataNode::New();
  imageNode->SetData( outImage );
  imageNode->SetName(imageName.toStdString().c_str());
  GetDefaultDataStorage()->Add(imageNode);

  if(m_Controls->m_OutputRMSErrorImage->isChecked()){
    // create new Error image
    FilterType::ErrorImageType::Pointer errImage = filter->GetErrorImage();
    mitk::Image::Pointer mitkErrImage = mitk::Image::New();
    mitkErrImage->InitializeByItk<FilterType::ErrorImageType>(errImage);
    mitkErrImage->SetVolume(errImage->GetBufferPointer());

    imageNode = mitk::DataNode::New();
    imageNode->SetData( mitkErrImage );
    imageNode->SetName((imageName+"_Error").toStdString().c_str());
    GetDefaultDataStorage()->Add(imageNode);
  }
}
    void setUp()
    {
        // reference files
        m_InputDwi = dynamic_cast<mitk::DiffusionImage<short>*>(mitk::IOUtil::LoadDataNode(GetTestDataFilePath("DiffusionImaging/Fiberfox/StickBall_RELAX.dwi"))->GetData());

        // parameter setup
        m_Parameters = FiberfoxParameters<short>();
        m_Parameters.m_SignalGen.m_ImageRegion = m_InputDwi->GetVectorImage()->GetLargestPossibleRegion();
        m_Parameters.m_SignalGen.m_ImageSpacing = m_InputDwi->GetVectorImage()->GetSpacing();
        m_Parameters.m_SignalGen.m_ImageOrigin = m_InputDwi->GetVectorImage()->GetOrigin();
        m_Parameters.m_SignalGen.m_ImageDirection = m_InputDwi->GetVectorImage()->GetDirection();
        m_Parameters.m_SignalGen.m_Bvalue = m_InputDwi->GetReferenceBValue();
        m_Parameters.m_SignalGen.SetGradienDirections(m_InputDwi->GetDirections());
    }