diff --git a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageReader.cpp b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageReader.cpp index 3af436fda6..30c45f200a 100644 --- a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageReader.cpp +++ b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageReader.cpp @@ -1,346 +1,369 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkNrrdTbssImageReader_cpp #define __mitkNrrdTbssImageReader_cpp #include "mitkNrrdTbssImageReader.h" #include "itkImageFileReader.h" #include "itkMetaDataObject.h" #include "itkNrrdImageIO.h" #include "itkNiftiImageIO.h" #include #include #include #include "itksys/SystemTools.hxx" namespace mitk { void NrrdTbssImageReader ::GenerateData() { // Since everything is completely read in GenerateOutputInformation() it is stored // in a cache variable. A timestamp is associated. // If the timestamp of the cache variable is newer than the MTime, we only need to // assign the cache variable to the DataObject. // Otherwise, the tree must be read again from the file and OuputInformation must // be updated! if ( ( ! m_OutputCache ) || ( this->GetMTime( ) > m_CacheTime.GetMTime( ) ) ) { this->GenerateOutputInformation(); itkWarningMacro("Cache regenerated!"); } if (!m_OutputCache) { itkWarningMacro("Tree cache is empty!") } int vecsize = m_OutputCache->GetImage()->GetVectorLength(); static_cast(this->GetOutput()) ->SetImage(m_OutputCache->GetImage()); static_cast(this->GetOutput()) ->SetGroupInfo(m_OutputCache->GetGroupInfo()); static_cast(this->GetOutput()) ->SetMetaInfo(m_OutputCache->GetMetaInfo()); static_cast(this->GetOutput()) ->SetIsMeta(m_OutputCache->GetIsMeta()); static_cast(this->GetOutput()) ->InitializeFromVectorImage(); } void NrrdTbssImageReader ::GenerateOutputInformation() { OutputType::Pointer outputForCache = OutputType::New(); if ( m_FileName == "") { throw itk::ImageFileReaderException(__FILE__, __LINE__, "Sorry, the filename to be read is empty!"); } else { try { const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); if ( locale.compare(currLocale)!=0 ) { try { MITK_INFO << " ** Changing locale from " << setlocale(LC_ALL, NULL) << " to '" << locale << "'"; setlocale(LC_ALL, locale.c_str()); } catch(...) { MITK_INFO << "Could not set locale " << locale; } } MITK_INFO << "NrrdTbssImageReader READING IMAGE INFORMATION"; ImageType::Pointer img; std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); ext = itksys::SystemTools::LowerCase(ext); if (ext == ".tbss") { typedef itk::ImageFileReader FileReaderType; FileReaderType::Pointer reader = FileReaderType::New(); reader->SetFileName(this->m_FileName); itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); reader->SetImageIO(io); reader->Update(); img = reader->GetOutput(); MITK_INFO << "NrrdTbssImageReader READING HEADER INFORMATION"; itk::MetaDataDictionary imgMetaDictionary = img->GetMetaDataDictionary(); std::vector imgMetaKeys = imgMetaDictionary.GetKeys(); std::vector::const_iterator itKey = imgMetaKeys.begin(); std::string metaString; //int numberOfGradientImages = 0; std::string measurementInfo; bool isMeta = false; std::vector > metaInfo; std::vector< std::pair > groups; for (; itKey != imgMetaKeys.end(); itKey ++) { itk::ExposeMetaData (imgMetaDictionary, *itKey, metaString); MITK_INFO << *itKey << " ---> " << metaString; if (itKey->find("Group_index") != std::string::npos) { std::vector tokens; this->Tokenize(metaString, tokens, " "); if(tokens.size()==2) { std::cout << tokens.at(0) << " " << tokens.at(1) << std::endl; std::pair< std::string, int > p; p.first = tokens.at(0); std::string s = tokens.at(1); p.second = atoi(tokens.at(1).c_str()); groups.push_back(p); } } else if(itKey->find("Measurement info") != std::string::npos) { measurementInfo = metaString; } else if(itKey->find("meta") != std::string::npos) { if(metaString == "true") { isMeta = true; } } else if(itKey->find("mean fa skeleton mask") != std::string::npos) { std::pair p; p.first = mitk::TbssImage::MEAN_FA_SKELETON_MASK; p.second = atoi(metaString.c_str()); metaInfo.push_back(p); } else if(itKey->find("mean fa skeleton") != std::string::npos) { std::pair p; p.first = mitk::TbssImage::MEAN_FA_SKELETON; p.second = atoi(metaString.c_str()); metaInfo.push_back(p); } + else if(itKey->find("gradient_x") != std::string::npos) + { + std::pair p; + p.first = mitk::TbssImage::GRADIENT_X; + p.second = atoi(metaString.c_str()); + metaInfo.push_back(p); + } + else if(itKey->find("gradient_y") != std::string::npos) + { + std::pair p; + p.first = mitk::TbssImage::GRADIENT_Y; + p.second = atoi(metaString.c_str()); + metaInfo.push_back(p); + } + + else if(itKey->find("gradient_z") != std::string::npos) + { + std::pair p; + p.first = mitk::TbssImage::GRADIENT_Z; + p.second = atoi(metaString.c_str()); + metaInfo.push_back(p); + } + } outputForCache->SetIsMeta(isMeta); outputForCache->SetGroupInfo(groups); outputForCache->SetMeasurementInfo(measurementInfo); outputForCache->SetMetaInfo(metaInfo); } // This call updates the output information of the associated VesselTreeData outputForCache->SetImage(img); // outputForCache->SetB_Value(m_B_Value); //outputForCache->SetDirections(m_DiffusionVectors); // outputForCache->SetOriginalDirections(m_OriginalDiffusionVectors); // outputForCache->SetMeasurementFrame(m_MeasurementFrame); // Since we have already read the tree, we can store it in a cache variable // so that it can be assigned to the DataObject in GenerateData(); m_OutputCache = outputForCache; m_CacheTime.Modified(); try { MITK_INFO << " ** Changing locale back from " << setlocale(LC_ALL, NULL) << " to '" << currLocale << "'"; setlocale(LC_ALL, currLocale.c_str()); } catch(...) { MITK_INFO << "Could not reset locale " << currLocale; } } catch(std::exception& e) { MITK_INFO << "Std::Exception while reading file!!"; MITK_INFO << e.what(); throw itk::ImageFileReaderException(__FILE__, __LINE__, e.what()); } catch(...) { MITK_INFO << "Exception while reading file!!"; throw itk::ImageFileReaderException(__FILE__, __LINE__, "Sorry, an error occurred while reading the requested vessel tree file!"); } } } const char* NrrdTbssImageReader ::GetFileName() const { return m_FileName.c_str(); } void NrrdTbssImageReader ::SetFileName(const char* aFileName) { m_FileName = aFileName; } const char* NrrdTbssImageReader ::GetFilePrefix() const { return m_FilePrefix.c_str(); } void NrrdTbssImageReader ::SetFilePrefix(const char* aFilePrefix) { m_FilePrefix = aFilePrefix; } const char* NrrdTbssImageReader ::GetFilePattern() const { return m_FilePattern.c_str(); } void NrrdTbssImageReader ::SetFilePattern(const char* aFilePattern) { m_FilePattern = aFilePattern; } bool NrrdTbssImageReader ::CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern) { // First check the extension if( filename == "" ) return false; // check if image is serie if( filePattern != "" && filePrefix != "" ) return false; std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); ext = itksys::SystemTools::LowerCase(ext); if (ext == ".tbss") { itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); typedef itk::ImageFileReader FileReaderType; FileReaderType::Pointer reader = FileReaderType::New(); reader->SetImageIO(io); reader->SetFileName(filename); try { reader->Update(); } catch(itk::ExceptionObject e) { MITK_INFO << e.GetDescription(); return false; } /* typename ImageType::Pointer img = reader->GetOutput(); itk::MetaDataDictionary imgMetaDictionary = img->GetMetaDataDictionary(); std::vector imgMetaKeys = imgMetaDictionary.GetKeys(); std::vector::const_iterator itKey = imgMetaKeys.begin(); std::string metaString; for (; itKey != imgMetaKeys.end(); itKey ++) { itk::ExposeMetaData (imgMetaDictionary, *itKey, metaString); if (itKey->find("tbss") != std::string::npos) { if (metaString.find("ROI") != std::string::npos) { return true; } } } } */ // return false; return true; } return false; } } //namespace MITK #endif diff --git a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageWriter.cpp b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageWriter.cpp index 1d96fab600..3ed26ea4a7 100644 --- a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageWriter.cpp +++ b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkNrrdTbssImageWriter.cpp @@ -1,192 +1,204 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-12-10 18:05:13 +0100 (Mi, 10 Dez 2008) $ Version: $Revision: 15922 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkNrrdTbssImageWriter__cpp #define __mitkNrrdTbssImageWriter__cpp #include "mitkNrrdTbssImageWriter.h" #include "itkMetaDataDictionary.h" #include "itkMetaDataObject.h" #include "itkNrrdImageIO.h" //#include "itkNiftiImageIO.h" #include "itkImageFileWriter.h" #include "itksys/SystemTools.hxx" #include "boost/lexical_cast.hpp" #include #include mitk::NrrdTbssImageWriter::NrrdTbssImageWriter() : m_FileName(""), m_FilePrefix(""), m_FilePattern(""), m_Success(false) { this->SetNumberOfRequiredInputs( 1 ); } mitk::NrrdTbssImageWriter::~NrrdTbssImageWriter() {} void mitk::NrrdTbssImageWriter::GenerateData() { m_Success = false; InputType* input = this->GetInput(); if (input == NULL) { itkWarningMacro(<<"Sorry, input to NrrdTbssImageWriter is NULL!"); return; } if ( m_FileName == "" ) { itkWarningMacro( << "Sorry, filename has not been set!" ); return ; } itk::VectorImage::Pointer img = input->GetImage(); std::string key; std::string val; /* For the case of a tbss image containing data of the patients: Save info about the groups and the type of measurement */ if(!input->GetIsMeta()) { key = "meta"; val = "false"; itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(),key,val); std::vector< std::pair > groups = input->GetGroupInfo(); std::vector< std::pair >::iterator it = groups.begin(); int i=0; while(it != groups.end()) { std::pair p = *it; key = "Group_index_" + boost::lexical_cast(i); val = " " + p.first + " " + boost::lexical_cast(p.second); //sprintf( keybuffer, "Group_index_%04d", std::string(i) ); // sprintf( valbuffer, "%1d %1d", p.first, p.second); //std::cout << valbuffer << std::endl; //itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(),std::string(keybuffer),std::string(valbuffer)); itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(),key,val); it++; ++i; } key = "Measurement info"; val = input->GetMeasurementInfo(); itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(),key,val); } /* If we are dealing with metadata we need to know what index of the vector corresponds to what image. Metadata are the images involved in the algorithms of tbss, like the mean FA Skeleton. */ else { key = "meta"; val = "true"; itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(),key,val); std::vector< std::pair > metaInfo = input->GetMetaInfo(); std::vector< std::pair >::iterator it = metaInfo.begin(); while(it != metaInfo.end()) { std::pair p = *it; key = RetrieveString(p.first); val = " " + boost::lexical_cast(p.second); itk::EncapsulateMetaData< std::string >(input->GetImage()->GetMetaDataDictionary(),key,val); it++; } } typedef itk::VectorImage ImageType; itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); io->SetFileType( itk::ImageIOBase::Binary ); io->UseCompressionOn(); typedef itk::ImageFileWriter WriterType; WriterType::Pointer nrrdWriter = WriterType::New(); nrrdWriter->UseInputMetaDataDictionaryOn(); nrrdWriter->SetInput( img ); nrrdWriter->SetImageIO(io); nrrdWriter->SetFileName(m_FileName); nrrdWriter->UseCompressionOn(); nrrdWriter->SetImageIO(io); try { nrrdWriter->Update(); } catch (itk::ExceptionObject e) { std::cout << e << std::endl; } m_Success = true; } std::string mitk::NrrdTbssImageWriter::RetrieveString(mitk::TbssImage::MetaDataFunction meta) { if(meta == mitk::TbssImage::MEAN_FA_SKELETON) { return "mean fa skeleton"; } else if(meta == mitk::TbssImage::MEAN_FA_SKELETON_MASK) { return "mean fa skeleton mask"; } + else if(meta == mitk::TbssImage::GRADIENT_X) + { + return "gradient_x"; + } + else if(meta == mitk::TbssImage::GRADIENT_Y) + { + return "gradient_y"; + } + else if(meta == mitk::TbssImage::GRADIENT_Z) + { + return "gradient_z"; + } return ""; } void mitk::NrrdTbssImageWriter::SetInput( InputType* tbssVol ) { this->ProcessObject::SetNthInput( 0, tbssVol ); } mitk::TbssImage* mitk::NrrdTbssImageWriter::GetInput() { if ( this->GetNumberOfInputs() < 1 ) { return NULL; } else { return dynamic_cast ( this->ProcessObject::GetInput( 0 ) ); } } std::vector mitk::NrrdTbssImageWriter::GetPossibleFileExtensions() { std::vector possibleFileExtensions; possibleFileExtensions.push_back(".tbss"); return possibleFileExtensions; } #endif //__mitkNrrdTbssImageWriter__cpp diff --git a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.cpp b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.cpp index 7555640c18..79b0dad0f6 100644 --- a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.cpp +++ b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.cpp @@ -1,264 +1,337 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkTbssImporter_cpp #define __mitkTbssImporter_cpp #include "mitkTbssImporter.h" #include #include - +#include "itkNrrdImageIO.h" namespace mitk { mitk::TbssImporter::TbssImporter() { } mitk::TbssImporter::TbssImporter(std::string path) : m_File(path) { } mitk::TbssImage::Pointer mitk::TbssImporter::Import() { // read all images with all_*.nii.gz mitk::TbssImage::Pointer tbssImg = mitk::TbssImage::New(); FileReaderType4D::Pointer reader = FileReaderType4D::New(); reader->SetFileName(m_File); reader->Update(); FloatImage4DType::Pointer img = FloatImage4DType::New(); img = reader->GetOutput(); m_Data = DataImageType::New(); FloatImage4DType::SizeType size = img->GetLargestPossibleRegion().GetSize(); FloatImage4DType::SpacingType spacing = img->GetSpacing(); DataImageType::SizeType dataSize; dataSize[0] = size[0]; dataSize[1] = size[1]; dataSize[2] = size[2]; m_Data->SetRegions(dataSize); DataImageType::SpacingType dataSpacing; dataSpacing[0] = spacing[0]; dataSpacing[1] = spacing[1]; dataSpacing[2] = spacing[2]; m_Data->SetSpacing(dataSpacing); FloatImage4DType::PointType origin = img->GetOrigin(); DataImageType::PointType dataOrigin; dataOrigin[0] = origin[0]; dataOrigin[1] = origin[1]; dataOrigin[2] = origin[2]; m_Data->SetOrigin(dataOrigin); FloatImage4DType::DirectionType dir = img->GetDirection(); DataImageType::DirectionType dataDir; for(int i=0; i<=2; i++) { for(int j=0; j<=2; j++) { dataDir[i][j] = dir[i][j]; } } m_Data->SetDirection(dataDir); // Set the length to one because otherwise allocate fails. Should be changed when groups/measurements are added m_Data->SetVectorLength(size[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); int vecSize = pixel.Size(); for(int z=0; z ix4; ix4[0] = i; ix4[1] = j; ix4[2] = k; ix4[3] = z; float value = img->GetPixel(ix4); 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; } mitk::TbssImage::Pointer mitk::TbssImporter::ImportMeta() { mitk::TbssImage::Pointer tbssImg = mitk::TbssImage::New(); m_Data = DataImageType::New(); std::vector< std::pair > metaInfo; // Gradient images are vector images, so they will add more dimensions to the vector - int extradims=0; + int vecLength = m_MetaFiles.size(); + //Check if there is a gradient image - for(int i=0; i < (m_MetaFiles.size() + extradims); i++) + for(int i=0; i < m_MetaFiles.size(); i++) + { + std::pair p = m_MetaFiles.at(i); + if(RetrieveTbssFunction(p.first) == mitk::TbssImage::GRADIENT_X) + { + vecLength += 2; + } + } + + + + for(int i=0; i < m_MetaFiles.size(); i++) { std::pair p = m_MetaFiles.at(i); std::string function = p.first; std::string file = p.second; // Add to metainfo to give the tbss image a function-index pair std::pair pair; pair.first = RetrieveTbssFunction(function); pair.second = i; + if(pair.first == mitk::TbssImage::GRADIENT_X) + { + metaInfo.push_back(std::pair(mitk::TbssImage::GRADIENT_X, i)); + metaInfo.push_back(std::pair(mitk::TbssImage::GRADIENT_Y, i+1)); + metaInfo.push_back(std::pair(mitk::TbssImage::GRADIENT_Z, i+2)); + + + VectorReaderType::Pointer fileReader = VectorReaderType::New(); + fileReader->SetFileName(file); + itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New(); + fileReader->SetImageIO(io); + fileReader->Update(); - metaInfo.push_back(pair); + VectorImageType::Pointer img = fileReader->GetOutput(); + VectorImageType::SizeType size = img->GetLargestPossibleRegion().GetSize(); - if(pair.first == mitk::TbssImage::GRADIENT_X) - { - extradims +=3; + if(i==0) + { + // First image in serie. Properties should be used to initialize m_Data + m_Data->SetRegions(img->GetLargestPossibleRegion().GetSize()); + m_Data->SetSpacing(img->GetSpacing()); + m_Data->SetOrigin(img->GetOrigin()); + m_Data->SetDirection(img->GetDirection()); + m_Data->SetVectorLength(vecLength); + m_Data->Allocate(); + } + + + /* Dealing with a gradient image, so the size of the vector need to be increased by 2 + since this image contains 3 volumes. Old data should not be deleted*/ + + + + for(int x=0; x ix; + ix[0] = x; + ix[1] = y; + ix[2] = z; + + itk::VariableLengthVector vec = img->GetPixel(ix); + itk::VariableLengthVector pixel = m_Data->GetPixel(ix); + for(int j=0; jSetPixel(ix, pixel); + } + } + } // Read vector image and add to m_Data } else { + + metaInfo.push_back(pair); FileReaderType3D::Pointer fileReader = FileReaderType3D::New(); fileReader->SetFileName(file); fileReader->Update(); FloatImage3DType::Pointer img = fileReader->GetOutput(); FloatImage3DType::SizeType size = img->GetLargestPossibleRegion().GetSize(); if(i==0) { // First image in serie. Properties should be used to initialize m_Data m_Data->SetRegions(img->GetLargestPossibleRegion().GetSize()); m_Data->SetSpacing(img->GetSpacing()); m_Data->SetOrigin(img->GetOrigin()); m_Data->SetDirection(img->GetDirection()); - m_Data->SetVectorLength(m_MetaFiles.size()); + m_Data->SetVectorLength(vecLength); + /* + if(containsGradient) + { + m_Data->SetVectorLength(m_MetaFiles.size()+2); + } + else{ + m_Data->SetVectorLength(m_MetaFiles.size()); + }*/ m_Data->Allocate(); } for(int x=0; x ix; ix[0] = x; ix[1] = y; ix[2] = z; float f = img->GetPixel(ix); itk::VariableLengthVector pixel = m_Data->GetPixel(ix); pixel.SetElement(i, f); m_Data->SetPixel(ix, pixel); } } } } } tbssImg->SetIsMeta(true); tbssImg->SetImage(m_Data); tbssImg->SetMetaInfo(metaInfo); tbssImg->InitializeFromVectorImage(); return tbssImg; } mitk::TbssImage::MetaDataFunction mitk::TbssImporter::RetrieveTbssFunction(std::string s) { if(s == "skeleton mask") { return mitk::TbssImage::MEAN_FA_SKELETON_MASK; } else if(s == "mean fa skeleton") { return mitk::TbssImage::MEAN_FA_SKELETON; } else if(s == "gradient image") { return mitk::TbssImage::GRADIENT_X; } return mitk::TbssImage::MISC; } } #endif // __mitkTbssImporter_cpp diff --git a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.h b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.h index febd596039..e72fd5d49f 100644 --- a/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.h +++ b/Modules/DiffusionImaging/IODataStructures/TbssImages/mitkTbssImporter.h @@ -1,114 +1,115 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-14 19:11:20 +0200 (Tue, 14 Jul 2009) $ Version: $Revision: 18127 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __mitkTbssImporter_h #define __mitkTbssImporter_h #include "mitkCommon.h" #include "mitkFileReader.h" #include "itkImage.h" #include "itkVectorImage.h" #include "itkImageFileReader.h" #include "mitkTbssImage.h" namespace mitk { //template class 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; typedef itk::Image FloatImage3DType; typedef itk::ImageFileReader FileReaderType3D; TbssImporter(); mitkClassMacro( TbssImporter, Object ) itkNewMacro(Self) TbssImporter(std::string path); void SetInputFile(std::string f) { m_File = f; } mitk::TbssImage::Pointer Import(); mitk::TbssImage::Pointer ImportMeta(); void SetGroupInfo(std::vector< std::pair > groups) { m_Groups = groups; } std::vector< std::pair > GetGroupInfo() { return m_Groups; } void SetTbssDatasets(std::vector< std::pair > files) { m_MetaFiles = files; } void SetMeasurementInfo(std::string s) { m_MeasurementInfo = s; } std::string GetMeasurementInfo() { return m_MeasurementInfo; } protected: virtual ~TbssImporter(){} std::string m_File; DataImageType::Pointer m_Data; std::vector< std::pair > m_Groups; std::vector< std::pair > m_MetaFiles; std::string m_MeasurementInfo; mitk::TbssImage::MetaDataFunction RetrieveTbssFunction(std::string s); }; } #include "mitkTbssImporter.cpp" #endif // __mitkTbssImporter_h