<commit_before>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/
#ifndef _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_
#define _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_

#include "itkImageToImageFilter.h"
#include <itkDiffusionTensor3D.h>
#include <itkVectorImage.h>
#include <vnl/algo/vnl_symmetric_eigensystem.h>

#include <math.h>
#include <mitkDiffusionImage.h>




namespace itk
{

  template <class TDiffusionPixelType, class TTensorPixelType>
  class TensorReconstructionWithEigenvalueCorrectionFilter
    : public ImageToImageFilter< itk::Image< TDiffusionPixelType, 3 >, itk::Image<itk::DiffusionTensor3D<TTensorPixelType>,3> >
  {

  public:


    typedef itk::VectorImage<short, 3>  ImageType;



    typedef TensorReconstructionWithEigenvalueCorrectionFilter                  Self;
    typedef SmartPointer<Self>                          Pointer;
    typedef SmartPointer<const Self>                    ConstPointer;



    typedef ImageToImageFilter< Image< TDiffusionPixelType, 3>,
      Image< DiffusionTensor3D< TTensorPixelType >, 3 > >
      Superclass;

    /** Method for creation through the object factory. */
    itkNewMacro(Self)

    /** Runtime information support. */
    itkTypeMacro(TensorReconstructionWithEigenvalueCorrectionFilter, ImageToImageFilter)

    typedef TDiffusionPixelType                       ReferencePixelType;
    typedef TDiffusionPixelType                       GradientPixelType;
    typedef DiffusionTensor3D< TTensorPixelType >     TensorPixelType;


    /** Reference image data,  This image is aquired in the absence
    * of a diffusion sensitizing field gradient */
    typedef typename Superclass::InputImageType      ReferenceImageType;
    typedef Image< TensorPixelType, 3 >              TensorImageType;
    typedef TensorImageType                          OutputImageType;
    typedef typename Superclass::OutputImageRegionType
      OutputImageRegionType;

    /** Typedef defining one (of the many) gradient images.  */
    typedef Image< GradientPixelType, 3 >            GradientImageType;

    /** An alternative typedef defining one (of the many) gradient images.
    * It will be assumed that the vectorImage has the same dimension as the
    * Reference image and a vector length parameter of \c n (number of
    * gradient directions) */
    typedef VectorImage< GradientPixelType, 3 >      GradientImagesType;
    typedef typename GradientImagesType::PixelType         GradientVectorType;


    /*
    /** Holds the tensor basis coefficients G_k
    typedef vnl_matrix_fixed< double, 6, 6 >         TensorBasisMatrixType;

    typedef vnl_matrix< double >                     CoefficientMatrixType;
    */

    /** Holds each magnetic field gradient used to acquire one DWImage */
    typedef vnl_vector_fixed< double, 3 >            GradientDirectionType;

    /** Container to hold gradient directions of the 'n' DW measurements */
    typedef VectorContainer< unsigned int,
      GradientDirectionType >                  GradientDirectionContainerType;



    /** Another set method to add a gradient directions and its corresponding
    * image. The image here is a VectorImage. The user is expected to pass the
    * gradient directions in a container. The ith element of the container
    * corresponds to the gradient direction of the ith component image the
    * VectorImage.  For the baseline image, a vector of all zeros
    * should be set. */
    void SetGradientImage( GradientDirectionContainerType *,
      const GradientImagesType *image);

    /** Set method to set the reference image. */
    void SetReferenceImage( ReferenceImageType *referenceImage )
    {
      if( m_GradientImageTypeEnumeration == GradientIsInASingleImage)
      {
        itkExceptionMacro( << "Cannot call both methods:"
          << "AddGradientImage and SetGradientImage. Please call only one of them.");
      }

      this->ProcessObject::SetNthInput( 0, referenceImage );

      m_GradientImageTypeEnumeration = GradientIsInManyImages;
    }

    /** Get reference image */
    virtual ReferenceImageType * GetReferenceImage()
    { return ( static_cast< ReferenceImageType *>(this->ProcessObject::GetInput(0)) ); }

    /** Return the gradient direction. idx is 0 based */
    virtual GradientDirectionType GetGradientDirection( unsigned int idx) const
    {
      if( idx >= m_NumberOfGradientDirections )
      {
        itkExceptionMacro( << "Gradient direction " << idx << "does not exist" );
      }
      return m_GradientDirectionContainer->ElementAt( idx+1 );
    }

    itkSetMacro( BValue, TTensorPixelType);
    itkSetMacro( B0Threshold, float);
    itkSetMacro (Flagstatus, int);

    itkGetMacro(PseudoInverse, vnl_matrix<double>);
    itkGetMacro(H, vnl_matrix<double>);
    itkGetMacro(BVec, vnl_vector<double>);
    itkGetMacro(B0Mask, vnl_vector<short>);
    itkGetMacro(Voxdim, vnl_vector<double>);

    mitk::DiffusionImage<short>::Pointer GetOutputDiffusionImage()
    {
      return m_OutputDiffusionImage;
    }

    ImageType::Pointer GetVectorImage()
    {
      return m_VectorImage;
    }

    itk::Image<short, 3>::Pointer GetMask()
    {
      return m_MaskImage;
    }


    //itkGetMacro(OutputDiffusionImage, mitk::DiffusionImage<double>)

    //itkGetMacro( GradientDirectionContainer, GradientDirectionContainerType::Pointer);

  protected:

    TensorReconstructionWithEigenvalueCorrectionFilter();
    ~TensorReconstructionWithEigenvalueCorrectionFilter() {};


    void GenerateData();
<commit_msg>removed unused reference image type and getters/setters<commit_after>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/
#ifndef _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_
#define _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_

#include "itkImageToImageFilter.h"
#include <itkDiffusionTensor3D.h>
#include <itkVectorImage.h>
#include <vnl/algo/vnl_symmetric_eigensystem.h>

#include <math.h>
#include <mitkDiffusionImage.h>




namespace itk
{

  template <class TDiffusionPixelType, class TTensorPixelType>
  class TensorReconstructionWithEigenvalueCorrectionFilter
    : public ImageToImageFilter< itk::Image< TDiffusionPixelType, 3 >, itk::Image<itk::DiffusionTensor3D<TTensorPixelType>,3> >
  {

  public:


    typedef itk::VectorImage<short, 3>  ImageType;



    typedef TensorReconstructionWithEigenvalueCorrectionFilter                  Self;
    typedef SmartPointer<Self>                          Pointer;
    typedef SmartPointer<const Self>                    ConstPointer;



    typedef ImageToImageFilter< Image< TDiffusionPixelType, 3>,
      Image< DiffusionTensor3D< TTensorPixelType >, 3 > >
      Superclass;

    /** Method for creation through the object factory. */
    itkNewMacro(Self)

    /** Runtime information support. */
    itkTypeMacro(TensorReconstructionWithEigenvalueCorrectionFilter, ImageToImageFilter)

    typedef TDiffusionPixelType                       ReferencePixelType;
    typedef TDiffusionPixelType                       GradientPixelType;
    typedef DiffusionTensor3D< TTensorPixelType >     TensorPixelType;



    typedef Image< TensorPixelType, 3 >              TensorImageType;
    typedef TensorImageType                          OutputImageType;
    typedef typename Superclass::OutputImageRegionType
      OutputImageRegionType;

    /** Typedef defining one (of the many) gradient images.  */
    typedef Image< GradientPixelType, 3 >            GradientImageType;

    /** An alternative typedef defining one (of the many) gradient images.
    * It will be assumed that the vectorImage has the same dimension as the
    * Reference image and a vector length parameter of \c n (number of
    * gradient directions) */
    typedef VectorImage< GradientPixelType, 3 >      GradientImagesType;
    typedef typename GradientImagesType::PixelType         GradientVectorType;


    /*
    /** Holds the tensor basis coefficients G_k
    typedef vnl_matrix_fixed< double, 6, 6 >         TensorBasisMatrixType;

    typedef vnl_matrix< double >                     CoefficientMatrixType;
    */

    /** Holds each magnetic field gradient used to acquire one DWImage */
    typedef vnl_vector_fixed< double, 3 >            GradientDirectionType;

    /** Container to hold gradient directions of the 'n' DW measurements */
    typedef VectorContainer< unsigned int,
      GradientDirectionType >                  GradientDirectionContainerType;



    /** Another set method to add a gradient directions and its corresponding
    * image. The image here is a VectorImage. The user is expected to pass the
    * gradient directions in a container. The ith element of the container
    * corresponds to the gradient direction of the ith component image the
    * VectorImage.  For the baseline image, a vector of all zeros
    * should be set. */
    void SetGradientImage( GradientDirectionContainerType *,
      const GradientImagesType *image);



    itkSetMacro( BValue, TTensorPixelType);
    itkSetMacro( B0Threshold, float);
    itkSetMacro (Flagstatus, int);

    itkGetMacro(PseudoInverse, vnl_matrix<double>);
    itkGetMacro(H, vnl_matrix<double>);
    itkGetMacro(BVec, vnl_vector<double>);
    itkGetMacro(B0Mask, vnl_vector<short>);
    itkGetMacro(Voxdim, vnl_vector<double>);

    mitk::DiffusionImage<short>::Pointer GetOutputDiffusionImage()
    {
      return m_OutputDiffusionImage;
    }

    ImageType::Pointer GetVectorImage()
    {
      return m_VectorImage;
    }

    itk::Image<short, 3>::Pointer GetMask()
    {
      return m_MaskImage;
    }


  protected:

    TensorReconstructionWithEigenvalueCorrectionFilter();
    ~TensorReconstructionWithEigenvalueCorrectionFilter() {};


    void GenerateData();

{'fraction_non_alphanumeric': 0.09446896422199268, 'fraction_numerical': 0.0037562212414311204, 'mean_word_length': 3.522292993630573, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3878684', 'n_tokens_mistral': 2920, 'n_tokens_neox': 2737, 'n_words': 799}