this class encapsulates diffusion volumes (vectorimages not yet supported by mitkImage) More...
#include <mitkDiffusionImage.h>


Public Types | |
| typedef TPixelType | PixelType |
| typedef itk::VectorImage < TPixelType, 3 > | ImageType |
| typedef vnl_vector_fixed < double, 3 > | GradientDirectionType |
| typedef itk::VectorContainer < unsigned int, GradientDirectionType > | GradientDirectionContainerType |
| typedef itk::VectorImageToImageAdaptor < TPixelType, 3 > | AdaptorType |
| typedef DiffusionImage | Self |
| typedef Image | Superclass |
| typedef itk::SmartPointer< Self > | Pointer |
| typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
| virtual const char * | GetClassName () const |
| void | AverageRedundantGradients (double precision) |
| GradientDirectionContainerType::Pointer | CalcAveragedDirectionSet (double precision) |
| void | CorrectDKFZBrokenGradientScheme (double precision) |
| ImageType::Pointer | GetVectorImage () |
| void | SetVectorImage (typename ImageType::Pointer image) |
| void | InitializeFromVectorImage () |
| void | SetDisplayIndexForRendering (int displayIndex) |
| GradientDirectionContainerType::Pointer | GetDirections () |
| void | SetDirections (GradientDirectionContainerType::Pointer directions) |
| void | SetDirections (const std::vector< itk::Vector< double, 3 > > directions) |
| virtual float | GetB_Value () |
| virtual void | SetB_Value (float _arg) |
| bool | AreAlike (GradientDirectionType g1, GradientDirectionType g2, double precision) |
Static Public Member Functions | |
| static Pointer | New () |
Protected Member Functions | |
| DiffusionImage () | |
| virtual | ~DiffusionImage () |
Protected Attributes | |
| ImageType::Pointer | m_VectorImage |
| GradientDirectionContainerType::Pointer | m_Directions |
| float | m_B_Value |
| AdaptorType::Pointer | m_VectorImageAdaptor |
| int | m_DisplayIndex |
this class encapsulates diffusion volumes (vectorimages not yet supported by mitkImage)
Definition at line 34 of file mitkDiffusionImage.h.
| typedef itk::VectorImageToImageAdaptor< TPixelType, 3 > mitk::DiffusionImage< TPixelType >::AdaptorType |
Definition at line 45 of file mitkDiffusionImage.h.
| typedef itk::SmartPointer<const Self> mitk::DiffusionImage< TPixelType >::ConstPointer |
Reimplemented from mitk::Image.
Definition at line 47 of file mitkDiffusionImage.h.
| typedef itk::VectorContainer< unsigned int, GradientDirectionType > mitk::DiffusionImage< TPixelType >::GradientDirectionContainerType |
Definition at line 43 of file mitkDiffusionImage.h.
| typedef vnl_vector_fixed< double, 3 > mitk::DiffusionImage< TPixelType >::GradientDirectionType |
Definition at line 41 of file mitkDiffusionImage.h.
| typedef itk::VectorImage<TPixelType, 3> mitk::DiffusionImage< TPixelType >::ImageType |
Definition at line 40 of file mitkDiffusionImage.h.
| typedef TPixelType mitk::DiffusionImage< TPixelType >::PixelType |
Definition at line 38 of file mitkDiffusionImage.h.
| typedef itk::SmartPointer<Self> mitk::DiffusionImage< TPixelType >::Pointer |
Reimplemented from mitk::Image.
Definition at line 47 of file mitkDiffusionImage.h.
| typedef DiffusionImage mitk::DiffusionImage< TPixelType >::Self |
Reimplemented from mitk::Image.
Definition at line 47 of file mitkDiffusionImage.h.
| typedef Image mitk::DiffusionImage< TPixelType >::Superclass |
Reimplemented from mitk::Image.
Definition at line 47 of file mitkDiffusionImage.h.
| mitk::DiffusionImage< TPixelType >::DiffusionImage | ( | ) | [protected] |
Definition at line 23 of file mitkDiffusionImage.txx.
: m_VectorImage(0), m_Directions(0), m_B_Value(-1.0), m_VectorImageAdaptor(0) { }
| mitk::DiffusionImage< TPixelType >::~DiffusionImage | ( | ) | [protected, virtual] |
Definition at line 29 of file mitkDiffusionImage.txx.
{
}
| bool mitk::DiffusionImage< TPixelType >::AreAlike | ( | GradientDirectionType | g1, |
| GradientDirectionType | g2, | ||
| double | precision | ||
| ) |
Definition at line 185 of file mitkDiffusionImage.txx.
{
GradientDirectionType diff = g1 - g2;
return diff.two_norm() < precision;
}
| void mitk::DiffusionImage< TPixelType >::AverageRedundantGradients | ( | double | precision ) |
Definition at line 254 of file mitkDiffusionImage.txx.
Referenced by QmitkPreprocessingView::DoAverageGradients().
{
GradientDirectionContainerType::Pointer newDirs =
CalcAveragedDirectionSet(precision);
// if sizes equal, we do not need to do anything in this function
if(m_Directions->size() == newDirs->size())
return;
GradientDirectionContainerType::Pointer oldDirections = m_Directions;
m_Directions = newDirs;
// new image
typename ImageType::Pointer oldImage = m_VectorImage;
m_VectorImage = ImageType::New();
m_VectorImage->SetSpacing( oldImage->GetSpacing() ); // Set the image spacing
m_VectorImage->SetOrigin( oldImage->GetOrigin() ); // Set the image origin
m_VectorImage->SetDirection( oldImage->GetDirection() ); // Set the image direction
m_VectorImage->SetLargestPossibleRegion( oldImage->GetLargestPossibleRegion() );
m_VectorImage->SetVectorLength( m_Directions->size() );
m_VectorImage->SetBufferedRegion( oldImage->GetLargestPossibleRegion() );
m_VectorImage->Allocate();
// average image data that corresponds to identical directions
itk::ImageRegionIterator< ImageType > newIt(m_VectorImage, m_VectorImage->GetLargestPossibleRegion());
newIt.GoToBegin();
itk::ImageRegionIterator< ImageType > oldIt(oldImage, oldImage->GetLargestPossibleRegion());
oldIt.GoToBegin();
// initial new value of voxel
typename ImageType::PixelType newVec;
newVec.SetSize(m_Directions->size());
newVec.AllocateElements(m_Directions->size());
std::vector<std::vector<int> > dirIndices;
for(GradientDirectionContainerType::ConstIterator gdcitNew = m_Directions->Begin();
gdcitNew != m_Directions->End(); ++gdcitNew)
{
dirIndices.push_back(std::vector<int>(0));
for(GradientDirectionContainerType::ConstIterator gdcitOld = oldDirections->Begin();
gdcitOld != oldDirections->End(); ++gdcitOld)
{
if(AreAlike(gdcitNew.Value(), gdcitOld.Value(), precision))
{
dirIndices[gdcitNew.Index()].push_back(gdcitOld.Index());
}
}
}
int ind1 = -1;
while(!newIt.IsAtEnd())
{
// progress
typename ImageType::IndexType ind = newIt.GetIndex();
ind1 = ind.m_Index[2];
// init new vector with zeros
newVec.Fill(0.0);
// the old voxel value with duplicates
typename ImageType::PixelType oldVec = oldIt.Get();
for(unsigned int i=0; i<dirIndices.size(); i++)
{
// do the averaging
int numavg = dirIndices[i].size();
for(int j=0; j<numavg; j++)
{
newVec[i] += oldVec[dirIndices[i].at(j)];
}
newVec[i] /= numavg;
}
newIt.Set(newVec);
++newIt;
++oldIt;
}
}
| mitk::DiffusionImage< TPixelType >::GradientDirectionContainerType::Pointer mitk::DiffusionImage< TPixelType >::CalcAveragedDirectionSet | ( | double | precision ) |
Definition at line 222 of file mitkDiffusionImage.txx.
{
// save old and construct new direction container
GradientDirectionContainerType::Pointer newDirections = GradientDirectionContainerType::New();
// fill new direction container
for(GradientDirectionContainerType::ConstIterator gdcitOld = m_Directions->Begin();
gdcitOld != m_Directions->End(); ++gdcitOld)
{
// already exists?
bool found = false;
for(GradientDirectionContainerType::ConstIterator gdcitNew = newDirections->Begin();
gdcitNew != newDirections->End(); ++gdcitNew)
{
if(AreAlike(gdcitNew.Value(), gdcitOld.Value(), precision))
{
found = true;
break;
}
}
// if not found, add it to new container
if(!found)
{
newDirections->push_back(gdcitOld.Value());
}
}
return newDirections;
}
| void mitk::DiffusionImage< TPixelType >::CorrectDKFZBrokenGradientScheme | ( | double | precision ) |
Definition at line 194 of file mitkDiffusionImage.txx.
References MITK_INFO.
{
GradientDirectionContainerType::Pointer directionSet = CalcAveragedDirectionSet(precision);
if(directionSet->size() < 7)
{
MITK_INFO << "Too few directions, assuming and correcting DKFZ-bogus sequence details.";
double v [7][3] =
{{ 0, 0, 0 },
{-0.707057, 0, 0.707057 },
{ 0.707057, 0, 0.707057 },
{ 0, 0.707057, 0.707057 },
{ 0, 0.707057, -0.707057 },
{-0.707057, 0.707057, 0 },
{ 0.707057, 0.707057, 0 } };
int i=0;
for(GradientDirectionContainerType::Iterator it = m_Directions->Begin();
it != m_Directions->End(); ++it)
{
it.Value().set(v[i++%7]);
}
}
}
| virtual float mitk::DiffusionImage< TPixelType >::GetB_Value | ( | ) | [virtual] |
| virtual const char* mitk::DiffusionImage< TPixelType >::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::Image.
| GradientDirectionContainerType::Pointer mitk::DiffusionImage< TPixelType >::GetDirections | ( | ) | [inline] |
Definition at line 69 of file mitkDiffusionImage.h.
Referenced by QmitkPreprocessingView::DoBrainMask(), mitk::NrrdDiffusionImageWriter< TPixelType >::GenerateData(), QmitkTensorReconstructionView::ItkTensorReconstruction(), QmitkQBallReconstructionView::NumericalQBallReconstruction(), and QmitkQBallReconstructionView::TemplatedAnalyticalQBallReconstruction().
{ return m_Directions; }
| ImageType::Pointer mitk::DiffusionImage< TPixelType >::GetVectorImage | ( | ) | [inline] |
Definition at line 61 of file mitkDiffusionImage.h.
Referenced by QmitkPreprocessingView::DoBrainMask(), mitk::NrrdDiffusionImageWriter< TPixelType >::GenerateData(), QmitkTensorReconstructionView::ItkTensorReconstruction(), QmitkQBallReconstructionView::NumericalQBallReconstruction(), and QmitkQBallReconstructionView::TemplatedAnalyticalQBallReconstruction().
{ return m_VectorImage; }
| void mitk::DiffusionImage< TPixelType >::InitializeFromVectorImage | ( | ) |
Definition at line 36 of file mitkDiffusionImage.txx.
References MITK_INFO.
Referenced by QmitkTensorReconstructionView::DoTensorsToDWI().
{
if(!m_VectorImage || !m_Directions || m_B_Value==-1.0)
{
MITK_INFO << "DiffusionImage could not be initialized. Set all members first!" << std::endl;
return;
}
// find bzero index
int firstZeroIndex = -1;
for(GradientDirectionContainerType::ConstIterator it = m_Directions->Begin();
it != m_Directions->End(); ++it)
{
firstZeroIndex++;
GradientDirectionType g = it.Value();
if(g[0] == 0 && g[1] == 0 && g[2] == 0 )
break;
}
typedef itk::Image<TPixelType,3> ImgType;
typename ImgType::Pointer img = ImgType::New();
img->SetSpacing( m_VectorImage->GetSpacing() ); // Set the image spacing
img->SetOrigin( m_VectorImage->GetOrigin() ); // Set the image origin
img->SetDirection( m_VectorImage->GetDirection() ); // Set the image direction
img->SetLargestPossibleRegion( m_VectorImage->GetLargestPossibleRegion());
img->SetBufferedRegion( m_VectorImage->GetLargestPossibleRegion() );
img->Allocate();
int vecLength = m_VectorImage->GetVectorLength();
InitializeByItk( img.GetPointer(), 1, vecLength );
//for(int i=0; i<vecLength; i++)
//{
itk::ImageRegionIterator<ImgType> itw (img, img->GetLargestPossibleRegion() );
itw = itw.Begin();
itk::ImageRegionConstIterator<ImageType> itr (m_VectorImage, m_VectorImage->GetLargestPossibleRegion() );
itr = itr.Begin();
while(!itr.IsAtEnd())
{
itw.Set(itr.Get().GetElement(firstZeroIndex));
++itr;
++itw;
}
// init
SetImportVolume(img->GetBufferPointer());//, 0, 0, CopyMemory);
//SetVolume( img->GetBufferPointer(), i );
//}
m_DisplayIndex = firstZeroIndex;
MITK_INFO << "Diffusion-Image successfully initialized.";
}
| static Pointer mitk::DiffusionImage< TPixelType >::New | ( | ) | [static] |
| virtual void mitk::DiffusionImage< TPixelType >::SetB_Value | ( | float | _arg ) | [virtual] |
Referenced by QmitkTensorReconstructionView::DoTensorsToDWI().
| void mitk::DiffusionImage< TPixelType >::SetDirections | ( | GradientDirectionContainerType::Pointer | directions ) | [inline] |
Definition at line 71 of file mitkDiffusionImage.h.
Referenced by QmitkTensorReconstructionView::DoTensorsToDWI().
{ this->m_Directions = directions; }
| void mitk::DiffusionImage< TPixelType >::SetDirections | ( | const std::vector< itk::Vector< double, 3 > > | directions ) | [inline] |
Definition at line 73 of file mitkDiffusionImage.h.
{
m_Directions = GradientDirectionContainerType::New();
for(unsigned int i=0; i<directions.size(); i++)
{
m_Directions->InsertElement( i, directions[i].Get_vnl_vector() );
}
}
| void mitk::DiffusionImage< TPixelType >::SetDisplayIndexForRendering | ( | int | displayIndex ) |
Definition at line 94 of file mitkDiffusionImage.txx.
Referenced by mitk::DiffusionImageMapper< TPixelType >::GenerateData().
{
int index = displayIndex;
int vecLength = m_VectorImage->GetVectorLength();
index = index > vecLength-1 ? vecLength-1 : index;
if( m_DisplayIndex != index )
{
typedef itk::Image<TPixelType,3> ImgType;
typename ImgType::Pointer img = ImgType::New();
CastToItkImage<ImgType>(this, img);
itk::ImageRegionIterator<ImgType> itw (img, img->GetLargestPossibleRegion() );
itw = itw.Begin();
itk::ImageRegionConstIterator<ImageType> itr (m_VectorImage, m_VectorImage->GetLargestPossibleRegion() );
itr = itr.Begin();
while(!itr.IsAtEnd())
{
itw.Set(itr.Get().GetElement(index));
++itr;
++itw;
}
}
m_DisplayIndex = index;
}
| void mitk::DiffusionImage< TPixelType >::SetVectorImage | ( | typename ImageType::Pointer | image ) | [inline] |
Definition at line 63 of file mitkDiffusionImage.h.
Referenced by QmitkTensorReconstructionView::DoTensorsToDWI().
{ this->m_VectorImage = image; }
float mitk::DiffusionImage< TPixelType >::m_B_Value [protected] |
Definition at line 92 of file mitkDiffusionImage.h.
GradientDirectionContainerType::Pointer mitk::DiffusionImage< TPixelType >::m_Directions [protected] |
Definition at line 91 of file mitkDiffusionImage.h.
Referenced by mitk::DiffusionImage< DiffusionImagePixelType >::GetDirections(), and mitk::DiffusionImage< DiffusionImagePixelType >::SetDirections().
int mitk::DiffusionImage< TPixelType >::m_DisplayIndex [protected] |
Definition at line 94 of file mitkDiffusionImage.h.
ImageType::Pointer mitk::DiffusionImage< TPixelType >::m_VectorImage [protected] |
Definition at line 90 of file mitkDiffusionImage.h.
Referenced by mitk::DiffusionImage< DiffusionImagePixelType >::GetVectorImage(), and mitk::DiffusionImage< DiffusionImagePixelType >::SetVectorImage().
AdaptorType::Pointer mitk::DiffusionImage< TPixelType >::m_VectorImageAdaptor [protected] |
Definition at line 93 of file mitkDiffusionImage.h.
1.7.2