예제 #1
0
void QmitkPreprocessingView::DoAdcCalculation()
{
  if (m_DiffusionImage.IsNull())
    return;

  typedef mitk::DiffusionImage< DiffusionPixelType >            DiffusionImageType;
  typedef itk::AdcImageFilter< DiffusionPixelType, double >     FilterType;


  for (unsigned int i=0; i<m_SelectedDiffusionNodes.size(); i++)
  {
    DiffusionImageType::Pointer inImage = dynamic_cast< DiffusionImageType* >(m_SelectedDiffusionNodes.at(i)->GetData());
    FilterType::Pointer filter = FilterType::New();
    filter->SetInput(inImage->GetVectorImage());
    filter->SetGradientDirections(inImage->GetDirections());
    filter->SetB_value(inImage->GetReferenceBValue());
    filter->Update();

    mitk::Image::Pointer image = mitk::Image::New();
    image->InitializeByItk( filter->GetOutput() );
    image->SetVolume( filter->GetOutput()->GetBufferPointer() );
    mitk::DataNode::Pointer imageNode = mitk::DataNode::New();
    imageNode->SetData( image );
    QString name = m_SelectedDiffusionNodes.at(i)->GetName().c_str();

    imageNode->SetName((name+"_ADC").toStdString().c_str());
    GetDefaultDataStorage()->Add(imageNode);
  }
}
예제 #2
0
void QmitkPreprocessingView::DoLengthCorrection()
{
  if (m_DiffusionImage.IsNull())
    return;

  typedef mitk::DiffusionImage<DiffusionPixelType>  DiffusionImageType;
  typedef itk::DwiGradientLengthCorrectionFilter  FilterType;

  FilterType::Pointer filter = FilterType::New();
  filter->SetRoundingValue( m_Controls->m_B_ValueMap_Rounder_SpinBox->value());
  filter->SetReferenceBValue(m_DiffusionImage->GetReferenceBValue());
  filter->SetReferenceGradientDirectionContainer(m_DiffusionImage->GetDirections());
  filter->Update();

  DiffusionImageType::Pointer image = DiffusionImageType::New();
  image->SetVectorImage( m_DiffusionImage->GetVectorImage());
  image->SetReferenceBValue( filter->GetNewBValue() );
  image->SetDirections( filter->GetOutputGradientDirectionContainer());
  image->InitializeFromVectorImage();

  mitk::DataNode::Pointer imageNode = mitk::DataNode::New();
  imageNode->SetData( image );
  QString name = m_SelectedDiffusionNodes.front()->GetName().c_str();

  imageNode->SetName((name+"_rounded").toStdString().c_str());
  GetDefaultDataStorage()->Add(imageNode);
}
예제 #3
0
void QmitkDenoisingView::AfterThread()
{
  m_ThreadIsRunning = false;
  // stop timer to stop updates of progressbar
  m_DenoisingTimer->stop();
  // make sure progressbar is finished
  mitk::ProgressBar::GetInstance()->Progress(m_MaxProgressCount);
  if (m_CompletedCalculation)
  {
    switch (m_SelectedFilter)
    {
      case NOFILTERSELECTED:
      case GAUSS:
      {
        break;
      }

      case NLM:
      {
        DiffusionImageType::Pointer image = DiffusionImageType::New();
        image->SetVectorImage(m_NonLocalMeansFilter->GetOutput());
        image->SetReferenceBValue(m_InputImage->GetReferenceBValue());
        image->SetDirections(m_InputImage->GetDirections());
        image->InitializeFromVectorImage();
        mitk::DataNode::Pointer imageNode = mitk::DataNode::New();
        imageNode->SetData( image );
        QString name = m_ImageNode->GetName().c_str();

        //TODO: Rician adaption & joint information in name
        if (m_Controls->m_RicianCheckbox->isChecked() && !m_Controls->m_JointInformationCheckbox->isChecked())
        {
          imageNode->SetName((name+"_NLMr_"+QString::number(m_Controls->m_SpinBoxParameter1->value())+"-"+QString::number(m_Controls->m_SpinBoxParameter2->value())).toStdString().c_str());
        }
        else if(!m_Controls->m_RicianCheckbox->isChecked() && m_Controls->m_JointInformationCheckbox->isChecked())
        {
          imageNode->SetName((name+"_NLMv_"+QString::number(m_Controls->m_SpinBoxParameter1->value())+"-"+QString::number(m_Controls->m_SpinBoxParameter2->value())).toStdString().c_str());
        }
        else if(m_Controls->m_RicianCheckbox->isChecked() && m_Controls->m_JointInformationCheckbox->isChecked())
        {
          imageNode->SetName((name+"_NLMvr_"+QString::number(m_Controls->m_SpinBoxParameter1->value())+"-"+QString::number(m_Controls->m_SpinBoxParameter2->value())).toStdString().c_str());
        }
        else
        {
          imageNode->SetName((name+"_NLM_"+QString::number(m_Controls->m_SpinBoxParameter1->value())+"-"+QString::number(m_Controls->m_SpinBoxParameter2->value())).toStdString().c_str());
        }
        GetDefaultDataStorage()->Add(imageNode);
        break;
      }
    }
  }

  m_Controls->m_ParameterBox->setEnabled(true);
  m_Controls->m_ApplyButton->setText("Apply");
}
void QmitkRegistrationWorker::run()
{

  typedef mitk::DiffusionImage<DiffusionPixelType>              DiffusionImageType;
  typedef DiffusionImageType::BValueMap BValueMap;

  for( int i=0; i< m_View->m_SelectedDiffusionNodes.size(); i++)
  {

    m_View->m_GlobalRegisterer = QmitkDiffusionRegistrationView::DWIHeadMotionCorrectionFilterType::New();

    mitk::DataNode::Pointer node = m_View->m_SelectedDiffusionNodes.at(i);
    DiffusionImageType::Pointer inImage = dynamic_cast<mitk::DiffusionImage<short>*>(node->GetData());
    if(inImage.IsNull())
    {
      MITK_ERROR << "Error occured: can't get input image. \nAborting";
      return;
    }


    m_View->m_GlobalRegisterer->SetInput(inImage);

    try{
      m_View->m_GlobalRegisterer->Update();
    }
    catch( mitk::Exception e )
    {
      MITK_ERROR << "Internal error occured: " <<  e.what() << "\nAborting";
    }

    if( m_View->m_GlobalRegisterer->GetIsInValidState() )
    {
      DiffusionImageType::Pointer image = m_View->m_GlobalRegisterer->GetOutput();
      mitk::DataNode::Pointer imageNode = mitk::DataNode::New();
      imageNode->SetData( image );
      QString name = node->GetName().c_str();
      imageNode->SetName((name+"_MC").toStdString().c_str());
      m_View->GetDataStorage()->Add(imageNode);
    }


  }


  m_View->m_RegistrationThread.quit();
}
예제 #5
0
/**
 * Denoises DWI using the Nonlocal - Means algorithm
 */
int DwiDenoising(int argc, char* argv[])
{
  ctkCommandLineParser parser;
  parser.setArgumentPrefix("--", "-");
  parser.addArgument("input", "i", ctkCommandLineParser::String, "input image (DWI)", us::Any(), false);
  parser.addArgument("variance", "v", ctkCommandLineParser::Float, "noise variance", us::Any(), false);
  parser.addArgument("mask", "m", ctkCommandLineParser::String, "brainmask for input image", us::Any(), true);
  parser.addArgument("search", "s", ctkCommandLineParser::Int, "search radius", us::Any(), true);
  parser.addArgument("compare", "c", ctkCommandLineParser::Int, "compare radius", us::Any(), true);
  parser.addArgument("joint", "j", ctkCommandLineParser::Bool, "use joint information");
  parser.addArgument("rician", "r", ctkCommandLineParser::Bool, "use rician adaption");

  map<string, us::Any> parsedArgs = parser.parseArguments(argc, argv);
  if (parsedArgs.size()==0)
      return EXIT_FAILURE;

  string inFileName = us::any_cast<string>(parsedArgs["input"]);
  double variance = static_cast<double>(us::any_cast<float>(parsedArgs["variance"]));
  string maskName;
  if (parsedArgs.count("mask"))
    maskName = us::any_cast<string>(parsedArgs["mask"]);
  string outFileName = inFileName;
  boost::algorithm::erase_all(outFileName, ".dwi");
  int search = 4;
  if (parsedArgs.count("search"))
    search = us::any_cast<int>(parsedArgs["search"]);
  int compare = 1;
  if (parsedArgs.count("compare"))
    compare = us::any_cast<int>(parsedArgs["compare"]);
  bool joint = false;
  if (parsedArgs.count("joint"))
    joint = true;
  bool rician = false;
  if (parsedArgs.count("rician"))
    rician = true;

  try
  {


    if( boost::algorithm::ends_with(inFileName, ".dwi"))
    {

      DiffusionImageType::Pointer dwi = dynamic_cast<DiffusionImageType*>(LoadFile(inFileName).GetPointer());

      itk::NonLocalMeansDenoisingFilter<short>::Pointer filter = itk::NonLocalMeansDenoisingFilter<short>::New();
      filter->SetNumberOfThreads(12);
      filter->SetInputImage(dwi->GetVectorImage());

      if (!maskName.empty())
      {
        mitk::Image::Pointer mask = dynamic_cast<mitk::Image*>(LoadFile(maskName).GetPointer());
        ImageType::Pointer itkMask = ImageType::New();
        mitk::CastToItkImage(mask, itkMask);
        filter->SetInputMask(itkMask);
      }


      filter->SetUseJointInformation(joint);
      filter->SetUseRicianAdaption(rician);
      filter->SetSearchRadius(search);
      filter->SetComparisonRadius(compare);
      filter->SetVariance(variance);
      filter->Update();

      DiffusionImageType::Pointer output = DiffusionImageType::New();
      output->SetVectorImage(filter->GetOutput());
      output->SetReferenceBValue(dwi->GetReferenceBValue());
      output->SetDirections(dwi->GetDirections());
      output->InitializeFromVectorImage();

      std::stringstream name;
      name << outFileName << "_NLM_" << search << "-" << compare << "-" << variance << ".dwi";

      MITK_INFO << "Writing: " << name.str();

      mitk::NrrdDiffusionImageWriter<short>::Pointer writer = mitk::NrrdDiffusionImageWriter<short>::New();
      writer->SetInput(output);
      writer->SetFileName(name.str());
      writer->Update();



      MITK_INFO << "Finish!";
    }
    else
    {
      MITK_INFO << "Only supported for .dwi!";
    }
  }
  catch (itk::ExceptionObject e)
  {
      MITK_INFO << e;
      return EXIT_FAILURE;
  }
  catch (std::exception e)
  {
      MITK_INFO << e.what();
      return EXIT_FAILURE;
  }
  catch (...)
  {
      MITK_INFO << "ERROR!?!";
      return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}
예제 #6
0
void mitk::RegistrationWrapper::ApplyTransformationToImage(mitk::Image::Pointer img, const mitk::RegistrationWrapper::RidgidTransformType &transformation,double* offset, mitk::Image* resampleReference,  bool binary)
{
  typedef mitk::DiffusionImage<short> DiffusionImageType;

  if (dynamic_cast<DiffusionImageType*> (img.GetPointer()) == NULL)
  {

    ItkImageType::Pointer itkImage = ItkImageType::New();


    MITK_ERROR << "imgCopy  0 " <<  "/" << img->GetReferenceCount();
    MITK_ERROR << "pixel type  " << img->GetPixelType().GetComponentTypeAsString();

    CastToItkImage(img, itkImage);



    typedef itk::Euler3DTransform< double > RigidTransformType;
    RigidTransformType::Pointer rtransform = RigidTransformType::New();
    RigidTransformType::ParametersType parameters(RigidTransformType::ParametersDimension);

    for (int i = 0; i<6;++i)
      parameters[i] = transformation[i];

    rtransform->SetParameters( parameters );

    mitk::Point3D origin = itkImage->GetOrigin();
    origin[0]-=offset[0];
    origin[1]-=offset[1];
    origin[2]-=offset[2];

    mitk::Point3D newOrigin = rtransform->GetInverseTransform()->TransformPoint(origin);

    itk::Matrix<double,3,3> dir = itkImage->GetDirection();
    itk::Matrix<double,3,3> transM  ( vnl_inverse(rtransform->GetMatrix().GetVnlMatrix()));
    itk::Matrix<double,3,3> newDirection = transM * dir;

    itkImage->SetOrigin(newOrigin);
    itkImage->SetDirection(newDirection);

    // Perform Resampling if reference image is provided
    if (resampleReference != NULL)
    {
      typedef itk::ResampleImageFilter<ItkImageType, ItkImageType>  ResampleFilterType;

      ItkImageType::Pointer itkReference = ItkImageType::New();
      CastToItkImage(resampleReference,itkReference);

      typedef itk::WindowedSincInterpolateImageFunction< ItkImageType, 3> WindowedSincInterpolatorType;
      WindowedSincInterpolatorType::Pointer sinc_interpolator = WindowedSincInterpolatorType::New();

      typedef itk::NearestNeighborInterpolateImageFunction< ItkImageType, double > NearestNeighborInterpolatorType;
      NearestNeighborInterpolatorType::Pointer nn_interpolator = NearestNeighborInterpolatorType::New();


      ResampleFilterType::Pointer resampler = ResampleFilterType::New();
      resampler->SetInput(itkImage);
      resampler->SetReferenceImage( itkReference );
      resampler->UseReferenceImageOn();
      if (binary)
        resampler->SetInterpolator(nn_interpolator);
      else
        resampler->SetInterpolator(sinc_interpolator);

      resampler->Update();

      GrabItkImageMemory(resampler->GetOutput(), img);
    }
    else
    {
      // !! CastToItk behaves very differently depending on the original data type
      // if the target type is the same as the original, only a pointer to the data is set
      // and an additional GrabItkImageMemory will cause a segfault when the image is destroyed
      // GrabItkImageMemory - is not necessary in this case since we worked on the original data
      // See Bug 17538.
      if (img->GetPixelType().GetComponentTypeAsString() != "double")
        img = GrabItkImageMemory(itkImage);
    }
  }
  else
  {
    DiffusionImageType::Pointer diffImages = dynamic_cast<DiffusionImageType*>(img.GetPointer());

    typedef itk::Euler3DTransform< double > RigidTransformType;
    RigidTransformType::Pointer rtransform = RigidTransformType::New();
    RigidTransformType::ParametersType parameters(RigidTransformType::ParametersDimension);

    for (int i = 0; i<6;++i)
    {
      parameters[i] = transformation[i];
    }

    rtransform->SetParameters( parameters );

    mitk::Point3D b0origin = diffImages->GetVectorImage()->GetOrigin();
    b0origin[0]-=offset[0];
    b0origin[1]-=offset[1];
    b0origin[2]-=offset[2];

    mitk::Point3D newOrigin = rtransform->GetInverseTransform()->TransformPoint(b0origin);

    itk::Matrix<double,3,3> dir = diffImages->GetVectorImage()->GetDirection();
    itk::Matrix<double,3,3> transM  ( vnl_inverse(rtransform->GetMatrix().GetVnlMatrix()));
    itk::Matrix<double,3,3> newDirection = transM * dir;

    diffImages->GetVectorImage()->SetOrigin(newOrigin);
    diffImages->GetVectorImage()->SetDirection(newDirection);
    diffImages->Modified();

    mitk::DiffusionImageCorrectionFilter<short>::Pointer correctionFilter = mitk::DiffusionImageCorrectionFilter<short>::New();

    // For Diff. Images: Need to rotate the gradients (works in-place)
    correctionFilter->SetImage(diffImages);
    correctionFilter->CorrectDirections(transM.GetVnlMatrix());
    img = diffImages;
  }
}
예제 #7
0
/**
 * Denoises DWI using the Nonlocal - Means algorithm
 */
int main(int argc, char* argv[])
{
  mitkCommandLineParser parser;

  parser.setTitle("DWI Denoising");
  parser.setCategory("Preprocessing Tools");
  parser.setContributor("MIC");
  parser.setDescription("Denoising for diffusion weighted images using a non-local means algorithm.");

  parser.setArgumentPrefix("--", "-");
  parser.addArgument("input", "i", mitkCommandLineParser::InputFile, "Input:", "input image (DWI)", us::Any(), false);
  parser.addArgument("variance", "v", mitkCommandLineParser::Float, "Variance:", "noise variance", us::Any(), false);

  parser.addArgument("mask", "m", mitkCommandLineParser::InputFile, "Mask:", "brainmask for input image", us::Any(), true);
  parser.addArgument("search", "s", mitkCommandLineParser::Int, "Search radius:", "search radius", us::Any(), true);
  parser.addArgument("compare", "c", mitkCommandLineParser::Int, "Comparison radius:", "comparison radius", us::Any(), true);
  parser.addArgument("joint", "j", mitkCommandLineParser::Bool, "Joint information:", "use joint information");
  parser.addArgument("rician", "r", mitkCommandLineParser::Bool, "Rician adaption:", "use rician adaption");

  parser.changeParameterGroup("Output", "Output of this miniapp");

  parser.addArgument("output", "o", mitkCommandLineParser::OutputFile, "Output:", "output image (DWI)", us::Any(), false);

  map<string, us::Any> parsedArgs = parser.parseArguments(argc, argv);
  if (parsedArgs.size()==0)
      return EXIT_FAILURE;

  string inFileName = us::any_cast<string>(parsedArgs["input"]);
  double variance = static_cast<double>(us::any_cast<float>(parsedArgs["variance"]));
  string maskName;
  if (parsedArgs.count("mask"))
    maskName = us::any_cast<string>(parsedArgs["mask"]);
  string outFileName = us::any_cast<string>(parsedArgs["output"]);
//  boost::algorithm::erase_all(outFileName, ".dwi");
  int search = 4;
  if (parsedArgs.count("search"))
    search = us::any_cast<int>(parsedArgs["search"]);
  int compare = 1;
  if (parsedArgs.count("compare"))
    compare = us::any_cast<int>(parsedArgs["compare"]);
  bool joint = false;
  if (parsedArgs.count("joint"))
    joint = true;
  bool rician = false;
  if (parsedArgs.count("rician"))
    rician = true;

  try
  {
      mitk::PreferenceListReaderOptionsFunctor functor = mitk::PreferenceListReaderOptionsFunctor({"Diffusion Weighted Images"}, {});
      DiffusionImageType::Pointer dwi = dynamic_cast<mitk::Image*>(mitk::IOUtil::LoadImage(inFileName, &functor).GetPointer());

      mitk::DiffusionPropertyHelper::ImageType::Pointer itkVectorImagePointer = mitk::DiffusionPropertyHelper::ImageType::New();
      mitk::CastToItkImage(dwi, itkVectorImagePointer);

      itk::NonLocalMeansDenoisingFilter<short>::Pointer filter = itk::NonLocalMeansDenoisingFilter<short>::New();
      filter->SetNumberOfThreads(12);
      filter->SetInputImage( itkVectorImagePointer );

      if (!maskName.empty())
      {
        mitk::Image::Pointer mask = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(maskName)[0].GetPointer());
        ImageType::Pointer itkMask = ImageType::New();
        mitk::CastToItkImage(mask, itkMask);
        filter->SetInputMask(itkMask);
      }

      filter->SetUseJointInformation(joint);
      filter->SetUseRicianAdaption(rician);
      filter->SetSearchRadius(search);
      filter->SetComparisonRadius(compare);
      filter->SetVariance(variance);
      filter->Update();

      DiffusionImageType::Pointer output = mitk::GrabItkImageMemory( filter->GetOutput() );
      output->GetPropertyList()->ReplaceProperty( mitk::DiffusionPropertyHelper::REFERENCEBVALUEPROPERTYNAME.c_str(), mitk::FloatProperty::New( mitk::DiffusionPropertyHelper::GetReferenceBValue(dwi) ) );
      output->GetPropertyList()->ReplaceProperty( mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str(), mitk::GradientDirectionsProperty::New( mitk::DiffusionPropertyHelper::GetGradientContainer(dwi) ) );
      mitk::DiffusionPropertyHelper propertyHelper( output );
      propertyHelper.InitializeImage();

//      std::stringstream name;
//      name << outFileName << "_NLM_" << search << "-" << compare << "-" << variance << ".dwi";

      mitk::IOUtil::Save(output, outFileName.c_str());
  }
  catch (itk::ExceptionObject e)
  {
      std::cout << e;
      return EXIT_FAILURE;
  }
  catch (std::exception e)
  {
      std::cout << e.what();
      return EXIT_FAILURE;
  }
  catch (...)
  {
      std::cout << "ERROR!?!";
      return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}
예제 #8
0
void QmitkDenoisingView::StartDenoising()
{
  if (!m_ThreadIsRunning)
  {
    if (m_ImageNode.IsNotNull())
    {
      m_LastProgressCount = 0;
      switch (m_SelectedFilter)
      {
        case NOFILTERSELECTED:
        {
          break;
        }
        case NLM:
        {
          // initialize NLM
          m_InputImage = dynamic_cast<DiffusionImageType*> (m_ImageNode->GetData());
          m_NonLocalMeansFilter = NonLocalMeansDenoisingFilterType::New();

          if (m_BrainMaskNode.IsNotNull())
          {
            // use brainmask if set
            m_ImageMask = dynamic_cast<mitk::Image*>(m_BrainMaskNode->GetData());
            itk::Image<DiffusionPixelType, 3>::Pointer itkMask;
            mitk::CastToItkImage(m_ImageMask, itkMask);
            m_NonLocalMeansFilter->SetInputMask(itkMask);

            itk::ImageRegionIterator< itk::Image<DiffusionPixelType, 3> > mit(itkMask, itkMask->GetLargestPossibleRegion());
            mit.GoToBegin();
            itk::Image<DiffusionPixelType, 3>::IndexType minIndex;
            itk::Image<DiffusionPixelType, 3>::IndexType maxIndex;
            minIndex.Fill(10000);
            maxIndex.Fill(0);
            while (!mit.IsAtEnd())
            {
              if (mit.Get())
              {
                // calculation of the start & end index of the smallest masked region
                minIndex[0] = minIndex[0] < mit.GetIndex()[0] ? minIndex[0] : mit.GetIndex()[0];
                minIndex[1] = minIndex[1] < mit.GetIndex()[1] ? minIndex[1] : mit.GetIndex()[1];
                minIndex[2] = minIndex[2] < mit.GetIndex()[2] ? minIndex[2] : mit.GetIndex()[2];

                maxIndex[0] = maxIndex[0] > mit.GetIndex()[0] ? maxIndex[0] : mit.GetIndex()[0];
                maxIndex[1] = maxIndex[1] > mit.GetIndex()[1] ? maxIndex[1] : mit.GetIndex()[1];
                maxIndex[2] = maxIndex[2] > mit.GetIndex()[2] ? maxIndex[2] : mit.GetIndex()[2];
              }
              ++mit;
            }
            itk::Image<DiffusionPixelType, 3>::SizeType size;
            size[0] = maxIndex[0] - minIndex[0] + 1;
            size[1] = maxIndex[1] - minIndex[1] + 1;
            size[2] = maxIndex[2] - minIndex[2] + 1;

            m_MaxProgressCount = size[0] * size[1] * size[2];
          }
          else
          {
            // initialize the progressbar
            m_MaxProgressCount = m_InputImage->GetDimension(0) * m_InputImage->GetDimension(1) * m_InputImage->GetDimension(2);
          }


          mitk::ProgressBar::GetInstance()->AddStepsToDo(m_MaxProgressCount);


          m_NonLocalMeansFilter->SetInputImage(m_InputImage->GetVectorImage());
          m_NonLocalMeansFilter->SetUseRicianAdaption(m_Controls->m_RicianCheckbox->isChecked());
          m_NonLocalMeansFilter->SetUseJointInformation(m_Controls->m_JointInformationCheckbox->isChecked());
          m_NonLocalMeansFilter->SetSearchRadius(m_Controls->m_SpinBoxParameter1->value());
          m_NonLocalMeansFilter->SetComparisonRadius(m_Controls->m_SpinBoxParameter2->value());
          m_NonLocalMeansFilter->SetVariance(m_Controls->m_DoubleSpinBoxParameter3->value());





          // start denoising in detached thread
          m_DenoisingThread.start(QThread::HighestPriority);

          break;
        }
        case GAUSS:
        {
          // initialize GAUSS and run
          m_InputImage = dynamic_cast<DiffusionImageType*> (m_ImageNode->GetData());

          ExtractFilterType::Pointer extractor = ExtractFilterType::New();
          extractor->SetInput(m_InputImage->GetVectorImage());
          ComposeFilterType::Pointer composer = ComposeFilterType::New();

          for (unsigned int i = 0; i < m_InputImage->GetVectorImage()->GetVectorLength(); ++i)
          {
            extractor->SetIndex(i);
            extractor->Update();

            m_GaussianFilter = GaussianFilterType::New();
            m_GaussianFilter->SetVariance(m_Controls->m_SpinBoxParameter1->value());

            if (m_BrainMaskNode.IsNotNull())
            {
              m_ImageMask = dynamic_cast<mitk::Image*>(m_BrainMaskNode->GetData());
              itk::Image<DiffusionPixelType, 3>::Pointer itkMask = itk::Image<DiffusionPixelType, 3>::New();
              mitk::CastToItkImage(m_ImageMask, itkMask);

              itk::MaskImageFilter<itk::Image<DiffusionPixelType, 3> , itk::Image<DiffusionPixelType, 3> >::Pointer maskImageFilter = itk::MaskImageFilter<itk::Image<DiffusionPixelType, 3> , itk::Image<DiffusionPixelType, 3> >::New();
              maskImageFilter->SetInput(extractor->GetOutput());
              maskImageFilter->SetMaskImage(itkMask);
              maskImageFilter->Update();
              m_GaussianFilter->SetInput(maskImageFilter->GetOutput());
            }
            else
            {
              m_GaussianFilter->SetInput(extractor->GetOutput());
            }
            m_GaussianFilter->Update();

            composer->SetInput(i, m_GaussianFilter->GetOutput());
          }
          composer->Update();


          DiffusionImageType::Pointer image = DiffusionImageType::New();
          image->SetVectorImage(composer->GetOutput());
          image->SetReferenceBValue(m_InputImage->GetReferenceBValue());
          image->SetDirections(m_InputImage->GetDirections());
          image->InitializeFromVectorImage();
          mitk::DataNode::Pointer imageNode = mitk::DataNode::New();
          imageNode->SetData( image );
          QString name = m_ImageNode->GetName().c_str();

          imageNode->SetName((name+"_gauss_"+QString::number(m_Controls->m_SpinBoxParameter1->value())).toStdString().c_str());
          GetDefaultDataStorage()->Add(imageNode);

          break;
        }
      }
    }
  }

  else
  {
    m_NonLocalMeansFilter->AbortGenerateDataOn();
    m_CompletedCalculation = false;
  }
}