diff --git a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.cpp b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.cpp index f184dac8be..33439010f8 100644 --- a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.cpp +++ b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.cpp @@ -1,132 +1,130 @@ /*=================================================================== 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 __mitkTbssImporter_cpp #define __mitkTbssImporter_cpp #include "mitkTbssImporter.h" -#include -#include -#include "itkNrrdImageIO.h" -#include "mitkImageAccessByItk.h" +//#include +//#include +//#include "itkNrrdImageIO.h" +//#include "mitkImageAccessByItk.h" namespace mitk { mitk::TbssImage::Pointer mitk::TbssImporter::Import() { // read all images with all_*.nii.gz mitk::TbssImage::Pointer tbssImg = mitk::TbssImage::New(); m_Data = DataImageType::New(); mitk::Geometry3D* geo = m_InputVolume->GetGeometry(); mitk::Vector3D spacing = geo->GetSpacing(); mitk::Point3D origin = geo->GetOrigin(); //Size size DataImageType::SizeType dataSize; dataSize[0] = m_InputVolume->GetDimension(0); dataSize[1] = m_InputVolume->GetDimension(1); dataSize[2] = m_InputVolume->GetDimension(2); m_Data->SetRegions(dataSize); // Set spacing DataImageType::SpacingType dataSpacing; dataSpacing[0] = spacing[0]; dataSpacing[1] = spacing[1]; dataSpacing[2] = spacing[2]; m_Data->SetSpacing(dataSpacing); DataImageType::PointType dataOrigin; dataOrigin[0] = origin[0]; dataOrigin[1] = origin[1]; dataOrigin[2] = origin[2]; m_Data->SetOrigin(dataOrigin); //Direction must be set DataImageType::DirectionType dir; const itk::Transform* transform3D = geo->GetParametricTransform(); itk::Transform::ParametersType p = transform3D->GetParameters(); int t=0; for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { dir[i][j] = p[t]; // row-major order (where the column index varies the fastest) t++; } } m_Data->SetDirection(dir); // Set the length to one because otherwise allocate fails. Should be changed when groups/measurements are added m_Data->SetVectorLength(m_InputVolume->GetDimension(3)); m_Data->Allocate(); for(int i=0; i ix; ix[0] = i; ix[1] = j; ix[2] = k; itk::VariableLengthVector pixel = m_Data->GetPixel(ix); for(int z=0; zGetPixelValueByIndex(ix, z); pixel.SetElement(z, value); } m_Data->SetPixel(ix, pixel); } } } -// mitk::CastToTbssImage(m_Data.GetPointer(), tbssImg); - tbssImg->SetGroupInfo(m_Groups); tbssImg->SetMeasurementInfo(m_MeasurementInfo); tbssImg->SetImage(m_Data); tbssImg->InitializeFromVectorImage(); return tbssImg; } } #endif // __mitkTbssImporter_cpp diff --git a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.h b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.h index 4fb4254602..c5b6390ad2 100644 --- a/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.h +++ b/Modules/DiffusionImaging/Quantification/IODataStructures/TbssImages/mitkTbssImporter.h @@ -1,104 +1,96 @@ /*=================================================================== 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 __mitkTbssImporter_h #define __mitkTbssImporter_h #include "mitkCommon.h" #include "mitkFileReader.h" #include "itkImage.h" #include "itkVectorImage.h" -#include "itkImageFileReader.h" + #include "mitkTbssImage.h" #include "QuantificationExports.h" - namespace mitk { - //template - class Quantification_EXPORT TbssImporter : public itk::Object { - public: - // typedef TPixelType PixelType; - typedef itk::VectorImage DataImageType; // type of the 3d vector image containing the skeletonized images - typedef itk::VectorImage VectorImageType; // Datatype of the tbss gradient images - typedef itk::Image FloatImage4DType; - typedef itk::ImageFileReader FileReaderType4D; - typedef itk::ImageFileReader VectorReaderType; +/** + * \brief Converts FSL TBSS data (4D skeleton projection images) to a NRRD image with meta data. + * + * The TBSS pipeline of FSL produces a 4D image containing the 3D skeleton projections of all individuals. + * This class converts the FSL Nifty image to NRRD and adds information about the type of measurement and the study groups. + */ - typedef itk::Image FloatImage3DType; - typedef itk::ImageFileReader FileReaderType3D; + class Quantification_EXPORT TbssImporter : public itk::Object { + public: + // type of the 3d vector image containing the skeletonized images + typedef itk::VectorImage DataImageType; mitkClassMacro( TbssImporter, Object ) itkNewMacro(Self) - - + /* \brief Converts the FSL Nifty to NRRD and adds the meta data */ mitk::TbssImage::Pointer Import(); + + /* \brief Group info is set by providing a vector with pairs of group name and number*/ void SetGroupInfo(std::vector< std::pair > groups) { m_Groups = groups; } - std::vector< std::pair > GetGroupInfo() - { - return m_Groups; - } + /* \brief Used to indicate the type of measurement */ void SetMeasurementInfo(std::string s) { m_MeasurementInfo = s; } - std::string GetMeasurementInfo() - { - return m_MeasurementInfo; - } - + /* \brief Sets the FSL import volume */ void SetImportVolume(mitk::Image::Pointer inputVolume) { m_InputVolume = inputVolume; } protected: TbssImporter(){} virtual ~TbssImporter(){} DataImageType::Pointer m_Data; + std::vector< std::pair > m_Groups; std::string m_MeasurementInfo; - mitk::Image::Pointer m_InputVolume; }; } #endif // __mitkTbssImporter_h