diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp index fb892104ad..c0abbdd204 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleReader.cpp @@ -1,427 +1,349 @@ /*========================================================================= 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. =========================================================================*/ #include "mitkFiberBundleReader.h" #include #include #include #include #include #include #include #include #include #include #include #include #include const char* mitk::FiberBundleReader::XML_GEOMETRY = "geometry"; const char* mitk::FiberBundleReader::XML_MATRIX_XX = "xx"; const char* mitk::FiberBundleReader::XML_MATRIX_XY = "xy"; const char* mitk::FiberBundleReader::XML_MATRIX_XZ = "xz"; const char* mitk::FiberBundleReader::XML_MATRIX_YX = "yx"; const char* mitk::FiberBundleReader::XML_MATRIX_YY = "yy"; const char* mitk::FiberBundleReader::XML_MATRIX_YZ = "yz"; const char* mitk::FiberBundleReader::XML_MATRIX_ZX = "zx"; const char* mitk::FiberBundleReader::XML_MATRIX_ZY = "zy"; const char* mitk::FiberBundleReader::XML_MATRIX_ZZ = "zz"; const char* mitk::FiberBundleReader::XML_ORIGIN_X = "origin_x"; const char* mitk::FiberBundleReader::XML_ORIGIN_Y = "origin_y"; const char* mitk::FiberBundleReader::XML_ORIGIN_Z = "origin_z"; const char* mitk::FiberBundleReader::XML_SPACING_X = "spacing_x"; const char* mitk::FiberBundleReader::XML_SPACING_Y = "spacing_y"; const char* mitk::FiberBundleReader::XML_SPACING_Z = "spacing_z"; const char* mitk::FiberBundleReader::XML_SIZE_X = "size_x"; const char* mitk::FiberBundleReader::XML_SIZE_Y = "size_y"; const char* mitk::FiberBundleReader::XML_SIZE_Z = "size_z"; const char* mitk::FiberBundleReader::XML_FIBER_BUNDLE = "fiber_bundle"; const char* mitk::FiberBundleReader::XML_FIBER = "fiber"; const char* mitk::FiberBundleReader::XML_PARTICLE = "particle"; const char* mitk::FiberBundleReader::XML_ID = "id"; const char* mitk::FiberBundleReader::XML_POS_X = "pos_x"; const char* mitk::FiberBundleReader::XML_POS_Y = "pos_y"; const char* mitk::FiberBundleReader::XML_POS_Z = "pos_z"; const char* mitk::FiberBundleReader::XML_NUM_FIBERS = "num_fibers"; const char* mitk::FiberBundleReader::XML_NUM_PARTICLES = "num_particles"; const char* mitk::FiberBundleReader::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; const char* mitk::FiberBundleReader::XML_FILE_VERSION = "file_version" ; const char* mitk::FiberBundleReader::VERSION_STRING = "0.1" ; namespace mitk { void FiberBundleReader ::GenerateData() { MITK_INFO << "Reading fiber bundle"; if ( ( ! m_OutputCache ) ) { Superclass::SetNumberOfRequiredOutputs(0); this->GenerateOutputInformation(); } if (!m_OutputCache) { itkWarningMacro("Tree cache is empty!"); } Superclass::SetNumberOfRequiredOutputs(1); Superclass::SetNthOutput(0, m_OutputCache.GetPointer()); } void FiberBundleReader::GenerateOutputInformation() { m_OutputCache = OutputType::New(); std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); ext = itksys::SystemTools::LowerCase(ext); const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); if ( locale.compare(currLocale)!=0 ) { try { setlocale(LC_ALL, locale.c_str()); } catch(...) { MITK_INFO << "Could not set locale " << locale; } } if ( m_FileName == "") { } - else if (ext == ".fib") + else if (ext == ".fib_deprecated") { try { TiXmlDocument doc( m_FileName ); doc.LoadFile(); TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); pElem = hDoc.FirstChildElement().Element(); // save this for later hRoot = TiXmlHandle(pElem); pElem = hRoot.FirstChildElement(FiberBundleReader::XML_GEOMETRY).Element(); // read geometry mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); // read origin mitk::Point3D origin; double temp = 0; pElem->Attribute(FiberBundleReader::XML_ORIGIN_X, &temp); origin[0] = temp; pElem->Attribute(FiberBundleReader::XML_ORIGIN_Y, &temp); origin[1] = temp; pElem->Attribute(FiberBundleReader::XML_ORIGIN_Z, &temp); origin[2] = temp; geometry->SetOrigin(origin); // read spacing float spacing[3]; pElem->Attribute(FiberBundleReader::XML_SPACING_X, &temp); spacing[0] = temp; pElem->Attribute(FiberBundleReader::XML_SPACING_Y, &temp); spacing[1] = temp; pElem->Attribute(FiberBundleReader::XML_SPACING_Z, &temp); spacing[2] = temp; geometry->SetSpacing(spacing); // read transform vtkMatrix4x4* m = vtkMatrix4x4::New(); pElem->Attribute(FiberBundleReader::XML_MATRIX_XX, &temp); m->SetElement(0,0,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_XY, &temp); m->SetElement(1,0,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_XZ, &temp); m->SetElement(2,0,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_YX, &temp); m->SetElement(0,1,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_YY, &temp); m->SetElement(1,1,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_YZ, &temp); m->SetElement(2,1,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_ZX, &temp); m->SetElement(0,2,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_ZY, &temp); m->SetElement(1,2,temp); pElem->Attribute(FiberBundleReader::XML_MATRIX_ZZ, &temp); m->SetElement(2,2,temp); m->SetElement(0,3,origin[0]); m->SetElement(1,3,origin[1]); m->SetElement(2,3,origin[2]); m->SetElement(3,3,1); geometry->SetIndexToWorldTransformByVtkMatrix(m); // read bounds float bounds[] = {0, 0, 0, 0, 0, 0}; pElem->Attribute(FiberBundleReader::XML_SIZE_X, &temp); bounds[1] = temp; pElem->Attribute(FiberBundleReader::XML_SIZE_Y, &temp); bounds[3] = temp; pElem->Attribute(FiberBundleReader::XML_SIZE_Z, &temp); bounds[5] = temp; geometry->SetFloatBounds(bounds); // read bounds float bounds2[] = {0, 0, 0}; bounds2[0] = bounds[1]; bounds2[1] = bounds[3]; bounds2[2] = bounds[5]; m_OutputCache->SetBounds(bounds2); geometry->SetImageGeometry(true); m_OutputCache->SetGeometry(geometry); // generate tract container ContainerType::Pointer tractContainer = ContainerType::New(); int fiberID = 0; pElem = hRoot.FirstChildElement(FiberBundleReader::XML_FIBER_BUNDLE).FirstChild().Element(); for( pElem; pElem; pElem=pElem->NextSiblingElement()) { TiXmlElement* pElem2 = pElem->FirstChildElement(); ContainerTractType::Pointer tract = ContainerTractType::New(); for( pElem2; pElem2; pElem2=pElem2->NextSiblingElement()) { ContainerPointType point; pElem2->Attribute(FiberBundleReader::XML_POS_X, &temp); point[0] = temp; pElem2->Attribute(FiberBundleReader::XML_POS_Y, &temp); point[1] = temp; pElem2->Attribute(FiberBundleReader::XML_POS_Z, &temp); point[2] = temp; tract->InsertElement(tract->Size(), point); } pElem->Attribute(FiberBundleReader::XML_ID, &fiberID); tractContainer->CreateIndex(fiberID); tractContainer->SetElement(fiberID, tract); } m_OutputCache->addTractContainer(tractContainer); m_OutputCache->initFiberGroup(); MITK_INFO << "Fiber bundle read"; } catch(...) { MITK_INFO << "Could not read file "; } - } - else if (ext == ".vfib") - { - // generate tract container - ContainerType::Pointer tractContainer = ContainerType::New(); - mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); - - ///We create a Generic Reader to test de .vtk/ - vtkDataReader *chooser=vtkDataReader::New(); - chooser->SetFileName(m_FileName.c_str() ); - if( chooser->IsFilePolyData()) - { - vtkPolyDataReader *reader = vtkPolyDataReader::New(); - reader->SetFileName( m_FileName.c_str() ); - reader->Update(); - - if ( reader->GetOutput() != NULL ) - { - vtkPolyData* output = reader->GetOutput(); - double* center = output->GetCenter(); - MITK_INFO << "center: " << center[0] << ", " << center[1] << ", " << center[2]; - - float min = itk::NumericTraits::min(); - float max = itk::NumericTraits::max(); - float b[] = {max, min, max, min, max, min}; - - vtkCellArray* cells = output->GetLines(); - cells->InitTraversal(); - for (int i=0; iGetNumberOfCells(); i++) - { - ContainerTractType::Pointer tract = ContainerTractType::New(); - vtkCell* cell = output->GetCell(i); - int p = cell->GetNumberOfPoints(); - vtkPoints* points = cell->GetPoints(); - for (int j=0; jGetPoint(j, p); - ContainerPointType point; - point[0] = p[0]; - point[1] = p[1]; - point[2] = p[2]; - - if (point[0]b[1]) - b[1]=point[0]; - - if (point[1]b[3]) - b[3]=point[1]; - - if (point[2]b[5]) - b[5]=point[2]; - - tract->InsertElement(tract->Size(), point); - } - tractContainer->InsertElement(i, tract); - } - - float bounds[] = {0, 0, 0}; - bounds[0] = b[1]; - bounds[1] = b[3]; - bounds[2] = b[5]; - m_OutputCache->SetBounds(bounds); - - geometry->SetImageGeometry(true); - geometry->SetFloatBounds(b); - m_OutputCache->SetGeometry(geometry); - } - reader->Delete(); - } - chooser->Delete(); - m_OutputCache->addTractContainer(tractContainer); - m_OutputCache->initFiberGroup(); MITK_INFO << "Fiber bundle read"; } try { setlocale(LC_ALL, currLocale.c_str()); } catch(...) { MITK_INFO << "Could not reset locale " << currLocale; } } void FiberBundleReader::Update() { this->GenerateData(); } const char* FiberBundleReader ::GetFileName() const { return m_FileName.c_str(); } void FiberBundleReader ::SetFileName(const char* aFileName) { m_FileName = aFileName; } const char* FiberBundleReader ::GetFilePrefix() const { return m_FilePrefix.c_str(); } void FiberBundleReader ::SetFilePrefix(const char* aFilePrefix) { m_FilePrefix = aFilePrefix; } const char* FiberBundleReader ::GetFilePattern() const { return m_FilePattern.c_str(); } void FiberBundleReader ::SetFilePattern(const char* aFilePattern) { m_FilePattern = aFilePattern; } bool FiberBundleReader ::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) { // First check the extension if( filename == "" ) { return false; } std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); ext = itksys::SystemTools::LowerCase(ext); - if (ext == ".fib" || ext == ".vfib") + if (ext == ".fib_deprecated") { return true; } return false; } } //namespace MITK diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp index 41f24ed4a5..cac2bca968 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.cpp @@ -1,260 +1,259 @@ /*========================================================================= 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. =========================================================================*/ #include "mitkFiberBundleWriter.h" #include const char* mitk::FiberBundleWriter::XML_GEOMETRY = "geometry"; const char* mitk::FiberBundleWriter::XML_MATRIX_XX = "xx"; const char* mitk::FiberBundleWriter::XML_MATRIX_XY = "xy"; const char* mitk::FiberBundleWriter::XML_MATRIX_XZ = "xz"; const char* mitk::FiberBundleWriter::XML_MATRIX_YX = "yx"; const char* mitk::FiberBundleWriter::XML_MATRIX_YY = "yy"; const char* mitk::FiberBundleWriter::XML_MATRIX_YZ = "yz"; const char* mitk::FiberBundleWriter::XML_MATRIX_ZX = "zx"; const char* mitk::FiberBundleWriter::XML_MATRIX_ZY = "zy"; const char* mitk::FiberBundleWriter::XML_MATRIX_ZZ = "zz"; const char* mitk::FiberBundleWriter::XML_ORIGIN_X = "origin_x"; const char* mitk::FiberBundleWriter::XML_ORIGIN_Y = "origin_y"; const char* mitk::FiberBundleWriter::XML_ORIGIN_Z = "origin_z"; const char* mitk::FiberBundleWriter::XML_SPACING_X = "spacing_x"; const char* mitk::FiberBundleWriter::XML_SPACING_Y = "spacing_y"; const char* mitk::FiberBundleWriter::XML_SPACING_Z = "spacing_z"; const char* mitk::FiberBundleWriter::XML_SIZE_X = "size_x"; const char* mitk::FiberBundleWriter::XML_SIZE_Y = "size_y"; const char* mitk::FiberBundleWriter::XML_SIZE_Z = "size_z"; const char* mitk::FiberBundleWriter::XML_FIBER_BUNDLE = "fiber_bundle"; const char* mitk::FiberBundleWriter::XML_FIBER = "fiber"; const char* mitk::FiberBundleWriter::XML_PARTICLE = "particle"; const char* mitk::FiberBundleWriter::XML_ID = "id"; const char* mitk::FiberBundleWriter::XML_POS_X = "pos_x"; const char* mitk::FiberBundleWriter::XML_POS_Y = "pos_y"; const char* mitk::FiberBundleWriter::XML_POS_Z = "pos_z"; const char* mitk::FiberBundleWriter::XML_NUM_FIBERS = "num_fibers"; const char* mitk::FiberBundleWriter::XML_NUM_PARTICLES = "num_particles"; const char* mitk::FiberBundleWriter::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; const char* mitk::FiberBundleWriter::XML_FILE_VERSION = "file_version" ; const char* mitk::FiberBundleWriter::VERSION_STRING = "0.1" ; const char* mitk::FiberBundleWriter::ASCII_FILE = "ascii_file" ; const char* mitk::FiberBundleWriter::FILE_NAME = "file_name" ; mitk::FiberBundleWriter::FiberBundleWriter() : m_FileName(""), m_FilePrefix(""), m_FilePattern(""), m_Success(false) { this->SetNumberOfRequiredInputs( 1 ); } mitk::FiberBundleWriter::~FiberBundleWriter() {} void mitk::FiberBundleWriter::GenerateData() { try { MITK_INFO << "Writing fiber bundle"; m_Success = false; InputType* input = this->GetInput(); if (input == NULL) { itkWarningMacro(<<"Sorry, input to FiberBundleWriter is NULL!"); return; } if ( m_FileName == "" ) { itkWarningMacro( << "Sorry, filename has not been set!" ); return ; } const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); if ( locale.compare(currLocale)!=0 ) { try { setlocale(LC_ALL, locale.c_str()); } catch(...) { MITK_INFO << "Could not set locale " << locale; } } std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); ext = itksys::SystemTools::LowerCase(ext); - if (ext == ".fib") + if (ext == ".fib_deprecated") { /* direct linked includes of mitkFiberBundle DataStructure */ typedef mitk::FiberBundle::ContainerPointType ContainerPointType; typedef mitk::FiberBundle::ContainerTractType ContainerTractType; typedef mitk::FiberBundle::ContainerType ContainerType; ContainerType::Pointer tractContainer = input->GetTractContainer(); mitk::Geometry3D* geometry = input->GetGeometry(); TiXmlDocument documentXML; TiXmlDeclaration* declXML = new TiXmlDeclaration( "1.0", "", "" ); // TODO what to write here? encoding? etc.... documentXML.LinkEndChild( declXML ); TiXmlElement* mainXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER_BUNDLE_FILE); mainXML->SetAttribute(mitk::FiberBundleWriter::XML_FILE_VERSION, mitk::FiberBundleWriter::VERSION_STRING); documentXML.LinkEndChild(mainXML); TiXmlElement* geometryXML = new TiXmlElement(mitk::FiberBundleWriter::XML_GEOMETRY); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XX, geometry->GetMatrixColumn(0)[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XY, geometry->GetMatrixColumn(0)[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_XZ, geometry->GetMatrixColumn(0)[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YX, geometry->GetMatrixColumn(1)[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YY, geometry->GetMatrixColumn(1)[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_YZ, geometry->GetMatrixColumn(1)[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZX, geometry->GetMatrixColumn(2)[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZY, geometry->GetMatrixColumn(2)[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_MATRIX_ZZ, geometry->GetMatrixColumn(2)[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_X, geometry->GetOrigin()[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_Y, geometry->GetOrigin()[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_ORIGIN_Z, geometry->GetOrigin()[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_X, geometry->GetSpacing()[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_Y, geometry->GetSpacing()[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SPACING_Z, geometry->GetSpacing()[2]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_X, input->GetBounds()[0]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_Y, input->GetBounds()[1]); geometryXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_SIZE_Z, input->GetBounds()[2]); mainXML->LinkEndChild(geometryXML); TiXmlElement* fiberBundleXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER_BUNDLE); fiberBundleXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_FIBERS, tractContainer->size()); int numParticles = 0; for (int i=0; iSize(); i++) { ContainerTractType::Pointer tract = tractContainer->GetElement(i); TiXmlElement* fiberXML = new TiXmlElement(mitk::FiberBundleWriter::XML_FIBER); fiberXML->SetAttribute(mitk::FiberBundleWriter::XML_ID, i); fiberXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_PARTICLES, tract->Size()); numParticles += tract->Size(); for (int j=0; jSize(); j++) { TiXmlElement* particleXML = new TiXmlElement(mitk::FiberBundleWriter::XML_PARTICLE); ContainerPointType p = tract->GetElement(j); particleXML->SetAttribute(mitk::FiberBundleWriter::XML_ID, j); particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_X, p[0]); particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_Y, p[1]); particleXML->SetDoubleAttribute(mitk::FiberBundleWriter::XML_POS_Z, p[2]); fiberXML->LinkEndChild(particleXML); } fiberBundleXML->LinkEndChild(fiberXML); } fiberBundleXML->SetAttribute(mitk::FiberBundleWriter::XML_NUM_PARTICLES, numParticles); mainXML->LinkEndChild(fiberBundleXML); documentXML.SaveFile( m_FileName ); m_Success = true; MITK_INFO << "Fiber bundle written"; - }else if (ext == ".vfib" || ext == ".vtk") { + }else if (ext == ".fib" || ext == ".vtk") { vtkPolyDataWriter* writer = vtkPolyDataWriter::New(); writer->SetInput(input->GeneratePolydata()); writer->SetFileName(m_FileName.c_str()); writer->SetFileTypeToASCII(); writer->Write(); m_Success = true; MITK_INFO << "Fiber bundle written as polydata"; } try { setlocale(LC_ALL, currLocale.c_str()); } catch(...) { MITK_INFO << "Could not reset locale " << currLocale; } } catch(...) { throw; } } void mitk::FiberBundleWriter::SetInputFiberBundle( InputType* diffVolumes ) { this->ProcessObject::SetNthInput( 0, diffVolumes ); } mitk::FiberBundle* mitk::FiberBundleWriter::GetInput() { if ( this->GetNumberOfInputs() < 1 ) { return NULL; } else { return dynamic_cast ( this->ProcessObject::GetInput( 0 ) ); } } std::vector mitk::FiberBundleWriter::GetPossibleFileExtensions() { std::vector possibleFileExtensions; possibleFileExtensions.push_back(".fib"); - possibleFileExtensions.push_back(".vfib"); possibleFileExtensions.push_back(".vtk"); return possibleFileExtensions; } diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h index da7bef49c7..bd09c568a3 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundle/mitkFiberBundleWriter.h @@ -1,216 +1,216 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ Version: $Revision: 15096 $ 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 __mitkFiberBundleWriter_h #define __mitkFiberBundleWriter_h #include #include #include "mitkFiberBundle.h" #include namespace mitk { /** * Writes fiber bundles to a file * @ingroup Process */ class FiberBundleWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( FiberBundleWriter, mitk::FileWriterWithInformation ); //mitkWriterMacro; virtual void Write() { if ( this->GetInput() == NULL ) { itkExceptionMacro(<<"Write:Please specify an input!"); return; } /* Fill in image information.*/ this->UpdateOutputInformation(); (*(this->GetInputs().begin()))->SetRequestedRegionToLargestPossibleRegion(); this->PropagateRequestedRegion(NULL); this->UpdateOutputData(NULL); } virtual void Update() { Write(); } itkNewMacro( Self ); typedef mitk::FiberBundle InputType; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInputFiberBundle( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods virtual const char * GetDefaultFilename() { return "FiberBundle.fib"; } - virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.vfib *.vtk)"; } + virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.vtk)"; } virtual const char * GetDefaultExtension() { return ".fib"; } virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; virtual void DoWrite(BaseData::Pointer data) { if (CanWriteBaseDataType(data)) { this->SetInputFiberBundle(dynamic_cast(data.GetPointer())); this->Update(); } }; static const char* XML_GEOMETRY; static const char* XML_MATRIX_XX; static const char* XML_MATRIX_XY; static const char* XML_MATRIX_XZ; static const char* XML_MATRIX_YX; static const char* XML_MATRIX_YY; static const char* XML_MATRIX_YZ; static const char* XML_MATRIX_ZX; static const char* XML_MATRIX_ZY; static const char* XML_MATRIX_ZZ; static const char* XML_ORIGIN_X; static const char* XML_ORIGIN_Y; static const char* XML_ORIGIN_Z; static const char* XML_SPACING_X; static const char* XML_SPACING_Y; static const char* XML_SPACING_Z; static const char* XML_SIZE_X; static const char* XML_SIZE_Y; static const char* XML_SIZE_Z; static const char* XML_FIBER_BUNDLE; static const char* XML_FIBER; static const char* XML_PARTICLE; static const char* XML_ID; static const char* XML_POS_X; static const char* XML_POS_Y; static const char* XML_POS_Z; static const char* VERSION_STRING; static const char* XML_FIBER_BUNDLE_FILE; static const char* XML_FILE_VERSION; static const char* XML_NUM_FIBERS; static const char* XML_NUM_PARTICLES; static const char* ASCII_FILE; static const char* FILE_NAME; protected: FiberBundleWriter(); virtual ~FiberBundleWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #endif //__mitkFiberBundleWriter_h diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp index 6df23209a3..6e9554621a 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp @@ -1,415 +1,412 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ - + 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. - + =========================================================================*/ #include "mitkFiberBundleX.h" /* musthave */ //#include // without geometry, fibers are not rendered #include #include #include #include #include #include // baptize array names const char* mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED = "Color_Orient"; const char* mitk::FiberBundleX::COLORCODING_FA_BASED = "Color_FA"; const char* mitk::FiberBundleX::FIBER_ID_ARRAY = "Fiber_IDs"; mitk::FiberBundleX::FiberBundleX(vtkSmartPointer fiberPolyData ) - : m_currentColorCoding(NULL) - , m_isModified(false) + : m_currentColorCoding(NULL) + , m_isModified(false) { - //generate geometry of passed polydata - if (fiberPolyData == NULL) - this->m_FiberPolyData = vtkSmartPointer::New(); - else - this->m_FiberPolyData = fiberPolyData; - - this->UpdateFiberGeometry(); - + //generate geometry of passed polydata + if (fiberPolyData == NULL) + this->m_FiberPolyData = vtkSmartPointer::New(); + else + this->m_FiberPolyData = fiberPolyData; + this->UpdateFiberGeometry(); } mitk::FiberBundleX::~FiberBundleX() { - // Memory Management - m_FiberPolyData->Delete(); + // Memory Management + m_FiberPolyData->Delete(); } -/* === main input method ==== +/* * set computed fibers from tractography algorithms */ void mitk::FiberBundleX::SetFiberPolyData(vtkSmartPointer fiberPD) -{ - if (fiberPD == NULL) - this->m_FiberPolyData = vtkSmartPointer::New(); - else - this->m_FiberPolyData = fiberPD; +{ + if (fiberPD == NULL) + this->m_FiberPolyData = vtkSmartPointer::New(); + else + this->m_FiberPolyData = fiberPD; - m_isModified = true; + m_isModified = true; } -/* === main output method === +/* * return fiberbundle as vtkPolyData * Depending on processing of input fibers, this method returns * the latest processed fibers. */ vtkSmartPointer mitk::FiberBundleX::GetFiberPolyData() { - return m_FiberPolyData; + return m_FiberPolyData; } /*=================================== *++++ PROCESSING WITH FIBERS +++++++ ====================================*/ void mitk::FiberBundleX::DoColorCodingOrientationbased() { //===== FOR WRITING A TEST ======================== // colorT size == tupelComponents * tupelElements // compare color results // to cover this code 100% also polydata needed, where colorarray already exists // + one fiber with exactly 1 point // + one fiber with 0 points //================================================= /* make sure that processing colorcoding is only called when necessary */ if ( m_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED) && m_FiberPolyData->GetNumberOfPoints() == m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)->GetNumberOfTuples() ) { // fiberstructure is already colorcoded MITK_INFO << " NO NEED TO REGENERATE COLORCODING! " ; return; } + /* Finally, execute color calculation */ + vtkPoints* extrPoints = m_FiberPolyData->GetPoints(); + int numOfPoints = extrPoints->GetNumberOfPoints(); - /* Finally, execute color calculation */ - vtkPoints* extrPoints = m_FiberPolyData->GetPoints(); - int numOfPoints = extrPoints->GetNumberOfPoints(); + //colors and alpha value for each single point, RGBA = 4 components + unsigned char rgba[4] = {0,0,0,0}; + int componentSize = sizeof(rgba); - //colors and alpha value for each single point, RGBA = 4 components - unsigned char rgba[4] = {0,0,0,0}; - int componentSize = sizeof(rgba); + vtkUnsignedCharArray * colorsT = vtkUnsignedCharArray::New(); + colorsT->Allocate(numOfPoints * componentSize); + colorsT->SetNumberOfComponents(componentSize); + colorsT->SetName(COLORCODING_ORIENTATION_BASED); - vtkUnsignedCharArray * colorsT = vtkUnsignedCharArray::New(); - colorsT->Allocate(numOfPoints * componentSize); - colorsT->SetNumberOfComponents(componentSize); - colorsT->SetName(COLORCODING_ORIENTATION_BASED); - - /* checkpoint: does polydata contain any fibers */ - int numOfFibers = m_FiberPolyData->GetNumberOfLines(); - if (numOfFibers < 1) { - MITK_INFO << "\n ========= Number of Fibers is 0 and below ========= \n"; - return; - } + /* checkpoint: does polydata contain any fibers */ + int numOfFibers = m_FiberPolyData->GetNumberOfLines(); + if (numOfFibers < 1) { + MITK_INFO << "\n ========= Number of Fibers is 0 and below ========= \n"; + return; + } - /* extract single fibers of fiberBundle */ - vtkCellArray* fiberList = m_FiberPolyData->GetLines(); - fiberList->InitTraversal(); - for (int fi=0; fiGetLines(); + fiberList->InitTraversal(); + for (int fi=0; fiGetNextCell(pointsPerFiber, idList); + vtkIdType* idList; // contains the point id's of the line + vtkIdType pointsPerFiber; // number of points for current line + fiberList->GetNextCell(pointsPerFiber, idList); // MITK_INFO << "Fib#: " << fi << " of " << numOfFibers << " pnts in fiber: " << pointsPerFiber ; - /* single fiber checkpoints: is number of points valid */ - if (pointsPerFiber > 1) - { - /* operate on points of single fiber */ - for (int i=0; i 1) + { + /* operate on points of single fiber */ + for (int i=0; i 0) - { - /* The color value of the current point is influenced by the previous point and next point. */ - vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); - vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); - vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); + if (i 0) + { + /* The color value of the current point is influenced by the previous point and next point. */ + vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); + vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); + vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); - vnl_vector_fixed< double, 3 > diff1; - diff1 = currentPntvtk - nextPntvtk; + vnl_vector_fixed< double, 3 > diff1; + diff1 = currentPntvtk - nextPntvtk; - vnl_vector_fixed< double, 3 > diff2; - diff2 = currentPntvtk - prevPntvtk; + vnl_vector_fixed< double, 3 > diff2; + diff2 = currentPntvtk - prevPntvtk; - vnl_vector_fixed< double, 3 > diff; - diff = (diff1 - diff2) / 2.0; - diff.normalize(); + vnl_vector_fixed< double, 3 > diff; + diff = (diff1 - diff2) / 2.0; + diff.normalize(); - rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); - rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); - rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); - rgba[3] = (unsigned char) (255.0); + rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); + rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); + rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); + rgba[3] = (unsigned char) (255.0); - } else if (i==0) { - /* First point has no previous point, therefore only diff1 is taken */ + } else if (i==0) { + /* First point has no previous point, therefore only diff1 is taken */ - vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); - vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); + vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); + vnl_vector_fixed< double, 3 > nextPntvtk(extrPoints->GetPoint(idList[i+1])[0], extrPoints->GetPoint(idList[i+1])[1], extrPoints->GetPoint(idList[i+1])[2]); - vnl_vector_fixed< double, 3 > diff1; - diff1 = currentPntvtk - nextPntvtk; - diff1.normalize(); + vnl_vector_fixed< double, 3 > diff1; + diff1 = currentPntvtk - nextPntvtk; + diff1.normalize(); - rgba[0] = (unsigned char) (255.0 * std::abs(diff1[0])); - rgba[1] = (unsigned char) (255.0 * std::abs(diff1[1])); - rgba[2] = (unsigned char) (255.0 * std::abs(diff1[2])); - rgba[3] = (unsigned char) (255.0); + rgba[0] = (unsigned char) (255.0 * std::abs(diff1[0])); + rgba[1] = (unsigned char) (255.0 * std::abs(diff1[1])); + rgba[2] = (unsigned char) (255.0 * std::abs(diff1[2])); + rgba[3] = (unsigned char) (255.0); - } else if (i==pointsPerFiber-1) { - /* Last point has no next point, therefore only diff2 is taken */ - vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); - vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); + } else if (i==pointsPerFiber-1) { + /* Last point has no next point, therefore only diff2 is taken */ + vnl_vector_fixed< double, 3 > currentPntvtk(extrPoints->GetPoint(idList[i])[0], extrPoints->GetPoint(idList[i])[1],extrPoints->GetPoint(idList[i])[2]); + vnl_vector_fixed< double, 3 > prevPntvtk(extrPoints->GetPoint(idList[i-1])[0], extrPoints->GetPoint(idList[i-1])[1], extrPoints->GetPoint(idList[i-1])[2]); - vnl_vector_fixed< double, 3 > diff2; - diff2 = currentPntvtk - prevPntvtk; - diff2.normalize(); + vnl_vector_fixed< double, 3 > diff2; + diff2 = currentPntvtk - prevPntvtk; + diff2.normalize(); - rgba[0] = (unsigned char) (255.0 * std::abs(diff2[0])); - rgba[1] = (unsigned char) (255.0 * std::abs(diff2[1])); - rgba[2] = (unsigned char) (255.0 * std::abs(diff2[2])); - rgba[3] = (unsigned char) (255.0); + rgba[0] = (unsigned char) (255.0 * std::abs(diff2[0])); + rgba[1] = (unsigned char) (255.0 * std::abs(diff2[1])); + rgba[2] = (unsigned char) (255.0 * std::abs(diff2[2])); + rgba[3] = (unsigned char) (255.0); - } + } - colorsT->InsertTupleValue(idList[i], rgba); + colorsT->InsertTupleValue(idList[i], rgba); - } //end for loop + } //end for loop - } else if (pointsPerFiber == 1) { - /* a single point does not define a fiber (use vertex mechanisms instead */ - continue; - // colorsT->InsertTupleValue(0, rgba); + } else if (pointsPerFiber == 1) { + /* a single point does not define a fiber (use vertex mechanisms instead */ + continue; + // colorsT->InsertTupleValue(0, rgba); - } else { - MITK_INFO << "Fiber with 0 points detected... please check your tractography algorithm!" ; - continue; + } else { + MITK_INFO << "Fiber with 0 points detected... please check your tractography algorithm!" ; + continue; - } + } - }//end for loop + }//end for loop m_FiberPolyData->GetPointData()->AddArray(colorsT); /*========================= - this is more relevant for renderer than for fiberbundleX datastructure - think about sourcing this to a explicit method which coordinates colorcoding */ this->SetColorCoding(COLORCODING_ORIENTATION_BASED); m_isModified = true; // =========================== - //mini test, shall be ported to MITK TESTINGS! - if (colorsT->GetSize() != numOfPoints*componentSize) { - MITK_INFO << "ALLOCATION ERROR IN INITIATING COLOR ARRAY"; - } + //mini test, shall be ported to MITK TESTINGS! + if (colorsT->GetSize() != numOfPoints*componentSize) { + MITK_INFO << "ALLOCATION ERROR IN INITIATING COLOR ARRAY"; + } } void mitk::FiberBundleX::DoGenerateFiberIds() { - if (m_FiberPolyData == NULL) - return; - - // for (int i=0; i<10000000; ++i) - // { - // if(i%500 == 0) - // MITK_INFO << i; - // } - // MITK_INFO << "Generating Fiber Ids"; - vtkSmartPointer idFiberFilter = vtkSmartPointer::New(); - idFiberFilter->SetInput(m_FiberPolyData); - idFiberFilter->CellIdsOn(); - // idFiberFilter->PointIdsOn(); // point id's are not needed - idFiberFilter->SetIdsArrayName(FIBER_ID_ARRAY); - idFiberFilter->FieldDataOn(); - idFiberFilter->Update(); - - m_FiberIdDataSet = idFiberFilter->GetOutput(); - - MITK_INFO << "Generating Fiber Ids...[done] | " << m_FiberIdDataSet->GetNumberOfCells(); + if (m_FiberPolyData == NULL) + return; + + // for (int i=0; i<10000000; ++i) + // { + // if(i%500 == 0) + // MITK_INFO << i; + // } + // MITK_INFO << "Generating Fiber Ids"; + vtkSmartPointer idFiberFilter = vtkSmartPointer::New(); + idFiberFilter->SetInput(m_FiberPolyData); + idFiberFilter->CellIdsOn(); + // idFiberFilter->PointIdsOn(); // point id's are not needed + idFiberFilter->SetIdsArrayName(FIBER_ID_ARRAY); + idFiberFilter->FieldDataOn(); + idFiberFilter->Update(); + + m_FiberIdDataSet = idFiberFilter->GetOutput(); + + MITK_INFO << "Generating Fiber Ids...[done] | " << m_FiberIdDataSet->GetNumberOfCells(); } void mitk::FiberBundleX::UpdateFiberGeometry() { - float min = itk::NumericTraits::min(); - float max = itk::NumericTraits::max(); - float b[] = {max, min, max, min, max, min}; + float min = itk::NumericTraits::min(); + float max = itk::NumericTraits::max(); + float b[] = {max, min, max, min, max, min}; - vtkCellArray* cells = m_FiberPolyData->GetLines(); - cells->InitTraversal(); - for (int i=0; iGetNumberOfCells(); i++) - { + vtkCellArray* cells = m_FiberPolyData->GetLines(); + cells->InitTraversal(); + for (int i=0; iGetNumberOfCells(); i++) + { - vtkCell* cell = m_FiberPolyData->GetCell(i); - int p = cell->GetNumberOfPoints(); - vtkPoints* points = cell->GetPoints(); - for (int j=0; jGetPoint(j, p); - - if (p[0]b[1]) - b[1]=p[0]; + vtkCell* cell = m_FiberPolyData->GetCell(i); + int p = cell->GetNumberOfPoints(); + vtkPoints* points = cell->GetPoints(); + for (int j=0; jGetPoint(j, p); - if (p[1]b[3]) - b[3]=p[1]; + if (p[0]b[1]) + b[1]=p[0]; - if (p[2]b[5]) - b[5]=p[2]; + if (p[1]b[3]) + b[3]=p[1]; + if (p[2]b[5]) + b[5]=p[2]; - } } - // provide some buffer space at borders + } - for(int i=0; i<=4; i+=2){ - b[i] -=10; - } + // provide some buffer space at borders - for(int i=1; i<=5; i+=2){ - b[i] +=10; - } + for(int i=0; i<=4; i+=2){ + b[i] -=10; + } + + for(int i=1; i<=5; i+=2){ + b[i] +=10; + } - mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); - geometry->SetImageGeometry(true); - geometry->SetFloatBounds(b); - this->SetGeometry(geometry); + mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); + geometry->SetImageGeometry(true); + geometry->SetFloatBounds(b); + this->SetGeometry(geometry); } /*============================== *++++ FIBER INFORMATION +++++++ ===============================*/ QStringList mitk::FiberBundleX::GetAvailableColorCodings() { QStringList availableColorCodings; int numColors = m_FiberPolyData->GetPointData()->GetNumberOfArrays(); for(int i=0; iGetPointData()->GetArrayName(i)); } //this controlstructure shall be implemented by the calling method if (availableColorCodings.isEmpty()) MITK_INFO << "no colorcodings available in fiberbundleX"; // for(int i=0; im_currentColorCoding; } void mitk::FiberBundleX::SetColorCoding(const char* requestedColorCoding) { // MITK_INFO << "FbX try to set colorCoding: " << requestedColorCoding << " compare with: " << COLORCODING_ORIENTATION_BASED; if(strcmp (COLORCODING_ORIENTATION_BASED,requestedColorCoding) == 0 ) { this->m_currentColorCoding = (char*) COLORCODING_ORIENTATION_BASED; this->m_isModified = true; } else if(strcmp (COLORCODING_FA_BASED,requestedColorCoding) == 0 ) { this->m_currentColorCoding = (char*) COLORCODING_FA_BASED; this->m_isModified = true; } else { MITK_INFO << "FIBERBUNDLE X: UNKNOWN COLORCODING in FIBERBUNDLEX Datastructure"; this->m_currentColorCoding = "---"; //will cause blank colorcoding of fibers this->m_isModified = true; } } bool mitk::FiberBundleX::isFiberBundleXModified() { - return m_isModified; + return m_isModified; } void mitk::FiberBundleX::setFBXModificationDone() { - m_isModified = false; + m_isModified = false; } /* ESSENTIAL IMPLEMENTATION OF SUPERCLASS METHODS */ void mitk::FiberBundleX::UpdateOutputInformation() { } void mitk::FiberBundleX::SetRequestedRegionToLargestPossibleRegion() { } bool mitk::FiberBundleX::RequestedRegionIsOutsideOfTheBufferedRegion() { - return false; + return false; } bool mitk::FiberBundleX::VerifyRequestedRegion() { - return true; + return true; } void mitk::FiberBundleX::SetRequestedRegion( itk::DataObject *data ) { } diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp index af9a8b5f33..435c713550 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.cpp @@ -1,385 +1,149 @@ /*========================================================================= 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. =========================================================================*/ #include "mitkFiberBundleXReader.h" #include -#include -#include -#include -#include -#include -#include #include #include #include -#include -#include - -const char* mitk::FiberBundleXReader::XML_GEOMETRY = "geometry"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_XX = "xx"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_XY = "xy"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_XZ = "xz"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_YX = "yx"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_YY = "yy"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_YZ = "yz"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_ZX = "zx"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_ZY = "zy"; - -const char* mitk::FiberBundleXReader::XML_MATRIX_ZZ = "zz"; - -const char* mitk::FiberBundleXReader::XML_ORIGIN_X = "origin_x"; - -const char* mitk::FiberBundleXReader::XML_ORIGIN_Y = "origin_y"; - -const char* mitk::FiberBundleXReader::XML_ORIGIN_Z = "origin_z"; - -const char* mitk::FiberBundleXReader::XML_SPACING_X = "spacing_x"; - -const char* mitk::FiberBundleXReader::XML_SPACING_Y = "spacing_y"; - -const char* mitk::FiberBundleXReader::XML_SPACING_Z = "spacing_z"; - -const char* mitk::FiberBundleXReader::XML_SIZE_X = "size_x"; - -const char* mitk::FiberBundleXReader::XML_SIZE_Y = "size_y"; - -const char* mitk::FiberBundleXReader::XML_SIZE_Z = "size_z"; - -const char* mitk::FiberBundleXReader::XML_FIBER_BUNDLE = "fiber_bundle"; - -const char* mitk::FiberBundleXReader::XML_FIBER = "fiber"; - -const char* mitk::FiberBundleXReader::XML_PARTICLE = "particle"; - -const char* mitk::FiberBundleXReader::XML_ID = "id"; - -const char* mitk::FiberBundleXReader::XML_POS_X = "pos_x"; - -const char* mitk::FiberBundleXReader::XML_POS_Y = "pos_y"; - -const char* mitk::FiberBundleXReader::XML_POS_Z = "pos_z"; - -const char* mitk::FiberBundleXReader::XML_NUM_FIBERS = "num_fibers"; - -const char* mitk::FiberBundleXReader::XML_NUM_PARTICLES = "num_particles"; - -const char* mitk::FiberBundleXReader::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; - -const char* mitk::FiberBundleXReader::XML_FILE_VERSION = "file_version" ; - -const char* mitk::FiberBundleXReader::VERSION_STRING = "0.1" ; +#include namespace mitk { void FiberBundleXReader ::GenerateData() { - MITK_INFO << "Reading fiber bundle"; if ( ( ! m_OutputCache ) ) { Superclass::SetNumberOfRequiredOutputs(0); this->GenerateOutputInformation(); } if (!m_OutputCache) { - itkWarningMacro("Tree cache is empty!"); + itkWarningMacro("Output cache is empty!"); } Superclass::SetNumberOfRequiredOutputs(1); Superclass::SetNthOutput(0, m_OutputCache.GetPointer()); } void FiberBundleXReader::GenerateOutputInformation() { - m_OutputCache = OutputType::New(); - -// std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); -// ext = itksys::SystemTools::LowerCase(ext); - - if ( m_FileName == "") + try { - + MITK_INFO << "Reading fiber bundle"; + const std::string& locale = "C"; + const std::string& currLocale = setlocale( LC_ALL, NULL ); + setlocale(LC_ALL, locale.c_str()); + + std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); + ext = itksys::SystemTools::LowerCase(ext); + + vtkSmartPointer chooser=vtkDataReader::New(); + chooser->SetFileName(m_FileName.c_str() ); + if( chooser->IsFilePolyData()) + { + vtkSmartPointer reader = vtkPolyDataReader::New(); + reader->SetFileName( m_FileName.c_str() ); + reader->Update(); + + if ( reader->GetOutput() != NULL ) + { + vtkSmartPointer fiberPolyData = reader->GetOutput(); + m_OutputCache = OutputType::New(fiberPolyData); + } + } + + setlocale(LC_ALL, currLocale.c_str()); + MITK_INFO << "Fiber bundle read"; + } + catch(...) + { + throw; } -// else if (ext == ".fib") -// { -// try -// { -// TiXmlDocument doc( m_FileName ); -// doc.LoadFile(); -// -// TiXmlHandle hDoc(&doc); -// TiXmlElement* pElem; -// TiXmlHandle hRoot(0); -// -// pElem = hDoc.FirstChildElement().Element(); -// -// // save this for later -// hRoot = TiXmlHandle(pElem); -// -// pElem = hRoot.FirstChildElement(FiberBundleXReader::XML_GEOMETRY).Element(); -// -// // read geometry -// mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); -// -// // read origin -// mitk::Point3D origin; -// double temp = 0; -// pElem->Attribute(FiberBundleXReader::XML_ORIGIN_X, &temp); -// origin[0] = temp; -// pElem->Attribute(FiberBundleXReader::XML_ORIGIN_Y, &temp); -// origin[1] = temp; -// pElem->Attribute(FiberBundleXReader::XML_ORIGIN_Z, &temp); -// origin[2] = temp; -// geometry->SetOrigin(origin); -// -// // read spacing -// float spacing[3]; -// pElem->Attribute(FiberBundleXReader::XML_SPACING_X, &temp); -// spacing[0] = temp; -// pElem->Attribute(FiberBundleXReader::XML_SPACING_Y, &temp); -// spacing[1] = temp; -// pElem->Attribute(FiberBundleXReader::XML_SPACING_Z, &temp); -// spacing[2] = temp; -// geometry->SetSpacing(spacing); -// -// // read transform -// vtkMatrix4x4* m = vtkMatrix4x4::New(); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_XX, &temp); -// m->SetElement(0,0,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_XY, &temp); -// m->SetElement(1,0,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_XZ, &temp); -// m->SetElement(2,0,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_YX, &temp); -// m->SetElement(0,1,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_YY, &temp); -// m->SetElement(1,1,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_YZ, &temp); -// m->SetElement(2,1,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_ZX, &temp); -// m->SetElement(0,2,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_ZY, &temp); -// m->SetElement(1,2,temp); -// pElem->Attribute(FiberBundleXReader::XML_MATRIX_ZZ, &temp); -// m->SetElement(2,2,temp); -// -// m->SetElement(0,3,origin[0]); -// m->SetElement(1,3,origin[1]); -// m->SetElement(2,3,origin[2]); -// m->SetElement(3,3,1); -// geometry->SetIndexToWorldTransformByVtkMatrix(m); -// -// // read bounds -// float bounds[] = {0, 0, 0, 0, 0, 0}; -// pElem->Attribute(FiberBundleXReader::XML_SIZE_X, &temp); -// bounds[1] = temp; -// pElem->Attribute(FiberBundleXReader::XML_SIZE_Y, &temp); -// bounds[3] = temp; -// pElem->Attribute(FiberBundleXReader::XML_SIZE_Z, &temp); -// bounds[5] = temp; -// geometry->SetFloatBounds(bounds); -// -// // read bounds -// float bounds2[] = {0, 0, 0}; -// bounds2[0] = bounds[1]; -// bounds2[1] = bounds[3]; -// bounds2[2] = bounds[5]; -// m_OutputCache->SetBounds(bounds2); -// -// geometry->SetImageGeometry(true); -// m_OutputCache->SetGeometry(geometry); -// -// // generate tract container -// ContainerType::Pointer tractContainer = ContainerType::New(); -// -// int fiberID = 0; -// pElem = hRoot.FirstChildElement(FiberBundleXReader::XML_FIBER_BUNDLE).FirstChild().Element(); -// for( pElem; pElem; pElem=pElem->NextSiblingElement()) -// { -// TiXmlElement* pElem2 = pElem->FirstChildElement(); -// ContainerTractType::Pointer tract = ContainerTractType::New(); -// for( pElem2; pElem2; pElem2=pElem2->NextSiblingElement()) -// { -// ContainerPointType point; -// pElem2->Attribute(FiberBundleXReader::XML_POS_X, &temp); -// point[0] = temp; -// pElem2->Attribute(FiberBundleXReader::XML_POS_Y, &temp); -// point[1] = temp; -// pElem2->Attribute(FiberBundleXReader::XML_POS_Z, &temp); -// point[2] = temp; -// -// tract->InsertElement(tract->Size(), point); -// -// } -// pElem->Attribute(FiberBundleXReader::XML_ID, &fiberID); -// tractContainer->CreateIndex(fiberID); -// tractContainer->SetElement(fiberID, tract); -// -// } -// m_OutputCache->addTractContainer(tractContainer); -// m_OutputCache->initFiberGroup(); -// -// MITK_INFO << "Fiber bundle read"; -// } -// catch(...) -// { -// MITK_INFO << "Could not read file "; -// } -// } -// else if (ext == ".vfib") -// { -// // generate tract container -// ContainerType::Pointer tractContainer = ContainerType::New(); -// mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); -// -// ///We create a Generic Reader to test de .vtk/ -// vtkDataReader *chooser=vtkDataReader::New(); -// chooser->SetFileName(m_FileName.c_str() ); -// if( chooser->IsFilePolyData()) -// { -// vtkPolyDataReader *reader = vtkPolyDataReader::New(); -// reader->SetFileName( m_FileName.c_str() ); -// reader->Update(); -// -// if ( reader->GetOutput() != NULL ) -// { -// vtkPolyData* output = reader->GetOutput(); -// output->ComputeBounds(); -// double bounds[3]; -// output->GetBounds(bounds); -// double center[3]; -// output->GetCenter(center); -// Point3D origin; -// origin.SetElement(0, -center[0]); -// origin.SetElement(1, -center[1]); -// origin.SetElement(2, -center[2]); -// MITK_INFO << origin; -// -// mitk::Surface::Pointer surf = mitk::Surface::New(); -// surf->SetVtkPolyData(output); -// mitk::Geometry3D* geom = surf->GetGeometry(); -// //geom->SetOrigin(origin); -// geom->SetImageGeometry(true); -// m_OutputCache->SetBounds(bounds); -// m_OutputCache->SetGeometry(geom); -// vtkCellArray* cells = output->GetLines(); -// -// cells->InitTraversal(); -// -// for (int i=0; iGetNumberOfCells(); i++) -// { -// ContainerTractType::Pointer tract = ContainerTractType::New(); -// vtkCell* cell = output->GetCell(i); -// int p = cell->GetNumberOfPoints(); -// vtkPoints* points = cell->GetPoints(); -// for (int j=0; jGetPoint(j, p); -// ContainerPointType point; -// point[0] = p[0]; -// point[1] = p[1]; -// point[2] = p[2]; -// tract->InsertElement(tract->Size(), point); -// } -// tractContainer->InsertElement(i, tract); -// } -// } -// reader->Delete(); -// } -// chooser->Delete(); -// -// m_OutputCache->addTractContainer(tractContainer); -// m_OutputCache->initFiberGroup(); -// MITK_INFO << "Fiber bundle read"; -// } } void FiberBundleXReader::Update() { this->GenerateData(); } const char* FiberBundleXReader ::GetFileName() const { return m_FileName.c_str(); } void FiberBundleXReader ::SetFileName(const char* aFileName) { m_FileName = aFileName; } const char* FiberBundleXReader ::GetFilePrefix() const { return m_FilePrefix.c_str(); } void FiberBundleXReader ::SetFilePrefix(const char* aFilePrefix) { m_FilePrefix = aFilePrefix; } const char* FiberBundleXReader ::GetFilePattern() const { return m_FilePattern.c_str(); } void FiberBundleXReader ::SetFilePattern(const char* aFilePattern) { m_FilePattern = aFilePattern; } bool FiberBundleXReader ::CanReadFile(const std::string filename, const std::string /*filePrefix*/, const std::string /*filePattern*/) { // First check the extension if( filename == "" ) { return false; } -// std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); -// ext = itksys::SystemTools::LowerCase(ext); + std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); + ext = itksys::SystemTools::LowerCase(ext); + if (ext == ".fib") + { + return true; + } return false; } } //namespace MITK diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.h b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.h index e2a5c10ba5..fe53bea830 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.h +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXReader.h @@ -1,143 +1,77 @@ /*========================================================================= 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 __mitkFiberBundleXReader_h #define __mitkFiberBundleXReader_h -#include "mitkCommon.h" -#include "itkVectorContainer.h" -#include "mitkFileReader.h" -#include "mitkFiberBundleX.h" -#include "itkSlowPolyLineParametricPath.h" - -//NOTE>umbenennen in FiberBundleXSource +#include +#include +#include +#include namespace mitk { - /** \brief + /** \brief */ class FiberBundleXReader : public FileReader, public BaseProcess { public: /** Types for the standardized TractContainer **/ /* direct linked includes of mitkFiberBundleX DataStructure */ - + typedef mitk::FiberBundleX OutputType; - + mitkClassMacro( FiberBundleXReader, BaseProcess ); itkNewMacro(Self); const char* GetFileName() const; void SetFileName(const char* aFileName); const char* GetFilePrefix() const; void SetFilePrefix(const char* aFilePrefix); const char* GetFilePattern() const; void SetFilePattern(const char* aFilePattern); static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern); // itkGetMacro(GroupFiberBundleX, FiberGroupType::Pointer); // itkGetMacro(TractContainer, ContainerType::Pointer); virtual void Update(); - - static const char* XML_GEOMETRY; - - static const char* XML_MATRIX_XX; - - static const char* XML_MATRIX_XY; - - static const char* XML_MATRIX_XZ; - - static const char* XML_MATRIX_YX; - - static const char* XML_MATRIX_YY; - - static const char* XML_MATRIX_YZ; - - static const char* XML_MATRIX_ZX; - - static const char* XML_MATRIX_ZY; - - static const char* XML_MATRIX_ZZ; - - static const char* XML_ORIGIN_X; - - static const char* XML_ORIGIN_Y; - - static const char* XML_ORIGIN_Z; - - static const char* XML_SPACING_X; - - static const char* XML_SPACING_Y; - - static const char* XML_SPACING_Z; - - static const char* XML_SIZE_X; - - static const char* XML_SIZE_Y; - - static const char* XML_SIZE_Z; - - static const char* XML_FIBER_BUNDLE; - - static const char* XML_FIBER; - - static const char* XML_PARTICLE; - - static const char* XML_ID; - - static const char* XML_POS_X; - - static const char* XML_POS_Y; - - static const char* XML_POS_Z; - - static const char* VERSION_STRING; - - static const char* XML_FIBER_BUNDLE_FILE; - - static const char* XML_FILE_VERSION; - - static const char* XML_NUM_FIBERS; - - static const char* XML_NUM_PARTICLES; - protected: /** Does the real work. */ virtual void GenerateData(); virtual void GenerateOutputInformation(); OutputType::Pointer m_OutputCache; std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; private: void operator=(const Self&); //purposely not implemented }; } //namespace MITK #endif // __mitkFiberBundleXReader_h diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.cpp b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.cpp index c6d31cad5d..4e9f835a0e 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.cpp +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.cpp @@ -1,227 +1,95 @@ /*========================================================================= 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. =========================================================================*/ #include "mitkFiberBundleXWriter.h" -#include - -const char* mitk::FiberBundleXWriter::XML_GEOMETRY = "geometry"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_XX = "xx"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_XY = "xy"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_XZ = "xz"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_YX = "yx"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_YY = "yy"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_YZ = "yz"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_ZX = "zx"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_ZY = "zy"; - -const char* mitk::FiberBundleXWriter::XML_MATRIX_ZZ = "zz"; - -const char* mitk::FiberBundleXWriter::XML_ORIGIN_X = "origin_x"; - -const char* mitk::FiberBundleXWriter::XML_ORIGIN_Y = "origin_y"; - -const char* mitk::FiberBundleXWriter::XML_ORIGIN_Z = "origin_z"; - -const char* mitk::FiberBundleXWriter::XML_SPACING_X = "spacing_x"; - -const char* mitk::FiberBundleXWriter::XML_SPACING_Y = "spacing_y"; - -const char* mitk::FiberBundleXWriter::XML_SPACING_Z = "spacing_z"; - -const char* mitk::FiberBundleXWriter::XML_SIZE_X = "size_x"; - -const char* mitk::FiberBundleXWriter::XML_SIZE_Y = "size_y"; - -const char* mitk::FiberBundleXWriter::XML_SIZE_Z = "size_z"; - -const char* mitk::FiberBundleXWriter::XML_FIBER_BUNDLE = "fiber_bundle"; - -const char* mitk::FiberBundleXWriter::XML_FIBER = "fiber"; - -const char* mitk::FiberBundleXWriter::XML_PARTICLE = "particle"; - -const char* mitk::FiberBundleXWriter::XML_ID = "id"; - -const char* mitk::FiberBundleXWriter::XML_POS_X = "pos_x"; - -const char* mitk::FiberBundleXWriter::XML_POS_Y = "pos_y"; - -const char* mitk::FiberBundleXWriter::XML_POS_Z = "pos_z"; - -const char* mitk::FiberBundleXWriter::XML_NUM_FIBERS = "num_fibers"; - -const char* mitk::FiberBundleXWriter::XML_NUM_PARTICLES = "num_particles"; - -const char* mitk::FiberBundleXWriter::XML_FIBER_BUNDLE_FILE = "fiber_bundle_file" ; - -const char* mitk::FiberBundleXWriter::XML_FILE_VERSION = "file_version" ; - -const char* mitk::FiberBundleXWriter::VERSION_STRING = "0.1" ; - -const char* mitk::FiberBundleXWriter::ASCII_FILE = "ascii_file" ; - -const char* mitk::FiberBundleXWriter::FILE_NAME = "file_name" ; +#include mitk::FiberBundleXWriter::FiberBundleXWriter() : m_FileName(""), m_FilePrefix(""), m_FilePattern(""), m_Success(false) { this->SetNumberOfRequiredInputs( 1 ); } mitk::FiberBundleXWriter::~FiberBundleXWriter() {} void mitk::FiberBundleXWriter::GenerateData() { - MITK_INFO << "Writing fiber bundle"; - m_Success = false; - InputType* input = this->GetInput(); - if (input == NULL) + try { - itkWarningMacro(<<"Sorry, input to FiberBundleXWriter is NULL!"); - return; + const std::string& locale = "C"; + const std::string& currLocale = setlocale( LC_ALL, NULL ); + setlocale(LC_ALL, locale.c_str()); + + MITK_INFO << "Writing fiber bundle"; + m_Success = false; + InputType* input = this->GetInput(); + if (input == NULL) + { + itkWarningMacro(<<"Sorry, input to FiberBundleXWriter is NULL!"); + return; + } + if ( m_FileName == "" ) + { + itkWarningMacro( << "Sorry, filename has not been set!" ); + return ; + } + vtkSmartPointer writer = vtkPolyDataWriter::New(); + writer->SetInput(input->GetFiberPolyData()); + writer->SetFileName(m_FileName.c_str()); + writer->SetFileTypeToASCII(); + writer->Write(); + + setlocale(LC_ALL, currLocale.c_str()); + m_Success = true; + MITK_INFO << "Fiber bundle written"; } - if ( m_FileName == "" ) + catch(...) { - itkWarningMacro( << "Sorry, filename has not been set!" ); - return ; + throw; } - -// std::string ext = itksys::SystemTools::GetFilenameLastExtension(m_FileName); -// ext = itksys::SystemTools::LowerCase(ext); - -// if (ext == ".fib") -// { -// /* direct linked includes of mitkFiberBundleX DataStructure */ -// -// mitk::Geometry3D* geometry = input->GetGeometry(); -// -// TiXmlDocument documentXML; -// TiXmlDeclaration* declXML = new TiXmlDeclaration( "1.0", "", "" ); // TODO what to write here? encoding? etc.... -// documentXML.LinkEndChild( declXML ); -// -// TiXmlElement* mainXML = new TiXmlElement(mitk::FiberBundleXWriter::XML_FIBER_BUNDLE_FILE); -// mainXML->SetAttribute(mitk::FiberBundleXWriter::XML_FILE_VERSION, mitk::FiberBundleXWriter::VERSION_STRING); -// documentXML.LinkEndChild(mainXML); -// -// TiXmlElement* geometryXML = new TiXmlElement(mitk::FiberBundleXWriter::XML_GEOMETRY); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_XX, geometry->GetMatrixColumn(0)[0]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_XY, geometry->GetMatrixColumn(0)[1]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_XZ, geometry->GetMatrixColumn(0)[2]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_YX, geometry->GetMatrixColumn(1)[0]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_YY, geometry->GetMatrixColumn(1)[1]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_YZ, geometry->GetMatrixColumn(1)[2]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_ZX, geometry->GetMatrixColumn(2)[0]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_ZY, geometry->GetMatrixColumn(2)[1]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_MATRIX_ZZ, geometry->GetMatrixColumn(2)[2]); -// -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_ORIGIN_X, geometry->GetOrigin()[0]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_ORIGIN_Y, geometry->GetOrigin()[1]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_ORIGIN_Z, geometry->GetOrigin()[2]); -// -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_SPACING_X, geometry->GetSpacing()[0]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_SPACING_Y, geometry->GetSpacing()[1]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_SPACING_Z, geometry->GetSpacing()[2]); -// -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_SIZE_X, input->GetBounds()[0]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_SIZE_Y, input->GetBounds()[1]); -// geometryXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_SIZE_Z, input->GetBounds()[2]); -// -// mainXML->LinkEndChild(geometryXML); -// -// TiXmlElement* FiberBundleXXML = new TiXmlElement(mitk::FiberBundleXWriter::XML_FIBER_BUNDLE); -// FiberBundleXXML->SetAttribute(mitk::FiberBundleXWriter::XML_NUM_FIBERS, tractContainer->size()); -// int numParticles = 0; -// for (int i=0; iSize(); i++) -// { -// ContainerTractType::Pointer tract = tractContainer->GetElement(i); -// TiXmlElement* fiberXML = new TiXmlElement(mitk::FiberBundleXWriter::XML_FIBER); -// fiberXML->SetAttribute(mitk::FiberBundleXWriter::XML_ID, i); -// fiberXML->SetAttribute(mitk::FiberBundleXWriter::XML_NUM_PARTICLES, tract->Size()); -// numParticles += tract->Size(); -// for (int j=0; jSize(); j++) -// { -// TiXmlElement* particleXML = new TiXmlElement(mitk::FiberBundleXWriter::XML_PARTICLE); -// ContainerPointType p = tract->GetElement(j); -// particleXML->SetAttribute(mitk::FiberBundleXWriter::XML_ID, j); -// particleXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_POS_X, p[0]); -// particleXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_POS_Y, p[1]); -// particleXML->SetDoubleAttribute(mitk::FiberBundleXWriter::XML_POS_Z, p[2]); -// fiberXML->LinkEndChild(particleXML); -// } -// FiberBundleXXML->LinkEndChild(fiberXML); -// } -// FiberBundleXXML->SetAttribute(mitk::FiberBundleXWriter::XML_NUM_PARTICLES, numParticles); -// mainXML->LinkEndChild(FiberBundleXXML); -// -// documentXML.SaveFile( m_FileName ); -// -// m_Success = true; -// -// MITK_INFO << "Fiber bundle written"; -// -// }else if (ext == ".vfib" || ext == ".vtk") { -// vtkPolyDataWriter* writer = vtkPolyDataWriter::New(); -// writer->SetInput(input->GeneratePolydata()); -// writer->SetFileName(m_FileName.c_str()); -// writer->SetFileTypeToASCII(); -// writer->Write(); -// -// m_Success = true; -// MITK_INFO << "Fiber bundle written as polydata"; -// } - } void mitk::FiberBundleXWriter::SetInputFiberBundleX( InputType* diffVolumes ) { this->ProcessObject::SetNthInput( 0, diffVolumes ); } mitk::FiberBundleX* mitk::FiberBundleXWriter::GetInput() { if ( this->GetNumberOfInputs() < 1 ) { return NULL; } else { return dynamic_cast ( this->ProcessObject::GetInput( 0 ) ); } } std::vector mitk::FiberBundleXWriter::GetPossibleFileExtensions() { std::vector possibleFileExtensions; possibleFileExtensions.push_back(".fib"); - possibleFileExtensions.push_back(".vfib"); possibleFileExtensions.push_back(".vtk"); return possibleFileExtensions; } diff --git a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.h b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.h index 84a248080b..13a4ebb0c9 100644 --- a/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.h +++ b/Modules/DiffusionImaging/IODataStructures/FiberBundleX/mitkFiberBundleXWriter.h @@ -1,216 +1,216 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2008-08-27 17:18:46 +0200 (Mi, 27 Aug 2008) $ Version: $Revision: 15096 $ 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 __mitkFiberBundleXWriter_h #define __mitkFiberBundleXWriter_h #include #include #include "mitkFiberBundleX.h" #include namespace mitk { /** * Writes fiber bundles to a file * @ingroup Process */ class FiberBundleXWriter : public mitk::FileWriterWithInformation { public: mitkClassMacro( FiberBundleXWriter, mitk::FileWriterWithInformation ); //mitkWriterMacro; virtual void Write() { if ( this->GetInput() == NULL ) { itkExceptionMacro(<<"Write:Please specify an input!"); return; } /* Fill in image information.*/ this->UpdateOutputInformation(); (*(this->GetInputs().begin()))->SetRequestedRegionToLargestPossibleRegion(); this->PropagateRequestedRegion(NULL); this->UpdateOutputData(NULL); } virtual void Update() { Write(); } itkNewMacro( Self ); typedef mitk::FiberBundleX InputType; /** * Sets the filename of the file to write. * @param FileName the name of the file to write. */ itkSetStringMacro( FileName ); /** * @returns the name of the file to be written to disk. */ itkGetStringMacro( FileName ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePrefix ); /** * @warning multiple write not (yet) supported */ itkSetStringMacro( FilePattern ); /** * @warning multiple write not (yet) supported */ itkGetStringMacro( FilePattern ); /** * Sets the input object for the filter. * @param input the diffusion volumes to write to file. */ void SetInputFiberBundleX( InputType* input ); /** * @returns the 0'th input object of the filter. */ InputType* GetInput(); /** * Returns false if an error happened during writing */ itkGetMacro( Success, bool ); /** * @return possible file extensions for the data type associated with the writer */ virtual std::vector GetPossibleFileExtensions(); // FileWriterWithInformation methods - virtual const char * GetDefaultFilename() { return "FiberBundleX.fib"; } - virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.vfib *.vtk)"; } + virtual const char * GetDefaultFilename() { return "FiberBundle.fib"; } + virtual const char * GetFileDialogPattern() { return "Fiber Bundle (*.fib *.vtk)"; } virtual const char * GetDefaultExtension() { return ".fib"; } virtual bool CanWriteBaseDataType(BaseData::Pointer data) { return (dynamic_cast(data.GetPointer()) != NULL); }; virtual void DoWrite(BaseData::Pointer data) { if (CanWriteBaseDataType(data)) { this->SetInputFiberBundleX(dynamic_cast(data.GetPointer())); this->Update(); } }; static const char* XML_GEOMETRY; static const char* XML_MATRIX_XX; static const char* XML_MATRIX_XY; static const char* XML_MATRIX_XZ; static const char* XML_MATRIX_YX; static const char* XML_MATRIX_YY; static const char* XML_MATRIX_YZ; static const char* XML_MATRIX_ZX; static const char* XML_MATRIX_ZY; static const char* XML_MATRIX_ZZ; static const char* XML_ORIGIN_X; static const char* XML_ORIGIN_Y; static const char* XML_ORIGIN_Z; static const char* XML_SPACING_X; static const char* XML_SPACING_Y; static const char* XML_SPACING_Z; static const char* XML_SIZE_X; static const char* XML_SIZE_Y; static const char* XML_SIZE_Z; static const char* XML_FIBER_BUNDLE; static const char* XML_FIBER; static const char* XML_PARTICLE; static const char* XML_ID; static const char* XML_POS_X; static const char* XML_POS_Y; static const char* XML_POS_Z; static const char* VERSION_STRING; static const char* XML_FIBER_BUNDLE_FILE; static const char* XML_FILE_VERSION; static const char* XML_NUM_FIBERS; static const char* XML_NUM_PARTICLES; static const char* ASCII_FILE; static const char* FILE_NAME; protected: FiberBundleXWriter(); virtual ~FiberBundleXWriter(); virtual void GenerateData(); std::string m_FileName; std::string m_FilePrefix; std::string m_FilePattern; bool m_Success; }; } // end of namespace mitk #endif //__mitkFiberBundleXWriter_h diff --git a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp index 86e856ef3c..8ab6c0fa2a 100644 --- a/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp +++ b/Modules/DiffusionImaging/IODataStructures/mitkDiffusionImagingObjectFactory.cpp @@ -1,435 +1,433 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-06-18 15:59:04 +0200 (Do, 18 Jun 2009) $ Version: $Revision: 16916 $ 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. =========================================================================*/ #include "mitkDiffusionImagingObjectFactory.h" #include "mitkProperties.h" #include "mitkBaseRenderer.h" #include "mitkDataNode.h" #include "mitkNrrdDiffusionImageIOFactory.h" #include "mitkNrrdDiffusionImageWriterFactory.h" #include "mitkNrrdDiffusionImageWriter.h" #include "mitkDiffusionImage.h" #include "mitkNrrdQBallImageIOFactory.h" #include "mitkNrrdQBallImageWriterFactory.h" #include "mitkNrrdQBallImageWriter.h" #include "mitkNrrdTensorImageIOFactory.h" #include "mitkNrrdTensorImageWriterFactory.h" #include "mitkNrrdTensorImageWriter.h" #include "mitkCompositeMapper.h" #include "mitkDiffusionImageMapper.h" #include "mitkGPUVolumeMapper3D.h" #include "mitkVolumeDataVtkMapper3D.h" #include "mitkTbssImageMapper.h" #include "mitkTbssGradientImageMapper.h" //====depricated fiberstructure===== #include "mitkFiberBundle.h" #include "mitkFiberBundleMapper2D.h" #include "mitkFiberBundleMapper3D.h" #include "mitkFiberBundleIOFactory.h" #include "mitkFiberBundleWriterFactory.h" #include "mitkFiberBundleWriter.h" //================================== //modernized fiberbundle datastrucutre #include "mitkFiberBundleX.h" #include "mitkFiberBundleXIOFactory.h" #include "mitkFiberBundleXWriterFactory.h" #include "mitkFiberBundleXWriter.h" #include "mitkFiberBundleXMapper3D.h" #include "mitkFiberBundleXMapper2D.h" #include "mitkFiberBundleXThreadMonitorMapper3D.h" #include "mitkFiberBundleXThreadMonitor.h" #include "mitkNrrdTbssImageIOFactory.h" #include "mitkNrrdTbssImageWriterFactory.h" #include "mitkNrrdTbssImageWriter.h" #include "mitkNrrdTbssRoiImageIOFactory.h" #include "mitkNrrdTbssRoiImageWriterFactory.h" #include "mitkNrrdTbssRoiImageWriter.h" #include "mitkNrrdTbssGradientImageWriterFactory.h" #include "mitkNrrdTbssGradientImageWriter.h" #include "mitkPlanarCircleMapper3D.h" #include "mitkPlanarPolygonMapper3D.h" typedef short DiffusionPixelType; typedef char TbssRoiPixelType; typedef float TbssPixelType; typedef int TbssGradientPixelType; typedef mitk::DiffusionImage DiffusionImageShort; typedef std::multimap MultimapType; mitk::DiffusionImagingObjectFactory::DiffusionImagingObjectFactory(bool /*registerSelf*/) :CoreObjectFactoryBase() { static bool alreadyDone = false; if (!alreadyDone) { MITK_DEBUG << "DiffusionImagingObjectFactory c'tor" << std::endl; RegisterIOFactories(); mitk::NrrdDiffusionImageIOFactory::RegisterOneFactory(); mitk::NrrdQBallImageIOFactory::RegisterOneFactory(); mitk::NrrdTensorImageIOFactory::RegisterOneFactory(); mitk::FiberBundleIOFactory::RegisterOneFactory(); mitk::NrrdTbssImageIOFactory::RegisterOneFactory(); mitk::NrrdTbssRoiImageIOFactory::RegisterOneFactory(); mitk::FiberBundleXIOFactory::RegisterOneFactory(); //modernized mitk::NrrdDiffusionImageWriterFactory::RegisterOneFactory(); mitk::NrrdQBallImageWriterFactory::RegisterOneFactory(); mitk::NrrdTensorImageWriterFactory::RegisterOneFactory(); mitk::FiberBundleWriterFactory::RegisterOneFactory(); mitk::NrrdTbssImageWriterFactory::RegisterOneFactory(); mitk::NrrdTbssRoiImageWriterFactory::RegisterOneFactory(); mitk::FiberBundleXWriterFactory::RegisterOneFactory();//modernized mitk::NrrdTbssGradientImageWriterFactory::RegisterOneFactory(); m_FileWriters.push_back( NrrdDiffusionImageWriter::New().GetPointer() ); m_FileWriters.push_back( NrrdQBallImageWriter::New().GetPointer() ); m_FileWriters.push_back( NrrdTensorImageWriter::New().GetPointer() ); m_FileWriters.push_back( mitk::FiberBundleWriter::New().GetPointer() ); m_FileWriters.push_back( NrrdTbssImageWriter::New().GetPointer() ); m_FileWriters.push_back( NrrdTbssRoiImageWriter::New().GetPointer() ); m_FileWriters.push_back( mitk::FiberBundleXWriter::New().GetPointer() );//modernized m_FileWriters.push_back( mitk::NrrdTbssGradientImageWriter::New().GetPointer() ); mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(this); CreateFileExtensionsMap(); alreadyDone = true; } } mitk::Mapper::Pointer mitk::DiffusionImagingObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper=NULL; if ( id == mitk::BaseRenderer::Standard2D ) { std::string classname("QBallImage"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::CompositeMapper::New(); newMapper->SetDataNode(node); node->SetMapper(3, ((CompositeMapper*)newMapper.GetPointer())->GetImageMapper()); } classname = "TensorImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::CompositeMapper::New(); newMapper->SetDataNode(node); node->SetMapper(3, ((CompositeMapper*)newMapper.GetPointer())->GetImageMapper()); } classname = "DiffusionImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::DiffusionImageMapper::New(); newMapper->SetDataNode(node); } classname = "TbssRoiImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::ImageVtkMapper2D::New(); newMapper->SetDataNode(node); } - + classname = "FiberBundle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleMapper2D::New(); newMapper->SetDataNode(node); } - + classname = "FiberBundleX"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleXMapper2D::New(); newMapper->SetDataNode(node); } classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::TbssImageMapper::New(); newMapper->SetDataNode(node); } classname = "TbssGradientImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::TbssGradientImageMapper::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { std::string classname("QBallImage"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::GPUVolumeMapper3D::New(); newMapper->SetDataNode(node); } classname = "TensorImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::GPUVolumeMapper3D::New(); newMapper->SetDataNode(node); } classname = "DiffusionImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::GPUVolumeMapper3D::New(); newMapper->SetDataNode(node); } classname = "FiberBundle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleMapper3D::New(); newMapper->SetDataNode(node); } classname = "FiberBundleX"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleXMapper3D::New(); newMapper->SetDataNode(node); } - + classname = "FiberBundleXThreadMonitor"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleXThreadMonitorMapper3D::New(); - newMapper->SetDataNode(node); + newMapper->SetDataNode(node); } classname = "TbssRoiImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::VolumeDataVtkMapper3D::New(); newMapper->SetDataNode(node); } classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) - { + { newMapper = mitk::TbssImageMapper::New(); newMapper->SetDataNode(node); } - + classname = "PlanarCircle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::PlanarCircleMapper3D::New(); newMapper->SetDataNode(node); } - + classname = "PlanarPolygon"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::PlanarPolygonMapper3D::New(); newMapper->SetDataNode(node); } - + classname = "TbssGradientImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::TbssGradientImageMapper::New(); newMapper->SetDataNode(node); } } return newMapper; } void mitk::DiffusionImagingObjectFactory::SetDefaultProperties(mitk::DataNode* node) { std::string classname = "QBallImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::CompositeMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "TensorImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::CompositeMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "DiffusionImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::DiffusionImageMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "FiberBundle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::FiberBundleMapper3D::SetDefaultProperties(node); mitk::FiberBundleMapper2D::SetDefaultProperties(node); } classname = "FiberBundleX"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::FiberBundleXMapper3D::SetDefaultProperties(node); mitk::FiberBundleXMapper2D::SetDefaultProperties(node); } classname = "FiberBundleXThreadMonitor"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::FiberBundleXThreadMonitorMapper3D::SetDefaultProperties(node); } - + classname = "TbssRoiImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::ImageVtkMapper2D::SetDefaultProperties(node); mitk::VolumeDataVtkMapper3D::SetDefaultProperties(node); } classname = "TbssImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::TbssImageMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } classname = "TbssGradientImage"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::TbssGradientImageMapper::SetDefaultProperties(node); mitk::GPUVolumeMapper3D::SetDefaultProperties(node); } - + classname = "PlanarCircle"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::PlanarCircleMapper3D::SetDefaultProperties(node); } - + classname = "PlanarPolygon"; if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { mitk::PlanarPolygonMapper3D::SetDefaultProperties(node); } } const char* mitk::DiffusionImagingObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::DiffusionImagingObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } const char* mitk::DiffusionImagingObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); }; mitk::CoreObjectFactoryBase::MultimapType mitk::DiffusionImagingObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::DiffusionImagingObjectFactory::CreateFileExtensionsMap() { m_FileExtensionsMap.insert(std::pair("*.dwi", "Diffusion Weighted Images")); m_FileExtensionsMap.insert(std::pair("*.hdwi", "Diffusion Weighted Images")); m_FileExtensionsMap.insert(std::pair("*.nii", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.fsl", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.fslgz", "Diffusion Weighted Images for FSL")); m_FileExtensionsMap.insert(std::pair("*.qbi", "Q-Ball Images")); m_FileExtensionsMap.insert(std::pair("*.hqbi", "Q-Ball Images")); m_FileExtensionsMap.insert(std::pair("*.dti", "Tensor Images")); m_FileExtensionsMap.insert(std::pair("*.hdti", "Tensor Images")); m_FileExtensionsMap.insert(std::pair("*.fib", "Fiber Bundle")); - m_FileExtensionsMap.insert(std::pair("*.vfib", "Fiber Bundle Polydata")); - m_FileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle Polydata")); + m_FileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle")); m_FileExtensionsMap.insert(std::pair("*.tbss", "TBSS data")); m_FileExtensionsMap.insert(std::pair("*.pf", "Planar Figure File")); m_FileExtensionsMap.insert(std::pair("*.roi", "TBSS ROI data")); m_FileExtensionsMap.insert(std::pair("*.tgi", "TBSS gradient image")); m_SaveFileExtensionsMap.insert(std::pair("*.dwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hdwi", "Diffusion Weighted Images")); m_SaveFileExtensionsMap.insert(std::pair("*.nii", "Diffusion Weighted Images for FSL")); m_SaveFileExtensionsMap.insert(std::pair("*.fsl", "Diffusion Weighted Images for FSL")); m_SaveFileExtensionsMap.insert(std::pair("*.fslgz", "Diffusion Weighted Images for FSL")); m_SaveFileExtensionsMap.insert(std::pair("*.qbi", "Q-Ball Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hqbi", "Q-Ball Images")); m_SaveFileExtensionsMap.insert(std::pair("*.dti", "Tensor Images")); m_SaveFileExtensionsMap.insert(std::pair("*.hdti", "Tensor Images")); m_SaveFileExtensionsMap.insert(std::pair("*.fib", "Fiber Bundle")); - m_SaveFileExtensionsMap.insert(std::pair("*.vfib", "Fiber Bundle Polydata")); - m_SaveFileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle Polydata")); + m_SaveFileExtensionsMap.insert(std::pair("*.vtk", "Fiber Bundle")); m_SaveFileExtensionsMap.insert(std::pair("*.tbss", "TBSS data")); m_SaveFileExtensionsMap.insert(std::pair("*.pf", "Planar Figure File")); m_SaveFileExtensionsMap.insert(std::pair("*.roi", "TBSS ROI data")); m_SaveFileExtensionsMap.insert(std::pair("*.tgi", "TBSS gradient image")); } void mitk::DiffusionImagingObjectFactory::RegisterIOFactories() { } void RegisterDiffusionImagingObjectFactory() { static bool oneDiffusionImagingObjectFactoryRegistered = false; if ( ! oneDiffusionImagingObjectFactoryRegistered ) { MITK_DEBUG << "Registering DiffusionImagingObjectFactory..." << std::endl; mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(mitk::DiffusionImagingObjectFactory::New()); oneDiffusionImagingObjectFactoryRegistered = true; } }