void mitk::DiffusionImageCorrectionFilter
::CorrectDirections( const TransformsVectorType& transformations)
{
  if( m_SourceImage.IsNull() )
  {
    mitkThrow() << " No diffusion image given! ";
  }

  DPH::GradientDirectionsContainerType::Pointer directions = DPH::GetGradientContainer(m_SourceImage);
  DPH::GradientDirectionsContainerType::Pointer corrected_directions = DPH::GradientDirectionsContainerType::New();

  mitk::BValueMapProperty::BValueMap bval_map = DPH::GetBValueMap(m_SourceImage);
  size_t first_unweighted_index = bval_map.begin()->second.front();

  unsigned int transformed = 0;
  for(size_t i=0; i< directions->Size(); i++ )
  {

    // skip b-zero images
    if(i==first_unweighted_index)
    {
      corrected_directions->push_back(directions->ElementAt(i));
      continue;
    }

    auto corrected = GetRotationComponent(transformations.at(transformed)) * directions->ElementAt(i);
    // store the corrected direction
    corrected_directions->push_back(corrected);
    transformed++;
  }

  // replace the old directions with the corrected ones
  DPH::SetGradientContainer(m_SourceImage, corrected_directions);
}
void mitk::DiffusionImageCorrectionFilter
::CorrectDirections( const TransformsVectorType& transformations)
{
  if( m_SourceImage.IsNull() )
  {
    mitkThrow() << " No diffusion image given! ";
  }

  GradientDirectionContainerPointerType directions = static_cast<mitk::GradientDirectionsProperty*>( m_SourceImage->GetProperty(mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str()).GetPointer() )->GetGradientDirectionsContainer();
  GradientDirectionContainerPointerType corrected_directions =
      GradientDirectionContainerType::New();

  unsigned int transformed = 0;
  for(size_t i=0; i< directions->Size(); i++ )
  {

    // skip b-zero images
    if( directions->ElementAt(i).one_norm() <= 0.0 )
    {
      corrected_directions->push_back( directions->ElementAt(i) );
      continue;
    }

    GradientDirectionType corrected = GetRotationComponent(
                                          transformations.at(transformed))
                                        * directions->ElementAt(i);
    // store the corrected direction
    corrected_directions->push_back( corrected );
    transformed++;
  }

  // replace the old directions with the corrected ones
  m_SourceImage->SetProperty( mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str(), mitk::GradientDirectionsProperty::New( corrected_directions ) );

}
void mitk::DiffusionImageCorrectionFilter<TPixelType>
::CorrectDirections( const TransformsVectorType& transformations)
{
  if( m_SourceImage.IsNull() )
  {
    mitkThrow() << " No diffusion image given! ";
  }

  GradientDirectionContainerPointerType directions = m_SourceImage->GetDirections();
  GradientDirectionContainerPointerType corrected_directions =
      GradientDirectionContainerType::New();

  unsigned int transformed = 0;
  for(size_t i=0; i< directions->Size(); i++ )
  {

    // skip b-zero images
    if( directions->ElementAt(i).one_norm() <= 0.0 )
    {
      corrected_directions->push_back( directions->ElementAt(i) );
      continue;
    }

    GradientDirectionType corrected = GetRotationComponent(
                                          transformations.at(transformed))
                                        * directions->ElementAt(i);
    // store the corrected direction
    corrected_directions->push_back( corrected );
    transformed++;
  }

  // replace the old directions with the corrected ones
  m_SourceImage->SetDirections( corrected_directions );

}