Difference between revisions of "NAMIC Wiki:DTI:ITK"

From NAMIC Wiki
Jump to: navigation, search
m (Update from Wiki)
m (Update from Wiki)
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
Header for proposed itkSymmetricTensor.
+
This page host a discussion on the implementation details of a Tensor class.
  
<nowiki>
+
== Tensors and Traits ==
/*=========================================================================
+
 
+
Torsten Rohlfing for SRI International Neuroscience Program proposed the following for ITK tensor processing:
  Program:   Insight Segmentation & Registration Toolkit
+
 
  Module:    $RCSfile: itkSymmetricTensor.txx,v $
+
* Separate the operations which depend on the tensor size from those that do not.
  Language:  C++
+
** The former are in tensor traits, the latter are in tensor class.
  Date:      $Date: 2004/04/15 22:37:33 $
+
* Filter classes operate on different tensor pixel type images (by templating).
  Version:  $Revision: 1.10 $
+
** The tensor classes can be more or less specialized. In particular, the filters will be able to support more general tensor classes that may be implemented later, as long as they provide the necessary interface functions for any given filter.
+
* [[NAMIC_Wiki:DTI:ITK-SymmetricTensorPixelType:Header|itkSymmetricTensor.h]]
  Copyright (c) Insight Software Consortium. All rights reserved.
+
** Contains functions that do not benefit from knowledge of the tensor size, e.g., GetVnlMatrix()
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
+
* [[NAMIC_Wiki:DTI:ITK-SymmetricTensorTraits::Header|itkSymmetricTensorTraits.h]]
+
** Operations that depend on the tensor size, e.g., eigenvalue computation.
      This software is distributed WITHOUT ANY WARRANTY; without even
+
* itkTensorToFractionalAnisotropyImageFilter.{h,txx}
      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+
** Example filter that operates on tensor data.
      PURPOSE.  See the above copyright notices for more information.
+
** Operates on any tensor class that implements T::ComputeEigenvalues()
+
* DiffusionTensorToFractionalAnisotropy.cxx
=========================================================================*/
+
** Example application. Reads a tensor image from a raw data file, computes the FA image, and writes the result.
+
 
#ifndef __itkSymmetricTensor_h
+
=== A First version of the SymmetricSecondRankTensor class committed to ITK ===
#define __itkSymmetricTensor_h
+
 
+
Given that Tensor can have any rank, from zero (scalar), one (vector), two (matrices) to N. It seemed appropriate to specify that this particular class was representing a symmetric tensor of second rank.
#include "itkFixedArray.h"
+
 
#include "itkSymmetricTensorTraits.h"
+
The class has been committed into ITK (May 2 2005) and it is expected to evolve in the CVS repository.
#include "vnl/vnl_matrix.h"
+
 
+
=== A first version of SymmetricEigenAnalysis class committed to ITK ===
namespace itk
+
 
{
+
Serves as a thread safe alternative to vnl_symmetric_eigensystem, which calls netlib C routines is not thread safe. Please use this class in any multi-threaded filters.
/** \class itkSymmetricTensor
+
 
  *
+
=== A Hessian filter uses the Symmetric second rank tensor class ===
  */
+
 
template
+
A filter for computing the Hessian of an image was also committed to ITK. This filter illustrates the first use of the SymmetricSecondRankTensor class as pixel type of an image.
  < typename TRealType = float, unsigned int VTensorDimension = 3,
 
  typename TTensorTraits = SymmetricTensorTraits<TRealType,VTensorDimension>
 
>
 
class ITK_EXPORT SymmetricTensor :
 
    public FixedArray< TRealType, VTensorDimension*(VTensorDimension+1)/2 >
 
{
 
  public:
 
  /// The compact linear vector dimension of the tensor.
 
  static const unsigned int NVectorDimension =
 
    VTensorDimension*(VTensorDimension+1)/2;
 
 
  /** Standard class typedefs. */
 
  typedef SymmetricTensor Self;
 
  typedef SmartPointer<Self> Pointer;
 
  typedef SmartPointer<const Self>  ConstPointer;
 
  typedef FixedArray< TRealType, NVectorDimension > Superclass;
 
 
  /** Run-time type information (and related methods) */
 
  itkTypeMacro(SymmetricTensor, FixedArray);
 
 
  /** Define the data type and the vector of data type used in calculations.
 
  */
 
  typedef TRealType RealType;
 
 
  typedef vnl_matrix_fixed<TRealType,VTensorDimension,VTensorDimension> VnlMatrixType;
 
  /* Return vnl_matrix object. We do this here, since it's always the same,
 
    * regardless of tensor size.
 
    */
 
  VnlMatrixType GetVnlMatrix() const;
 
 
  /** Compute eigenvalues. This is done in the traits class, since the best
 
    * implementation depends on the actual tensor size.
 
    */
 
  void ComputeEigenvalues( double (&lambda)[VTensorDimension] ) const
 
    {
 
    TTensorTraits::ComputeEigenvalues( *this, lambda );
 
    }
 
 
  SymmetricTensor() : Superclass() {}
 
  SymmetricTensor(const Self& other) : Superclass( other ) {}
 
  void operator=(const Self& other) { this->Superclass::operator=( other ); }
 
 
  /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  SymmetricTensor(const Vector<TRealType,NVectorDimension>& other) :
 
    Superclass( other ) {}
 
 
  /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  typedef TRealType ComponentType;
 
 
  /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  static int GetNumberOfComponents()
 
    { return VTensorDimension*(VTensorDimension+1)/2;}
 
 
  /** This is part of a hack that allows reading a raw vector field using
 
    * itkRawImageIO and subsequently casting to itkSymmetricTensor
 
    * using itkCastImageFilter.
 
    */
 
  void SetNthComponent(int c, const ComponentType& v)
 
  {  this->operator[](c) = v; }
 
 
protected:
 
  void PrintSelf(std::ostream& os, Indent indent) const;
 
};
 
 
} // end namespace itk
 
 
#ifndef ITK_MANUAL_INSTANTIATION
 
#include "itkSymmetricTensor.txx"
 
#endif
 
 
#endif
 
 
</nowiki>
 

Latest revision as of 14:06, 18 December 2006

Home < NAMIC Wiki:DTI:ITK

This page host a discussion on the implementation details of a Tensor class.

Tensors and Traits

Torsten Rohlfing for SRI International Neuroscience Program proposed the following for ITK tensor processing:

  • Separate the operations which depend on the tensor size from those that do not.
    • The former are in tensor traits, the latter are in tensor class.
  • Filter classes operate on different tensor pixel type images (by templating).
    • The tensor classes can be more or less specialized. In particular, the filters will be able to support more general tensor classes that may be implemented later, as long as they provide the necessary interface functions for any given filter.
  • itkSymmetricTensor.h
    • Contains functions that do not benefit from knowledge of the tensor size, e.g., GetVnlMatrix()
  • itkSymmetricTensorTraits.h
    • Operations that depend on the tensor size, e.g., eigenvalue computation.
  • itkTensorToFractionalAnisotropyImageFilter.{h,txx}
    • Example filter that operates on tensor data.
    • Operates on any tensor class that implements T::ComputeEigenvalues()
  • DiffusionTensorToFractionalAnisotropy.cxx
    • Example application. Reads a tensor image from a raw data file, computes the FA image, and writes the result.

A First version of the SymmetricSecondRankTensor class committed to ITK

Given that Tensor can have any rank, from zero (scalar), one (vector), two (matrices) to N. It seemed appropriate to specify that this particular class was representing a symmetric tensor of second rank.

The class has been committed into ITK (May 2 2005) and it is expected to evolve in the CVS repository.

A first version of SymmetricEigenAnalysis class committed to ITK

Serves as a thread safe alternative to vnl_symmetric_eigensystem, which calls netlib C routines is not thread safe. Please use this class in any multi-threaded filters.

A Hessian filter uses the Symmetric second rank tensor class

A filter for computing the Hessian of an image was also committed to ITK. This filter illustrates the first use of the SymmetricSecondRankTensor class as pixel type of an image.