diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper2D.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper2D.cpp index fd84df0658..77f4934755 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper2D.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper2D.cpp @@ -1,212 +1,214 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ /* * mitkFiberBundleMapper2D.cpp * mitk-all * * Created by HAL9000 on 1/17/11. * Copyright 2011 __MyCompanyName__. All rights reserved. * */ #include "mitkFiberBundleXMapper2D.h" #include #include #include #include #include +#include //#include //#include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include mitk::FiberBundleXMapper2D::FiberBundleXMapper2D() { m_lut = vtkLookupTable::New(); m_lut->Build(); } mitk::FiberBundleXMapper2D::~FiberBundleXMapper2D() { } mitk::FiberBundleX* mitk::FiberBundleXMapper2D::GetInput() { return dynamic_cast< mitk::FiberBundleX * > ( GetDataNode()->GetData() ); } void mitk::FiberBundleXMapper2D::Update(mitk::BaseRenderer * renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if ( !visible ) return; // Calculate time step of the input data for the specified renderer (integer value) // this method is implemented in mitkMapper this->CalculateTimeStep( renderer ); //check if updates occured in the node or on the display FBXLocalStorage *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); //set renderer independent shader properties const DataNode::Pointer node = this->GetDataNode(); float thickness = 2.0; if(!this->GetDataNode()->GetPropertyValue("Fiber2DSliceThickness",thickness)) MITK_INFO << "FIBER2D SLICE THICKNESS PROPERTY ERROR"; bool fiberfading = false; if(!this->GetDataNode()->GetPropertyValue("Fiber2DfadeEFX",fiberfading)) MITK_INFO << "FIBER2D SLICE FADE EFX PROPERTY ERROR"; float fiberOpacity; this->GetDataNode()->GetOpacity(fiberOpacity, NULL); node->SetFloatProperty("shader.mitkShaderFiberClipping.fiberThickness",thickness); node->SetIntProperty("shader.mitkShaderFiberClipping.fiberFadingON",fiberfading); node->SetFloatProperty("shader.mitkShaderFiberClipping.fiberOpacity",fiberOpacity); mitk::FiberBundleX* fiberBundle = this->GetInput(); if (fiberBundle==NULL) return; if ( localStorage->m_LastUpdateTimeGetDisplayGeometry()->GetMTime() || localStorage->m_LastUpdateTimeGetUpdateTime2D() ) { this->UpdateShaderParameter(renderer); this->GenerateDataForRenderer( renderer ); } } void mitk::FiberBundleXMapper2D::UpdateShaderParameter(mitk::BaseRenderer * renderer) { //get information about current position of views mitk::SliceNavigationController::Pointer sliceContr = renderer->GetSliceNavigationController(); mitk::PlaneGeometry::ConstPointer planeGeo = sliceContr->GetCurrentPlaneGeometry(); //generate according cutting planes based on the view position float planeNormal[3]; planeNormal[0] = planeGeo->GetNormal()[0]; planeNormal[1] = planeGeo->GetNormal()[1]; planeNormal[2] = planeGeo->GetNormal()[2]; float tmp1 = planeGeo->GetOrigin()[0] * planeNormal[0]; float tmp2 = planeGeo->GetOrigin()[1] * planeNormal[1]; float tmp3 = planeGeo->GetOrigin()[2] * planeNormal[2]; float thickness = tmp1 + tmp2 + tmp3; //attention, correct normalvector DataNode::Pointer node = this->GetDataNode(); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.w",thickness,renderer); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.x",planeNormal[0],renderer); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.y",planeNormal[1],renderer); node->SetFloatProperty("shader.mitkShaderFiberClipping.slicingPlane.z",planeNormal[2],renderer); } // vtkActors and Mappers are feeded here void mitk::FiberBundleXMapper2D::GenerateDataForRenderer(mitk::BaseRenderer *renderer) { mitk::FiberBundleX* fiberBundle = this->GetInput(); //the handler of local storage gets feeded in this method with requested data for related renderwindow FBXLocalStorage *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); mitk::DataNode* node = this->GetDataNode(); if ( node == NULL ) return; + vtkSmartPointer fiberPolyData = fiberBundle->GetFiberPolyData(); + if (fiberPolyData == NULL) + return; + + fiberPolyData->GetPointData()->AddArray(fiberBundle->GetFiberColors()); localStorage->m_FiberMapper->ScalarVisibilityOn(); localStorage->m_FiberMapper->SetScalarModeToUsePointFieldData(); localStorage->m_FiberMapper->SetLookupTable(m_lut); //apply the properties after the slice was set localStorage->m_PointActor->GetProperty()->SetOpacity(0.999); + localStorage->m_FiberMapper->SelectColorArray("FIBER_COLORS"); - // set color - if (fiberBundle->GetCurrentColorCoding() != NULL) - { - localStorage->m_FiberMapper->SelectColorArray(fiberBundle->GetCurrentColorCoding()); +// if(fiberBundle->GetCurrentColorCoding() == fiberBundle->COLORCODING_CUSTOM){ +// float temprgb[3]; +// this->GetDataNode()->GetColor( temprgb, NULL ); +// double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; +// localStorage->m_PointActor->GetProperty()->SetColor(trgb); +// } - if(fiberBundle->GetCurrentColorCoding() == fiberBundle->COLORCODING_CUSTOM){ - float temprgb[3]; - this->GetDataNode()->GetColor( temprgb, NULL ); - double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; - localStorage->m_PointActor->GetProperty()->SetColor(trgb); - } - } int lineWidth = 1; node->GetIntProperty("LineWidth",lineWidth); - localStorage->m_FiberMapper->SetInputData(fiberBundle->GetFiberPolyData()); + localStorage->m_FiberMapper->SetInputData(fiberPolyData); localStorage->m_PointActor->SetMapper(localStorage->m_FiberMapper); localStorage->m_PointActor->GetProperty()->ShadingOn(); localStorage->m_PointActor->GetProperty()->SetLineWidth(lineWidth); // Applying shading properties this->ApplyShaderProperties(renderer); // We have been modified => save this for next Update() localStorage->m_LastUpdateTime.Modified(); } vtkProp* mitk::FiberBundleXMapper2D::GetVtkProp(mitk::BaseRenderer *renderer) { this->Update(renderer); return m_LocalStorageHandler.GetLocalStorage(renderer)->m_PointActor; } void mitk::FiberBundleXMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { + Superclass::SetDefaultProperties(node, renderer, overwrite); node->SetProperty("shader",mitk::ShaderProperty::New("mitkShaderFiberClipping")); // Shaders IShaderRepository* shaderRepo = CoreServices::GetShaderRepository(); if (shaderRepo) { shaderRepo->AddDefaultProperties(node, renderer, overwrite); } //add other parameters to propertylist - node->AddProperty( "Fiber2DSliceThickness", mitk::FloatProperty::New(2.0f), renderer, overwrite ); + node->AddProperty( "Fiber2DSliceThickness", mitk::FloatProperty::New(1.0f), renderer, overwrite ); node->AddProperty( "Fiber2DfadeEFX", mitk::BoolProperty::New(true), renderer, overwrite ); - - Superclass::SetDefaultProperties(node, renderer, overwrite); + node->AddProperty( "color", mitk::ColorProperty::New(1.0,1.0,1.0), renderer, overwrite); } mitk::FiberBundleXMapper2D::FBXLocalStorage::FBXLocalStorage() { m_PointActor = vtkSmartPointer::New(); m_FiberMapper = vtkSmartPointer::New(); } diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper3D.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper3D.cpp index caea82c3a1..31aa03a47a 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper3D.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXMapper3D.cpp @@ -1,168 +1,142 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkFiberBundleXMapper3D.h" #include //#include //#include #include #include #include #include //not essential for mapper // #include mitk::FiberBundleXMapper3D::FiberBundleXMapper3D() { m_lut = vtkLookupTable::New(); m_lut->Build(); } mitk::FiberBundleXMapper3D::~FiberBundleXMapper3D() { } const mitk::FiberBundleX* mitk::FiberBundleXMapper3D::GetInput() { return static_cast ( GetDataNode()->GetData() ); } /* This method is called once the mapper gets new input, for UI rotation or changes in colorcoding this method is NOT called */ void mitk::FiberBundleXMapper3D::InternalGenerateData(mitk::BaseRenderer *renderer) { mitk::FiberBundleX* fiberBundle = dynamic_cast (GetDataNode()->GetData()); if (fiberBundle == NULL) return; vtkSmartPointer fiberPolyData = fiberBundle->GetFiberPolyData(); if (fiberPolyData == NULL) return; FBXLocalStorage3D *localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); - localStorage->m_FiberMapper->SetInputData(fiberPolyData); - - if ( fiberPolyData->GetPointData()->GetNumberOfArrays() > 0 ) - localStorage->m_FiberMapper->SelectColorArray( fiberBundle->GetCurrentColorCoding() ); + float tmpopa; + this->GetDataNode()->GetOpacity(tmpopa, NULL); + fiberPolyData->GetPointData()->AddArray(fiberBundle->GetFiberColors()); + localStorage->m_FiberMapper->SetInputData(fiberPolyData); + localStorage->m_FiberMapper->SelectColorArray("FIBER_COLORS"); localStorage->m_FiberMapper->ScalarVisibilityOn(); localStorage->m_FiberMapper->SetScalarModeToUsePointFieldData(); localStorage->m_FiberActor->SetMapper(localStorage->m_FiberMapper); localStorage->m_FiberMapper->SetLookupTable(m_lut); // set Opacity - float tmpopa; - this->GetDataNode()->GetOpacity(tmpopa, NULL); localStorage->m_FiberActor->GetProperty()->SetOpacity((double) tmpopa); int lineWidth = 1; this->GetDataNode()->GetIntProperty("LineWidth",lineWidth); localStorage->m_FiberActor->GetProperty()->SetLineWidth(lineWidth); - // set color - if (fiberBundle->GetCurrentColorCoding() != NULL){ - // localStorage->m_FiberMapper->SelectColorArray(""); - localStorage->m_FiberMapper->SelectColorArray(fiberBundle->GetCurrentColorCoding()); - MITK_DEBUG << "MapperFBX: " << fiberBundle->GetCurrentColorCoding(); - - if(fiberBundle->GetCurrentColorCoding() == fiberBundle->COLORCODING_CUSTOM) { - float temprgb[3]; - this->GetDataNode()->GetColor( temprgb, NULL ); - double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; - localStorage->m_FiberActor->GetProperty()->SetColor(trgb); - } - } - localStorage->m_FiberAssembly->AddPart(localStorage->m_FiberActor); localStorage->m_LastUpdateTime.Modified(); } void mitk::FiberBundleXMapper3D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if ( !visible ) return; const DataNode* node = this->GetDataNode(); FBXLocalStorage3D* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); mitk::FiberBundleX* fiberBundle = dynamic_cast(node->GetData()); if (localStorage->m_LastUpdateTime>=fiberBundle->GetUpdateTime3D()) return; // Calculate time step of the input data for the specified renderer (integer value) // this method is implemented in mitkMapper this->CalculateTimeStep( renderer ); this->InternalGenerateData(renderer); } void mitk::FiberBundleXMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { - // node->AddProperty( "DisplayChannel", mitk::IntProperty::New( true ), renderer, overwrite ); + Superclass::SetDefaultProperties(node, renderer, overwrite); node->AddProperty( "LineWidth", mitk::IntProperty::New( true ), renderer, overwrite ); node->AddProperty( "opacity", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); - // node->AddProperty( "VertexOpacity_1", mitk::BoolProperty::New( false ), renderer, overwrite); - // node->AddProperty( "Set_FA_VertexAlpha", mitk::BoolProperty::New( false ), renderer, overwrite); - // node->AddProperty( "pointSize", mitk::FloatProperty::New(0.5), renderer, overwrite); - // node->AddProperty( "setShading", mitk::IntProperty::New(1), renderer, overwrite); - // node->AddProperty( "Xmove", mitk::IntProperty::New( 0 ), renderer, overwrite); - // node->AddProperty( "Ymove", mitk::IntProperty::New( 0 ), renderer, overwrite); - // node->AddProperty( "Zmove", mitk::IntProperty::New( 0 ), renderer, overwrite); - // node->AddProperty( "RepPoints", mitk::BoolProperty::New( false ), renderer, overwrite); - // node->AddProperty( "TubeSides", mitk::IntProperty::New( 8 ), renderer, overwrite); - // node->AddProperty( "TubeRadius", mitk::FloatProperty::New( 0.15 ), renderer, overwrite); - // node->AddProperty( "TubeOpacity", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); + node->AddProperty( "color", mitk::ColorProperty::New(1.0,1.0,1.0), renderer, overwrite); node->AddProperty( "pickable", mitk::BoolProperty::New( true ), renderer, overwrite); - Superclass::SetDefaultProperties(node, renderer, overwrite); } vtkProp* mitk::FiberBundleXMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) { //MITK_INFO << "FiberBundleXxXXMapper3D()GetVTKProp"; //this->GenerateData(); return m_LocalStorageHandler.GetLocalStorage(renderer)->m_FiberAssembly; } void mitk::FiberBundleXMapper3D::UpdateVtkObjects() { } void mitk::FiberBundleXMapper3D::SetVtkMapperImmediateModeRendering(vtkMapper *) { } mitk::FiberBundleXMapper3D::FBXLocalStorage3D::FBXLocalStorage3D() { m_FiberActor = vtkSmartPointer::New(); m_FiberMapper = vtkSmartPointer::New(); m_FiberAssembly = vtkSmartPointer::New(); } diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXReader.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXReader.cpp index 5a5e8e6104..ce9807f8a8 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXReader.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXReader.cpp @@ -1,215 +1,229 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkFiberBundleXReader.h" #include #include #include #include #include #include #include #include #include #include +#include #include #include #include #include #include #include "mitkDiffusionIOMimeTypes.h" mitk::FiberBundleXReader::FiberBundleXReader() : mitk::AbstractFileReader( CustomMimeType( mitk::DiffusionIOMimeTypes::FIBERBUNDLE_MIMETYPE_NAME() ), mitk::DiffusionIOMimeTypes::FIBERBUNDLE_MIMETYPE_DESCRIPTION() ) { m_ServiceReg = this->RegisterService(); } mitk::FiberBundleXReader::FiberBundleXReader(const FiberBundleXReader &other) :mitk::AbstractFileReader(other) { } mitk::FiberBundleXReader * mitk::FiberBundleXReader::Clone() const { return new FiberBundleXReader(*this); } std::vector > mitk::FiberBundleXReader::Read() { std::vector > result; try { const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); setlocale(LC_ALL, locale.c_str()); std::string filename = this->GetInputLocation(); std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename); ext = itksys::SystemTools::LowerCase(ext); if (ext==".trk") { FiberBundleX::Pointer image = FiberBundleX::New(); TrackVisFiberReader reader; reader.open(this->GetInputLocation().c_str()); reader.read(image.GetPointer()); result.push_back(image.GetPointer()); return result; } vtkSmartPointer chooser=vtkSmartPointer::New(); chooser->SetFileName( this->GetInputLocation().c_str() ); if( chooser->IsFilePolyData()) { vtkSmartPointer reader = vtkSmartPointer::New(); reader->SetFileName( this->GetInputLocation().c_str() ); reader->Update(); if ( reader->GetOutput() != NULL ) { vtkSmartPointer fiberPolyData = reader->GetOutput(); FiberBundleX::Pointer fiberBundle = FiberBundleX::New(fiberPolyData); vtkSmartPointer weights = vtkFloatArray::SafeDownCast(fiberPolyData->GetCellData()->GetArray("FIBER_WEIGHTS")); if (weights!=NULL) + { +// float weight=0; +// for (int i=0; iGetSize(); i++) +// if (!mitk::Equal(weights->GetValue(i),weight,0.00001)) +// { +// MITK_INFO << "Weight: " << weights->GetValue(i); +// weight = weights->GetValue(i); +// } fiberBundle->SetFiberWeights(weights); + } + + vtkSmartPointer fiberColors = vtkUnsignedCharArray::SafeDownCast(fiberPolyData->GetPointData()->GetArray("FIBER_COLORS")); + if (fiberColors!=NULL) + fiberBundle->SetFiberColors(fiberColors); result.push_back(fiberBundle.GetPointer()); return result; } } else // try to read deprecated fiber bundle file format { MITK_INFO << "Reading xml fiber bundle"; vtkSmartPointer fiberPolyData = vtkSmartPointer::New(); vtkSmartPointer cellArray = vtkSmartPointer::New(); vtkSmartPointer points = vtkSmartPointer::New(); TiXmlDocument doc( this->GetInputLocation().c_str() ); if(doc.LoadFile()) { TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); pElem = hDoc.FirstChildElement().Element(); // save this for later hRoot = TiXmlHandle(pElem); pElem = hRoot.FirstChildElement("geometry").Element(); // read geometry mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); // read origin mitk::Point3D origin; double temp = 0; pElem->Attribute("origin_x", &temp); origin[0] = temp; pElem->Attribute("origin_y", &temp); origin[1] = temp; pElem->Attribute("origin_z", &temp); origin[2] = temp; geometry->SetOrigin(origin); // read spacing ScalarType spacing[3]; pElem->Attribute("spacing_x", &temp); spacing[0] = temp; pElem->Attribute("spacing_y", &temp); spacing[1] = temp; pElem->Attribute("spacing_z", &temp); spacing[2] = temp; geometry->SetSpacing(spacing); // read transform vtkMatrix4x4* m = vtkMatrix4x4::New(); pElem->Attribute("xx", &temp); m->SetElement(0,0,temp); pElem->Attribute("xy", &temp); m->SetElement(1,0,temp); pElem->Attribute("xz", &temp); m->SetElement(2,0,temp); pElem->Attribute("yx", &temp); m->SetElement(0,1,temp); pElem->Attribute("yy", &temp); m->SetElement(1,1,temp); pElem->Attribute("yz", &temp); m->SetElement(2,1,temp); pElem->Attribute("zx", &temp); m->SetElement(0,2,temp); pElem->Attribute("zy", &temp); m->SetElement(1,2,temp); pElem->Attribute("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("size_x", &temp); bounds[1] = temp; pElem->Attribute("size_y", &temp); bounds[3] = temp; pElem->Attribute("size_z", &temp); bounds[5] = temp; geometry->SetFloatBounds(bounds); geometry->SetImageGeometry(true); pElem = hRoot.FirstChildElement("fiber_bundle").FirstChild().Element(); for( ; pElem ; pElem=pElem->NextSiblingElement()) { TiXmlElement* pElem2 = pElem->FirstChildElement(); vtkSmartPointer container = vtkSmartPointer::New(); for( ; pElem2; pElem2=pElem2->NextSiblingElement()) { Point3D point; pElem2->Attribute("pos_x", &temp); point[0] = temp; pElem2->Attribute("pos_y", &temp); point[1] = temp; pElem2->Attribute("pos_z", &temp); point[2] = temp; geometry->IndexToWorld(point, point); vtkIdType id = points->InsertNextPoint(point.GetDataPointer()); container->GetPointIds()->InsertNextId(id); } cellArray->InsertNextCell(container); } fiberPolyData->SetPoints(points); fiberPolyData->SetLines(cellArray); vtkSmartPointer cleaner = vtkSmartPointer::New(); cleaner->SetInputData(fiberPolyData); cleaner->Update(); fiberPolyData = cleaner->GetOutput(); FiberBundleX::Pointer image = FiberBundleX::New(fiberPolyData); result.push_back(image.GetPointer()); return result; } else { MITK_ERROR << "could not open xml file"; throw "could not open xml file"; } } setlocale(LC_ALL, currLocale.c_str()); MITK_INFO << "Fiber bundle read"; } catch(...) { throw; } return result; } diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXWriter.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXWriter.cpp index f09d14a415..0bc4d06310 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXWriter.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberBundleXWriter.cpp @@ -1,139 +1,139 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkFiberBundleXWriter.h" #include #include #include #include #include #include #include +#include #include #include #include "mitkDiffusionIOMimeTypes.h" mitk::FiberBundleXWriter::FiberBundleXWriter() : mitk::AbstractFileWriter(mitk::FiberBundleX::GetStaticNameOfClass(), CustomMimeType( mitk::DiffusionIOMimeTypes::FIBERBUNDLE_MIMETYPE_NAME() ), mitk::DiffusionIOMimeTypes::FIBERBUNDLE_MIMETYPE_DESCRIPTION()) { RegisterService(); } mitk::FiberBundleXWriter::FiberBundleXWriter(const mitk::FiberBundleXWriter & other) :mitk::AbstractFileWriter(other) {} mitk::FiberBundleXWriter::~FiberBundleXWriter() {} mitk::FiberBundleXWriter * mitk::FiberBundleXWriter::Clone() const { return new mitk::FiberBundleXWriter(*this); } void mitk::FiberBundleXWriter::Write() { std::ostream* out; std::ofstream outStream; if( this->GetOutputStream() ) { out = this->GetOutputStream(); }else{ outStream.open( this->GetOutputLocation().c_str() ); out = &outStream; } if ( !out->good() ) { mitkThrow() << "Stream not good."; } try { const std::string& locale = "C"; const std::string& currLocale = setlocale( LC_ALL, NULL ); setlocale(LC_ALL, locale.c_str()); std::locale previousLocale(out->getloc()); std::locale I("C"); out->imbue(I); std::string filename = this->GetOutputLocation().c_str(); mitk::FiberBundleX::ConstPointer input = dynamic_cast(this->GetInput()); std::string ext = itksys::SystemTools::GetFilenameLastExtension(this->GetOutputLocation().c_str()); vtkSmartPointer fibPoly = input->GetFiberPolyData(); - - vtkSmartPointer weights = input->GetFiberWeights(); fibPoly->GetCellData()->AddArray(input->GetFiberWeights()); + fibPoly->GetPointData()->AddArray(input->GetFiberColors()); // default extension is .fib if(ext == "") { ext = ".fib"; this->SetOutputLocation(this->GetOutputLocation() + ext); } if (ext==".fib" || ext==".vtk") { MITK_INFO << "Writing fiber bundle as binary VTK"; vtkSmartPointer writer = vtkSmartPointer::New(); writer->SetInputData(fibPoly); writer->SetFileName(filename.c_str()); writer->SetFileTypeToBinary(); writer->Write(); } else if (ext==".afib") { itksys::SystemTools::ReplaceString(filename,".afib",".fib"); MITK_INFO << "Writing fiber bundle as ascii VTK"; vtkSmartPointer writer = vtkSmartPointer::New(); writer->SetInputData(fibPoly); writer->SetFileName(filename.c_str()); writer->SetFileTypeToASCII(); writer->Write(); } else if (ext==".avtk") { itksys::SystemTools::ReplaceString(filename,".avtk",".vtk"); MITK_INFO << "Writing fiber bundle as ascii VTK"; vtkSmartPointer writer = vtkSmartPointer::New(); writer->SetInputData(fibPoly); writer->SetFileName(filename.c_str()); writer->SetFileTypeToASCII(); writer->Write(); } else if (ext==".trk") { MITK_INFO << "Writing fiber bundle as TRK"; TrackVisFiberReader trk; trk.create(filename, input.GetPointer()); trk.writeHdr(); trk.append(input.GetPointer()); } setlocale(LC_ALL, currLocale.c_str()); MITK_INFO << "Fiber bundle written"; } catch(...) { throw; } } diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkFiberTrackingObjectFactory.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkFiberTrackingObjectFactory.cpp index cf8846e1fa..cb78e2f291 100644 --- a/Modules/DiffusionImaging/DiffusionIO/mitkFiberTrackingObjectFactory.cpp +++ b/Modules/DiffusionImaging/DiffusionIO/mitkFiberTrackingObjectFactory.cpp @@ -1,127 +1,114 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkFiberTrackingObjectFactory.h" mitk::FiberTrackingObjectFactory::FiberTrackingObjectFactory() : CoreObjectFactoryBase() { } mitk::FiberTrackingObjectFactory::~FiberTrackingObjectFactory() { } mitk::Mapper::Pointer mitk::FiberTrackingObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId id) { mitk::Mapper::Pointer newMapper=NULL; if ( id == mitk::BaseRenderer::Standard2D ) { std::string classname("FiberBundleX"); if(node->GetData() && classname.compare(node->GetData()->GetNameOfClass())==0) { newMapper = mitk::FiberBundleXMapper2D::New(); newMapper->SetDataNode(node); } } else if ( id == mitk::BaseRenderer::Standard3D ) { std::string 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); -// } } return newMapper; } void mitk::FiberTrackingObjectFactory::SetDefaultProperties(mitk::DataNode* node) { std::string 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); -// } } const char* mitk::FiberTrackingObjectFactory::GetFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_FileExtensionsMap, fileExtension); return fileExtension.c_str(); } mitk::CoreObjectFactoryBase::MultimapType mitk::FiberTrackingObjectFactory::GetFileExtensionsMap() { return m_FileExtensionsMap; } const char* mitk::FiberTrackingObjectFactory::GetSaveFileExtensions() { std::string fileExtension; this->CreateFileExtensions(m_SaveFileExtensionsMap, fileExtension); return fileExtension.c_str(); } mitk::CoreObjectFactoryBase::MultimapType mitk::FiberTrackingObjectFactory::GetSaveFileExtensionsMap() { return m_SaveFileExtensionsMap; } void mitk::FiberTrackingObjectFactory::CreateFileExtensionsMap() { } void mitk::FiberTrackingObjectFactory::RegisterIOFactories() { } struct RegisterFiberTrackingObjectFactory{ RegisterFiberTrackingObjectFactory() : m_Factory( mitk::FiberTrackingObjectFactory::New() ) { mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory( m_Factory ); } ~RegisterFiberTrackingObjectFactory() { mitk::CoreObjectFactory::GetInstance()->UnRegisterExtraFactory( m_Factory ); } mitk::FiberTrackingObjectFactory::Pointer m_Factory; }; static RegisterFiberTrackingObjectFactory registerFiberTrackingObjectFactory; diff --git a/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractDensityImageFilter.cpp b/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractDensityImageFilter.cpp index a335f48b56..13df693a5d 100644 --- a/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractDensityImageFilter.cpp +++ b/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractDensityImageFilter.cpp @@ -1,247 +1,248 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Coindex[1]right (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "itkTractDensityImageFilter.h" // VTK #include #include #include #include // misc #include #include namespace itk{ template< class OutputImageType > TractDensityImageFilter< OutputImageType >::TractDensityImageFilter() : m_InvertImage(false) , m_FiberBundle(NULL) , m_UpsamplingFactor(1) , m_InputImage(NULL) , m_BinaryOutput(false) , m_UseImageGeometry(false) , m_OutputAbsoluteValues(false) , m_UseTrilinearInterpolation(false) + , m_DoFiberResampling(true) { } template< class OutputImageType > TractDensityImageFilter< OutputImageType >::~TractDensityImageFilter() { } template< class OutputImageType > itk::Point TractDensityImageFilter< OutputImageType >::GetItkPoint(double point[3]) { itk::Point itkPoint; itkPoint[0] = point[0]; itkPoint[1] = point[1]; itkPoint[2] = point[2]; return itkPoint; } template< class OutputImageType > void TractDensityImageFilter< OutputImageType >::GenerateData() { // generate upsampled image mitk::BaseGeometry::Pointer geometry = m_FiberBundle->GetGeometry(); typename OutputImageType::Pointer outImage = this->GetOutput(); // calculate new image parameters itk::Vector newSpacing; mitk::Point3D newOrigin; itk::Matrix newDirection; ImageRegion<3> upsampledRegion; if (m_UseImageGeometry && !m_InputImage.IsNull()) { MITK_INFO << "TractDensityImageFilter: using image geometry"; newSpacing = m_InputImage->GetSpacing()/m_UpsamplingFactor; upsampledRegion = m_InputImage->GetLargestPossibleRegion(); newOrigin = m_InputImage->GetOrigin(); typename OutputImageType::RegionType::SizeType size = upsampledRegion.GetSize(); size[0] *= m_UpsamplingFactor; size[1] *= m_UpsamplingFactor; size[2] *= m_UpsamplingFactor; upsampledRegion.SetSize(size); newDirection = m_InputImage->GetDirection(); } else { MITK_INFO << "TractDensityImageFilter: using fiber bundle geometry"; newSpacing = geometry->GetSpacing()/m_UpsamplingFactor; newOrigin = geometry->GetOrigin(); mitk::Geometry3D::BoundsArrayType bounds = geometry->GetBounds(); newOrigin[0] += bounds.GetElement(0); newOrigin[1] += bounds.GetElement(2); newOrigin[2] += bounds.GetElement(4); for (int i=0; i<3; i++) for (int j=0; j<3; j++) newDirection[j][i] = geometry->GetMatrixColumn(i)[j]; upsampledRegion.SetSize(0, geometry->GetExtent(0)*m_UpsamplingFactor); upsampledRegion.SetSize(1, geometry->GetExtent(1)*m_UpsamplingFactor); upsampledRegion.SetSize(2, geometry->GetExtent(2)*m_UpsamplingFactor); } typename OutputImageType::RegionType::SizeType upsampledSize = upsampledRegion.GetSize(); // apply new image parameters outImage->SetSpacing( newSpacing ); outImage->SetOrigin( newOrigin ); outImage->SetDirection( newDirection ); outImage->SetLargestPossibleRegion( upsampledRegion ); outImage->SetBufferedRegion( upsampledRegion ); outImage->SetRequestedRegion( upsampledRegion ); outImage->Allocate(); outImage->FillBuffer(0.0); int w = upsampledSize[0]; int h = upsampledSize[1]; int d = upsampledSize[2]; // set/initialize output OutPixelType* outImageBufferPointer = (OutPixelType*)outImage->GetBufferPointer(); // resample fiber bundle float minSpacing = 1; if(newSpacing[0]GetDeepCopy(); - m_FiberBundle->ResampleSpline(minSpacing/10); + if (m_DoFiberResampling) + { + m_FiberBundle = m_FiberBundle->GetDeepCopy(); + m_FiberBundle->ResampleSpline(minSpacing/10); + } MITK_INFO << "TractDensityImageFilter: starting image generation"; vtkSmartPointer fiberPolyData = m_FiberBundle->GetFiberPolyData(); vtkSmartPointer vLines = fiberPolyData->GetLines(); vLines->InitTraversal(); int numFibers = m_FiberBundle->GetNumFibers(); boost::progress_display disp(numFibers); for( int i=0; iGetNextCell ( numPoints, points ); float weight = m_FiberBundle->GetFiberWeight(i); - MITK_INFO << weight; // fill output image for( int j=0; j vertex = GetItkPoint(fiberPolyData->GetPoint(points[j])); itk::Index<3> index; itk::ContinuousIndex contIndex; outImage->TransformPhysicalPointToIndex(vertex, index); outImage->TransformPhysicalPointToContinuousIndex(vertex, contIndex); if (!m_UseTrilinearInterpolation && outImage->GetLargestPossibleRegion().IsInside(index)) { if (m_BinaryOutput) outImage->SetPixel(index, 1); else outImage->SetPixel(index, outImage->GetPixel(index)+0.01*weight); continue; } float frac_x = contIndex[0] - index[0]; float frac_y = contIndex[1] - index[1]; float frac_z = contIndex[2] - index[2]; if (frac_x<0) { index[0] -= 1; frac_x += 1; } if (frac_y<0) { index[1] -= 1; frac_y += 1; } if (frac_z<0) { index[2] -= 1; frac_z += 1; } frac_x = 1-frac_x; frac_y = 1-frac_y; frac_z = 1-frac_z; // int coordinates inside image? if (index[0] < 0 || index[0] >= w-1) continue; if (index[1] < 0 || index[1] >= h-1) continue; if (index[2] < 0 || index[2] >= d-1) continue; if (m_BinaryOutput) { outImageBufferPointer[( index[0] + w*(index[1] + h*index[2] ))] = 1; outImageBufferPointer[( index[0] + w*(index[1]+1+ h*index[2] ))] = 1; outImageBufferPointer[( index[0] + w*(index[1] + h*index[2]+h))] = 1; outImageBufferPointer[( index[0] + w*(index[1]+1+ h*index[2]+h))] = 1; outImageBufferPointer[( index[0]+1 + w*(index[1] + h*index[2] ))] = 1; outImageBufferPointer[( index[0]+1 + w*(index[1] + h*index[2]+h))] = 1; outImageBufferPointer[( index[0]+1 + w*(index[1]+1+ h*index[2] ))] = 1; outImageBufferPointer[( index[0]+1 + w*(index[1]+1+ h*index[2]+h))] = 1; } else { outImageBufferPointer[( index[0] + w*(index[1] + h*index[2] ))] += ( frac_x)*( frac_y)*( frac_z); outImageBufferPointer[( index[0] + w*(index[1]+1+ h*index[2] ))] += ( frac_x)*(1-frac_y)*( frac_z); outImageBufferPointer[( index[0] + w*(index[1] + h*index[2]+h))] += ( frac_x)*( frac_y)*(1-frac_z); outImageBufferPointer[( index[0] + w*(index[1]+1+ h*index[2]+h))] += ( frac_x)*(1-frac_y)*(1-frac_z); outImageBufferPointer[( index[0]+1 + w*(index[1] + h*index[2] ))] += (1-frac_x)*( frac_y)*( frac_z); outImageBufferPointer[( index[0]+1 + w*(index[1] + h*index[2]+h))] += (1-frac_x)*( frac_y)*(1-frac_z); outImageBufferPointer[( index[0]+1 + w*(index[1]+1+ h*index[2] ))] += (1-frac_x)*(1-frac_y)*( frac_z); outImageBufferPointer[( index[0]+1 + w*(index[1]+1+ h*index[2]+h))] += (1-frac_x)*(1-frac_y)*(1-frac_z); } } } if (!m_OutputAbsoluteValues && !m_BinaryOutput) { MITK_INFO << "TractDensityImageFilter: max-normalizing output image"; OutPixelType max = 0; for (int i=0; i0) for (int i=0; i0 && outImageBufferPointer[i]<0.2) -// outImageBufferPointer[i] = 0.2; } } if (m_InvertImage) { MITK_INFO << "TractDensityImageFilter: inverting image"; for (int i=0; i #include #include #include #include namespace itk{ /** * \brief Generates tract density images from input fiberbundles (Calamante 2010). */ template< class OutputImageType > class TractDensityImageFilter : public ImageSource< OutputImageType > { public: typedef TractDensityImageFilter Self; typedef ProcessObject Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; typedef typename OutputImageType::PixelType OutPixelType; itkFactorylessNewMacro(Self) itkCloneMacro(Self) itkTypeMacro( TractDensityImageFilter, ImageSource ) itkSetMacro( UpsamplingFactor, float) ///< use higher resolution for ouput image itkGetMacro( UpsamplingFactor, float) ///< use higher resolution for ouput image itkSetMacro( InvertImage, bool) ///< voxelvalue = 1-voxelvalue itkGetMacro( InvertImage, bool) ///< voxelvalue = 1-voxelvalue itkSetMacro( BinaryOutput, bool) ///< generate binary fiber envelope itkGetMacro( BinaryOutput, bool) ///< generate binary fiber envelope itkSetMacro( OutputAbsoluteValues, bool) ///< output absolute values of the number of fibers per voxel itkGetMacro( OutputAbsoluteValues, bool) ///< output absolute values of the number of fibers per voxel itkSetMacro( UseImageGeometry, bool) ///< use input image geometry to initialize output image itkGetMacro( UseImageGeometry, bool) ///< use input image geometry to initialize output image itkSetMacro( FiberBundle, mitk::FiberBundleX::Pointer) ///< input fiber bundle itkSetMacro( InputImage, typename OutputImageType::Pointer) ///< use input image geometry to initialize output image itkSetMacro( UseTrilinearInterpolation, bool ) + itkSetMacro( DoFiberResampling, bool ) void GenerateData(); protected: itk::Point GetItkPoint(double point[3]); TractDensityImageFilter(); virtual ~TractDensityImageFilter(); typename OutputImageType::Pointer m_InputImage; ///< use input image geometry to initialize output image mitk::FiberBundleX::Pointer m_FiberBundle; ///< input fiber bundle float m_UpsamplingFactor; ///< use higher resolution for ouput image bool m_InvertImage; ///< voxelvalue = 1-voxelvalue bool m_BinaryOutput; ///< generate binary fiber envelope bool m_UseImageGeometry; ///< use input image geometry to initialize output image bool m_OutputAbsoluteValues; ///< do not normalize image values to 0-1 bool m_UseTrilinearInterpolation; + bool m_DoFiberResampling; }; } #ifndef ITK_MANUAL_INSTANTIATION #include "itkTractDensityImageFilter.cpp" #endif #endif // __itkTractDensityImageFilter_h__ diff --git a/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp b/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp index 1f013b584f..5f3ce15dd8 100755 --- a/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp +++ b/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.cpp @@ -1,1963 +1,1871 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #define _USE_MATH_DEFINES #include "mitkFiberBundleX.h" #include #include #include #include "mitkImagePixelReadAccessor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#include +#include +#include -const char* mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED = "Color_Orient"; -//const char* mitk::FiberBundleX::COLORCODING_FA_AS_OPACITY = "Color_Orient_FA_Opacity"; -const char* mitk::FiberBundleX::COLORCODING_FA_BASED = "FA_Values"; -const char* mitk::FiberBundleX::COLORCODING_CUSTOM = "custom"; const char* mitk::FiberBundleX::FIBER_ID_ARRAY = "Fiber_IDs"; using namespace std; mitk::FiberBundleX::FiberBundleX( vtkPolyData* fiberPolyData ) - : m_CurrentColorCoding(NULL) - , m_NumFibers(0) + : m_NumFibers(0) , m_FiberSampling(0) { m_FiberWeights = vtkSmartPointer::New(); m_FiberWeights->SetName("FIBER_WEIGHTS"); m_FiberPolyData = vtkSmartPointer::New(); if (fiberPolyData != NULL) { m_FiberPolyData = fiberPolyData; - //m_FiberPolyData->DeepCopy(fiberPolyData); this->DoColorCodingOrientationBased(); } this->UpdateFiberGeometry(); - this->SetColorCoding(COLORCODING_ORIENTATION_BASED); this->GenerateFiberIds(); } mitk::FiberBundleX::~FiberBundleX() { } mitk::FiberBundleX::Pointer mitk::FiberBundleX::GetDeepCopy() { mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(m_FiberPolyData); - newFib->SetColorCoding(m_CurrentColorCoding); + newFib->SetFiberColors(this->m_FiberColors); newFib->SetFiberWeights(this->m_FiberWeights); return newFib; } vtkSmartPointer mitk::FiberBundleX::GeneratePolyDataByIds(std::vector fiberIds) { - MITK_DEBUG << "\n=====FINAL RESULT: fib_id ======\n"; - MITK_DEBUG << "Number of new Fibers: " << fiberIds.size(); - // iterate through the vectorcontainer hosting all desired fiber Ids - vtkSmartPointer newFiberPolyData = vtkSmartPointer::New(); vtkSmartPointer newLineSet = vtkSmartPointer::New(); vtkSmartPointer newPointSet = vtkSmartPointer::New(); - // if FA array available, initialize fa double array - // if color orient array is available init color array - vtkSmartPointer faValueArray; - vtkSmartPointer colorsT; - //colors and alpha value for each single point, RGBA = 4 components - unsigned char rgba[4] = {0,0,0,0}; - int componentSize = sizeof(rgba); - - if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_FA_BASED)){ - MITK_DEBUG << "FA VALUES AVAILABLE, init array for new fiberbundle"; - faValueArray = vtkSmartPointer::New(); - } - - if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED)){ - MITK_DEBUG << "colorValues available, init array for new fiberbundle"; - colorsT = vtkUnsignedCharArray::New(); - colorsT->SetNumberOfComponents(componentSize); - colorsT->SetName(COLORCODING_ORIENTATION_BASED); - } - - - std::vector::iterator finIt = fiberIds.begin(); while ( finIt != fiberIds.end() ) { if (*finIt < 0 || *finIt>GetNumFibers()){ MITK_INFO << "FiberID can not be negative or >NumFibers!!! check id Extraction!" << *finIt; break; } vtkSmartPointer fiber = m_FiberIdDataSet->GetCell(*finIt);//->DeepCopy(fiber); - vtkSmartPointer fibPoints = fiber->GetPoints(); - vtkSmartPointer newFiber = vtkSmartPointer::New(); newFiber->GetPointIds()->SetNumberOfIds( fibPoints->GetNumberOfPoints() ); for(int i=0; iGetNumberOfPoints(); i++) { - // MITK_DEBUG << "id: " << fiber->GetPointId(i); - // MITK_DEBUG << fibPoints->GetPoint(i)[0] << " | " << fibPoints->GetPoint(i)[1] << " | " << fibPoints->GetPoint(i)[2]; newFiber->GetPointIds()->SetId(i, newPointSet->GetNumberOfPoints()); newPointSet->InsertNextPoint(fibPoints->GetPoint(i)[0], fibPoints->GetPoint(i)[1], fibPoints->GetPoint(i)[2]); - - - if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_FA_BASED)){ - // MITK_DEBUG << m_FiberIdDataSet->GetPointData()->GetArray(FA_VALUE_ARRAY)->GetTuple(fiber->GetPointId(i)); - } - - if (m_FiberIdDataSet->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED)){ - // MITK_DEBUG << "ColorValue: " << m_FiberIdDataSet->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)->GetTuple(fiber->GetPointId(i))[0]; - } } newLineSet->InsertNextCell(newFiber); ++finIt; } newFiberPolyData->SetPoints(newPointSet); newFiberPolyData->SetLines(newLineSet); - MITK_DEBUG << "new fiberbundle polydata points: " << newFiberPolyData->GetNumberOfPoints(); - MITK_DEBUG << "new fiberbundle polydata lines: " << newFiberPolyData->GetNumberOfLines(); - MITK_DEBUG << "=====================\n"; - - // mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(newFiberPolyData); return newFiberPolyData; } // merge two fiber bundles mitk::FiberBundleX::Pointer mitk::FiberBundleX::AddBundle(mitk::FiberBundleX* fib) { if (fib==NULL) { MITK_WARN << "trying to call AddBundle with NULL argument"; return NULL; } MITK_INFO << "Adding fibers"; vtkSmartPointer vNewPolyData = vtkSmartPointer::New(); vtkSmartPointer vNewLines = vtkSmartPointer::New(); vtkSmartPointer vNewPoints = vtkSmartPointer::New(); // add current fiber bundle vtkSmartPointer weights = vtkSmartPointer::New(); weights->SetNumberOfValues(this->GetNumFibers()+fib->GetNumFibers()); unsigned int counter = 0; for (int i=0; iGetNumberOfCells(); i++) { vtkCell* cell = m_FiberPolyData->GetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } weights->InsertValue(counter, this->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } // add new fiber bundle for (int i=0; iGetFiberPolyData()->GetNumberOfCells(); i++) { vtkCell* cell = fib->GetFiberPolyData()->GetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j, p); vtkIdType id = vNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } weights->InsertValue(counter, fib->GetFiberWeight(i)); vNewLines->InsertNextCell(container); counter++; } // initialize polydata vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // initialize fiber bundle mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(vNewPolyData); newFib->SetFiberWeights(weights); return newFib; } // subtract two fiber bundles mitk::FiberBundleX::Pointer mitk::FiberBundleX::SubtractBundle(mitk::FiberBundleX* fib) { MITK_INFO << "Subtracting fibers"; vtkSmartPointer vNewPolyData = vtkSmartPointer::New(); vtkSmartPointer vNewLines = vtkSmartPointer::New(); vtkSmartPointer vNewPoints = vtkSmartPointer::New(); // iterate over current fibers boost::progress_display disp(m_NumFibers); for( int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); if (points==NULL || numPoints<=0) continue; int numFibers2 = fib->GetNumFibers(); bool contained = false; for( int i2=0; i2GetFiberPolyData()->GetCell(i2); int numPoints2 = cell2->GetNumberOfPoints(); vtkPoints* points2 = cell2->GetPoints(); if (points2==NULL)// || numPoints2<=0) continue; // check endpoints if (numPoints2==numPoints) { itk::Point point_start = GetItkPoint(points->GetPoint(0)); itk::Point point_end = GetItkPoint(points->GetPoint(numPoints-1)); itk::Point point2_start = GetItkPoint(points2->GetPoint(0)); itk::Point point2_end = GetItkPoint(points2->GetPoint(numPoints2-1)); if ((point_start.SquaredEuclideanDistanceTo(point2_start)<=mitk::eps && point_end.SquaredEuclideanDistanceTo(point2_end)<=mitk::eps) || (point_start.SquaredEuclideanDistanceTo(point2_end)<=mitk::eps && point_end.SquaredEuclideanDistanceTo(point2_start)<=mitk::eps)) { // further checking ??? contained = true; break; } } } // add to result because fiber is not subtracted if (!contained) { vtkSmartPointer container = vtkSmartPointer::New(); for( int j=0; jInsertNextPoint(points->GetPoint(j)); container->GetPointIds()->InsertNextId(id); } vNewLines->InsertNextCell(container); } } if(vNewLines->GetNumberOfCells()==0) return NULL; // initialize polydata vNewPolyData->SetPoints(vNewPoints); vNewPolyData->SetLines(vNewLines); // initialize fiber bundle return mitk::FiberBundleX::New(vNewPolyData); } itk::Point mitk::FiberBundleX::GetItkPoint(double point[3]) { itk::Point itkPoint; itkPoint[0] = point[0]; itkPoint[1] = point[1]; itkPoint[2] = point[2]; return itkPoint; } /* * set polydata (additional flag to recompute fiber geometry, default = true) */ void mitk::FiberBundleX::SetFiberPolyData(vtkSmartPointer fiberPD, bool updateGeometry) { if (fiberPD == NULL) this->m_FiberPolyData = vtkSmartPointer::New(); else { m_FiberPolyData->DeepCopy(fiberPD); DoColorCodingOrientationBased(); } m_NumFibers = m_FiberPolyData->GetNumberOfLines(); if (updateGeometry) UpdateFiberGeometry(); - SetColorCoding(COLORCODING_ORIENTATION_BASED); GenerateFiberIds(); } /* * return vtkPolyData */ vtkSmartPointer mitk::FiberBundleX::GetFiberPolyData() const { return m_FiberPolyData; } 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_DEBUG << " NO NEED TO REGENERATE COLORCODING! " ; - this->ResetFiberOpacity(); - this->SetColorCoding(COLORCODING_ORIENTATION_BASED); - return; - } - - /* Finally, execute color calculation */ vtkPoints* extrPoints = NULL; extrPoints = m_FiberPolyData->GetPoints(); int numOfPoints = 0; if (extrPoints!=NULL) 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); int componentSize = 4; + m_FiberColors = vtkSmartPointer::New(); + m_FiberColors->Allocate(numOfPoints * componentSize); + m_FiberColors->SetNumberOfComponents(componentSize); + m_FiberColors->SetName("FIBER_COLORS"); - vtkSmartPointer colorsT = vtkSmartPointer::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) return; /* extract single fibers of fiberBundle */ vtkCellArray* fiberList = m_FiberPolyData->GetLines(); fiberList->InitTraversal(); for (int fi=0; fiGetNextCell(pointsPerFiber, idList); /* single fiber checkpoints: is number of points valid */ if (pointsPerFiber > 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]); vnl_vector_fixed< double, 3 > diff1; diff1 = currentPntvtk - nextPntvtk; vnl_vector_fixed< double, 3 > diff2; diff2 = currentPntvtk - prevPntvtk; vnl_vector_fixed< double, 3 > diff; diff = (diff1 - diff2) / 2.0; diff.normalize(); rgba[0] = (unsigned char) (255.0 * std::fabs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::fabs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::fabs(diff[2])); rgba[3] = (unsigned char) (255.0); } 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 > diff1; diff1 = currentPntvtk - nextPntvtk; diff1.normalize(); rgba[0] = (unsigned char) (255.0 * std::fabs(diff1[0])); rgba[1] = (unsigned char) (255.0 * std::fabs(diff1[1])); rgba[2] = (unsigned char) (255.0 * std::fabs(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]); vnl_vector_fixed< double, 3 > diff2; diff2 = currentPntvtk - prevPntvtk; diff2.normalize(); rgba[0] = (unsigned char) (255.0 * std::fabs(diff2[0])); rgba[1] = (unsigned char) (255.0 * std::fabs(diff2[1])); rgba[2] = (unsigned char) (255.0 * std::fabs(diff2[2])); rgba[3] = (unsigned char) (255.0); - } - colorsT->InsertTupleValue(idList[i], rgba); - } //end for loop + m_FiberColors->InsertTupleValue(idList[i], rgba); + } } else if (pointsPerFiber == 1) { /* a single point does not define a fiber (use vertex mechanisms instead */ continue; } else { MITK_DEBUG << "Fiber with 0 points detected... please check your tractography algorithm!" ; continue; } - }//end for loop - - m_FiberPolyData->GetPointData()->AddArray(colorsT); - - this->SetColorCoding(COLORCODING_ORIENTATION_BASED); - - //mini test, shall be ported to MITK TESTINGS! - if (colorsT->GetSize() != numOfPoints*componentSize) - MITK_DEBUG << "ALLOCATION ERROR IN INITIATING COLOR ARRAY"; -} - -void mitk::FiberBundleX::DoColorCodingFaBased() -{ - if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_FA_BASED) != 1 ) - return; - - this->SetColorCoding(COLORCODING_FA_BASED); - // this->GenerateFiberIds(); + } + m_UpdateTime3D.Modified(); + m_UpdateTime2D.Modified(); } -void mitk::FiberBundleX::DoUseFaFiberOpacity() +void mitk::FiberBundleX::SetFiberOpacity(vtkDoubleArray* FAValArray) { - if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_FA_BASED) != 1 ) - return; - - if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_ORIENTATION_BASED) != 1 ) - return; - - vtkDoubleArray* FAValArray = (vtkDoubleArray*) m_FiberPolyData->GetPointData()->GetArray(COLORCODING_FA_BASED); - vtkUnsignedCharArray* ColorArray = dynamic_cast (m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)); - - for(long i=0; iGetNumberOfTuples(); i++) { + for(long i=0; iGetNumberOfTuples(); i++) + { double faValue = FAValArray->GetValue(i); faValue = faValue * 255.0; - ColorArray->SetComponent(i,3, (unsigned char) faValue ); + m_FiberColors->SetComponent(i,3, (unsigned char) faValue ); } - - this->SetColorCoding(COLORCODING_ORIENTATION_BASED); - // this->GenerateFiberIds(); + m_UpdateTime3D.Modified(); + m_UpdateTime2D.Modified(); } -void mitk::FiberBundleX::ResetFiberOpacity() { - vtkUnsignedCharArray* ColorArray = dynamic_cast (m_FiberPolyData->GetPointData()->GetArray(COLORCODING_ORIENTATION_BASED)); - if (ColorArray==NULL) - return; - for(long i=0; iGetNumberOfTuples(); i++) - ColorArray->SetComponent(i,3, 255.0 ); +void mitk::FiberBundleX::ResetFiberOpacity() +{ + for(long i=0; iGetNumberOfTuples(); i++) + m_FiberColors->SetComponent(i,3, 255.0 ); + m_UpdateTime3D.Modified(); + m_UpdateTime2D.Modified(); } -void mitk::FiberBundleX::SetFAMap(mitk::Image::Pointer FAimage) +void mitk::FiberBundleX::ColorFibersByScalarMap(mitk::Image::Pointer FAimage, bool opacity) { - mitkPixelTypeMultiplex1( SetFAMap, FAimage->GetPixelType(), FAimage ); + mitkPixelTypeMultiplex2( ColorFibersByScalarMap, FAimage->GetPixelType(), FAimage, opacity ); + m_UpdateTime3D.Modified(); + m_UpdateTime2D.Modified(); } template -void mitk::FiberBundleX::SetFAMap(const mitk::PixelType, mitk::Image::Pointer FAimage) +void mitk::FiberBundleX::ColorFibersByScalarMap(const mitk::PixelType, mitk::Image::Pointer image, bool opacity) { - MITK_DEBUG << "SetFAMap"; - vtkSmartPointer faValues = vtkSmartPointer::New(); - faValues->SetName(COLORCODING_FA_BASED); - faValues->Allocate(m_FiberPolyData->GetNumberOfPoints()); - faValues->SetNumberOfValues(m_FiberPolyData->GetNumberOfPoints()); + m_FiberColors = vtkSmartPointer::New(); + m_FiberColors->Allocate(m_FiberPolyData->GetNumberOfPoints() * 4); + m_FiberColors->SetNumberOfComponents(4); + m_FiberColors->SetName("FIBER_COLORS"); - mitk::ImagePixelReadAccessor readFAimage (FAimage, FAimage->GetVolumeData(0)); + mitk::ImagePixelReadAccessor readimage(image, image->GetVolumeData(0)); + unsigned char rgba[4] = {0,0,0,0}; vtkPoints* pointSet = m_FiberPolyData->GetPoints(); + + mitk::LookupTable::Pointer mitkLookup = mitk::LookupTable::New(); + vtkSmartPointer lookupTable = vtkSmartPointer::New(); + lookupTable->SetTableRange(0.0, 0.8); + lookupTable->Build(); + mitkLookup->SetVtkLookupTable(lookupTable); + mitkLookup->SetType(mitk::LookupTable::JET); + for(long i=0; iGetNumberOfPoints(); ++i) { Point3D px; px[0] = pointSet->GetPoint(i)[0]; px[1] = pointSet->GetPoint(i)[1]; px[2] = pointSet->GetPoint(i)[2]; - double faPixelValue = 1-readFAimage.GetPixelByWorldCoordinates(px); - faValues->InsertValue(i, faPixelValue); - } - - m_FiberPolyData->GetPointData()->AddArray(faValues); - this->GenerateFiberIds(); + double pixelValue = readimage.GetPixelByWorldCoordinates(px); - if(m_FiberPolyData->GetPointData()->HasArray(COLORCODING_FA_BASED)) - MITK_DEBUG << "FA VALUE ARRAY SET"; + double color[3]; + lookupTable->GetColor(pixelValue, color); + rgba[0] = (unsigned char) (255.0 * color[0]); + rgba[1] = (unsigned char) (255.0 * color[1]); + rgba[2] = (unsigned char) (255.0 * color[2]); + if (opacity) + rgba[3] = (unsigned char) (255.0 * pixelValue); + else + rgba[3] = (unsigned char) (255.0); + m_FiberColors->InsertTupleValue(i, rgba); + } + m_UpdateTime3D.Modified(); + m_UpdateTime2D.Modified(); } +void mitk::FiberBundleX::SetFiberColors(float r, float g, float b, float alpha) +{ + m_FiberColors = vtkSmartPointer::New(); + m_FiberColors->Allocate(m_FiberPolyData->GetNumberOfPoints() * 4); + m_FiberColors->SetNumberOfComponents(4); + m_FiberColors->SetName("FIBER_COLORS"); + + unsigned char rgba[4] = {0,0,0,0}; + for(long i=0; iGetNumberOfPoints(); ++i) + { + rgba[0] = (unsigned char) r; + rgba[1] = (unsigned char) g; + rgba[2] = (unsigned char) b; + rgba[3] = (unsigned char) alpha; + m_FiberColors->InsertTupleValue(i, rgba); + } + m_UpdateTime3D.Modified(); + m_UpdateTime2D.Modified(); +} void mitk::FiberBundleX::GenerateFiberIds() { if (m_FiberPolyData == NULL) return; vtkSmartPointer idFiberFilter = vtkSmartPointer::New(); idFiberFilter->SetInputData(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_DEBUG << "Generating Fiber Ids...[done] | " << m_FiberIdDataSet->GetNumberOfCells(); - } mitk::FiberBundleX::Pointer mitk::FiberBundleX::ExtractFiberSubset(ItkUcharImgType* mask, bool anyPoint, bool invert) { vtkSmartPointer polyData = m_FiberPolyData; if (anyPoint) { float minSpacing = 1; if(mask->GetSpacing()[0]GetSpacing()[1] && mask->GetSpacing()[0]GetSpacing()[2]) minSpacing = mask->GetSpacing()[0]; else if (mask->GetSpacing()[1] < mask->GetSpacing()[2]) minSpacing = mask->GetSpacing()[1]; else minSpacing = mask->GetSpacing()[2]; mitk::FiberBundleX::Pointer fibCopy = this->GetDeepCopy(); fibCopy->ResampleSpline(minSpacing/5); polyData = fibCopy->GetFiberPolyData(); } vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); MITK_INFO << "Extracting fibers"; boost::progress_display disp(m_NumFibers); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkCell* cellOriginal = m_FiberPolyData->GetCell(i); int numPointsOriginal = cellOriginal->GetNumberOfPoints(); vtkPoints* pointsOriginal = cellOriginal->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); if (numPoints>1 && numPointsOriginal) { if (anyPoint) { if (!invert) { for (int j=0; jGetPoint(j); itk::Point itkP; itkP[0] = p[0]; itkP[1] = p[1]; itkP[2] = p[2]; itk::Index<3> idx; mask->TransformPhysicalPointToIndex(itkP, idx); if ( mask->GetPixel(idx)>0 && mask->GetLargestPossibleRegion().IsInside(idx) ) { for (int k=0; kGetPoint(k); vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } break; } } } else { bool includeFiber = true; for (int j=0; jGetPoint(j); itk::Point itkP; itkP[0] = p[0]; itkP[1] = p[1]; itkP[2] = p[2]; itk::Index<3> idx; mask->TransformPhysicalPointToIndex(itkP, idx); if ( mask->GetPixel(idx)>0 && mask->GetLargestPossibleRegion().IsInside(idx) ) { includeFiber = false; break; } } if (includeFiber) { for (int k=0; kGetPoint(k); vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } } } } else { double* start = pointsOriginal->GetPoint(0); itk::Point itkStart; itkStart[0] = start[0]; itkStart[1] = start[1]; itkStart[2] = start[2]; itk::Index<3> idxStart; mask->TransformPhysicalPointToIndex(itkStart, idxStart); double* end = pointsOriginal->GetPoint(numPointsOriginal-1); itk::Point itkEnd; itkEnd[0] = end[0]; itkEnd[1] = end[1]; itkEnd[2] = end[2]; itk::Index<3> idxEnd; mask->TransformPhysicalPointToIndex(itkEnd, idxEnd); if ( mask->GetPixel(idxStart)>0 && mask->GetPixel(idxEnd)>0 && mask->GetLargestPossibleRegion().IsInside(idxStart) && mask->GetLargestPossibleRegion().IsInside(idxEnd) ) { for (int j=0; jGetPoint(j); vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } } } } vtkNewCells->InsertNextCell(container); } if (vtkNewCells->GetNumberOfCells()<=0) return NULL; vtkSmartPointer newPolyData = vtkSmartPointer::New(); newPolyData->SetPoints(vtkNewPoints); newPolyData->SetLines(vtkNewCells); return mitk::FiberBundleX::New(newPolyData); } mitk::FiberBundleX::Pointer mitk::FiberBundleX::RemoveFibersOutside(ItkUcharImgType* mask, bool invert) { float minSpacing = 1; if(mask->GetSpacing()[0]GetSpacing()[1] && mask->GetSpacing()[0]GetSpacing()[2]) minSpacing = mask->GetSpacing()[0]; else if (mask->GetSpacing()[1] < mask->GetSpacing()[2]) minSpacing = mask->GetSpacing()[1]; else minSpacing = mask->GetSpacing()[2]; mitk::FiberBundleX::Pointer fibCopy = this->GetDeepCopy(); fibCopy->ResampleSpline(minSpacing/10); vtkSmartPointer polyData =fibCopy->GetFiberPolyData(); vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); MITK_INFO << "Cutting fibers"; boost::progress_display disp(m_NumFibers); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); if (numPoints>1) { int newNumPoints = 0; for (int j=0; jGetPoint(j); itk::Point itkP; itkP[0] = p[0]; itkP[1] = p[1]; itkP[2] = p[2]; itk::Index<3> idx; mask->TransformPhysicalPointToIndex(itkP, idx); if ( mask->GetPixel(idx)>0 && mask->GetLargestPossibleRegion().IsInside(idx) && !invert ) { vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); newNumPoints++; } else if ( (mask->GetPixel(idx)<=0 || !mask->GetLargestPossibleRegion().IsInside(idx)) && invert ) { vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); newNumPoints++; } else if (newNumPoints>0) { vtkNewCells->InsertNextCell(container); newNumPoints = 0; container = vtkSmartPointer::New(); } } if (newNumPoints>0) vtkNewCells->InsertNextCell(container); } } if (vtkNewCells->GetNumberOfCells()<=0) return NULL; vtkSmartPointer newPolyData = vtkSmartPointer::New(); newPolyData->SetPoints(vtkNewPoints); newPolyData->SetLines(vtkNewCells); mitk::FiberBundleX::Pointer newFib = mitk::FiberBundleX::New(newPolyData); newFib->ResampleSpline(minSpacing/2); return newFib; } mitk::FiberBundleX::Pointer mitk::FiberBundleX::ExtractFiberSubset(BaseData* roi) { if (roi==NULL || !(dynamic_cast(roi) || dynamic_cast(roi)) ) return NULL; std::vector tmp = ExtractFiberIdSubset(roi); if (tmp.size()<=0) return mitk::FiberBundleX::New(); vtkSmartPointer pTmp = GeneratePolyDataByIds(tmp); return mitk::FiberBundleX::New(pTmp); } std::vector mitk::FiberBundleX::ExtractFiberIdSubset(BaseData* roi) { std::vector result; if (roi==NULL) return result; mitk::PlanarFigureComposite::Pointer pfc = dynamic_cast(roi); if (!pfc.IsNull()) // handle composite { switch (pfc->getOperationType()) { case 0: // AND { result = this->ExtractFiberIdSubset(pfc->getChildAt(0)); std::vector::iterator it; for (int i=1; igetNumberOfChildren(); ++i) { std::vector inRoi = this->ExtractFiberIdSubset(pfc->getChildAt(i)); std::vector rest(std::min(result.size(),inRoi.size())); it = std::set_intersection(result.begin(), result.end(), inRoi.begin(), inRoi.end(), rest.begin() ); rest.resize( it - rest.begin() ); result = rest; } break; } case 1: // OR { result = ExtractFiberIdSubset(pfc->getChildAt(0)); std::vector::iterator it; for (int i=1; igetNumberOfChildren(); ++i) { it = result.end(); std::vector inRoi = ExtractFiberIdSubset(pfc->getChildAt(i)); result.insert(it, inRoi.begin(), inRoi.end()); } // remove duplicates sort(result.begin(), result.end()); it = unique(result.begin(), result.end()); result.resize( it - result.begin() ); break; } case 2: // NOT { for(long i=0; iGetNumFibers(); i++) result.push_back(i); std::vector::iterator it; for (long i=0; igetNumberOfChildren(); ++i) { std::vector inRoi = ExtractFiberIdSubset(pfc->getChildAt(i)); std::vector rest(result.size()-inRoi.size()); it = std::set_difference(result.begin(), result.end(), inRoi.begin(), inRoi.end(), rest.begin() ); rest.resize( it - rest.begin() ); result = rest; } break; } } } else if ( dynamic_cast(roi) ) // actual extraction { mitk::PlanarFigure::Pointer planarFigure = dynamic_cast(roi); Vector3D planeNormal = planarFigure->GetPlaneGeometry()->GetNormal(); planeNormal.Normalize(); Point3D planeOrigin = planarFigure->GetPlaneGeometry()->GetOrigin(); // define cutting plane by ROI geometry (PlanarFigure) vtkSmartPointer plane = vtkSmartPointer::New(); plane->SetOrigin(planeOrigin[0],planeOrigin[1],planeOrigin[2]); plane->SetNormal(planeNormal[0],planeNormal[1],planeNormal[2]); // get all fiber/plane intersection points vtkSmartPointer clipper = vtkSmartPointer::New(); clipper->SetInputData(m_FiberIdDataSet); clipper->SetClipFunction(plane); clipper->GenerateClipScalarsOn(); clipper->GenerateClippedOutputOn(); clipper->Update(); vtkSmartPointer clipperout = clipper->GetClippedOutput(); if (!clipperout->GetCellData()->HasArray(FIBER_ID_ARRAY)) return result; vtkSmartPointer distanceList = clipperout->GetPointData()->GetScalars(); vtkIdType numPoints = distanceList->GetNumberOfTuples(); std::vector pointsOnPlane; pointsOnPlane.reserve(numPoints); for (int i=0; iGetTuple(i)[0]; // check if point is on plane if (distance >= -0.01 && distance <= 0.01) pointsOnPlane.push_back(i); } if (pointsOnPlane.empty()) return result; // get all point IDs inside the ROI std::vector pointsInROI; pointsInROI.reserve(pointsOnPlane.size()); mitk::PlanarCircle::Pointer circleName = mitk::PlanarCircle::New(); mitk::PlanarPolygon::Pointer polyName = mitk::PlanarPolygon::New(); if ( planarFigure->GetNameOfClass() == circleName->GetNameOfClass() ) { //calculate circle radius mitk::Point3D V1w = planarFigure->GetWorldControlPoint(0); //centerPoint mitk::Point3D V2w = planarFigure->GetWorldControlPoint(1); //radiusPoint double radius = V1w.EuclideanDistanceTo(V2w); radius *= radius; for (unsigned int i=0; iGetPoint(pointsOnPlane[i], p); double dist = (p[0]-V1w[0])*(p[0]-V1w[0])+(p[1]-V1w[1])*(p[1]-V1w[1])+(p[2]-V1w[2])*(p[2]-V1w[2]); if( dist <= radius) pointsInROI.push_back(pointsOnPlane[i]); } } else if ( planarFigure->GetNameOfClass() == polyName->GetNameOfClass() ) { //create vtkPolygon using controlpoints from planarFigure polygon vtkSmartPointer polygonVtk = vtkSmartPointer::New(); for (unsigned int i=0; iGetNumberOfControlPoints(); ++i) { itk::Point p = planarFigure->GetWorldControlPoint(i); polygonVtk->GetPoints()->InsertNextPoint(p[0], p[1], p[2] ); } //prepare everything for using pointInPolygon function double n[3]; polygonVtk->ComputeNormal(polygonVtk->GetPoints()->GetNumberOfPoints(), static_cast(polygonVtk->GetPoints()->GetData()->GetVoidPointer(0)), n); double bounds[6]; polygonVtk->GetPoints()->GetBounds(bounds); for (unsigned int i=0; iGetPoint(pointsOnPlane[i], p); int isInPolygon = polygonVtk->PointInPolygon(p, polygonVtk->GetPoints()->GetNumberOfPoints(), static_cast(polygonVtk->GetPoints()->GetData()->GetVoidPointer(0)), bounds, n); if( isInPolygon ) pointsInROI.push_back(pointsOnPlane[i]); } } if (pointsInROI.empty()) return result; // get the fiber IDs corresponding to all clipped points std::vector< long > pointToFiberMap; // pointToFiberMap[PointID] = FiberIndex pointToFiberMap.resize(clipperout->GetNumberOfPoints()); vtkCellArray* clipperlines = clipperout->GetLines(); clipperlines->InitTraversal(); for (int i=0, ic=0 ; iGetNumberOfCells(); i++, ic+=3) { // ic is the index counter for the cells hosting the desired information. each cell consits of 3 items. long fiberID = clipperout->GetCellData()->GetArray(FIBER_ID_ARRAY)->GetTuple(i)[0]; vtkIdType numPoints; vtkIdType* pointIDs; clipperlines->GetCell(ic, numPoints, pointIDs); for (long j=0; j=0) result.push_back( pointToFiberMap[pointsInROI[k]] ); else MITK_INFO << "ERROR in ExtractFiberIdSubset; impossible fiber id detected"; } // remove duplicates std::vector::iterator it; sort(result.begin(), result.end()); it = unique (result.begin(), result.end()); result.resize( it - result.begin() ); } return result; } void mitk::FiberBundleX::UpdateFiberGeometry() { vtkSmartPointer cleaner = vtkSmartPointer::New(); cleaner->SetInputData(m_FiberPolyData); cleaner->PointMergingOff(); cleaner->Update(); m_FiberPolyData = cleaner->GetOutput(); m_FiberLengths.clear(); m_MeanFiberLength = 0; m_MedianFiberLength = 0; m_LengthStDev = 0; m_NumFibers = m_FiberPolyData->GetNumberOfCells(); + if (m_FiberColors==NULL || m_FiberColors->GetNumberOfTuples()!=m_FiberPolyData->GetNumberOfPoints()) + this->DoColorCodingOrientationBased(); + if (m_FiberWeights->GetSize()!=m_NumFibers) { m_FiberWeights = vtkSmartPointer::New(); m_FiberWeights->SetName("FIBER_WEIGHTS"); m_FiberWeights->SetNumberOfValues(m_NumFibers); this->SetFiberWeights(1); } if (m_NumFibers<=0) // no fibers present; apply default geometry { m_MinFiberLength = 0; m_MaxFiberLength = 0; mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); geometry->SetImageGeometry(false); float b[] = {0, 1, 0, 1, 0, 1}; geometry->SetFloatBounds(b); SetGeometry(geometry); return; } double b[6]; m_FiberPolyData->GetBounds(b); // calculate statistics for (int i=0; iGetNumberOfCells(); i++) { vtkCell* cell = m_FiberPolyData->GetCell(i); int p = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); float length = 0; for (int j=0; jGetPoint(j, p1); double p2[3]; points->GetPoint(j+1, p2); float dist = std::sqrt((p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1])+(p1[2]-p2[2])*(p1[2]-p2[2])); length += dist; } m_FiberLengths.push_back(length); m_MeanFiberLength += length; if (i==0) { m_MinFiberLength = length; m_MaxFiberLength = length; } else { if (lengthm_MaxFiberLength) m_MaxFiberLength = length; } } m_MeanFiberLength /= m_NumFibers; std::vector< float > sortedLengths = m_FiberLengths; std::sort(sortedLengths.begin(), sortedLengths.end()); for (int i=0; i1) m_LengthStDev /= (m_NumFibers-1); else m_LengthStDev = 0; m_LengthStDev = std::sqrt(m_LengthStDev); m_MedianFiberLength = sortedLengths.at(m_NumFibers/2); mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); geometry->SetFloatBounds(b); this->SetGeometry(geometry); m_UpdateTime3D.Modified(); m_UpdateTime2D.Modified(); } float mitk::FiberBundleX::GetFiberWeight(unsigned int fiber) { return m_FiberWeights->GetValue(fiber); } void mitk::FiberBundleX::SetFiberWeights(float newWeight) { for (int i=0; iGetSize(); i++) m_FiberWeights->SetValue(i, newWeight); } void mitk::FiberBundleX::SetFiberWeights(vtkSmartPointer weights) { if (m_NumFibers!=weights->GetSize()) return; for (int i=0; iGetSize(); i++) m_FiberWeights->SetValue(i, weights->GetValue(i)); m_FiberWeights->SetName("FIBER_WEIGHTS"); } void mitk::FiberBundleX::SetFiberWeight(unsigned int fiber, float weight) { m_FiberWeights->SetValue(fiber, weight); } -std::vector mitk::FiberBundleX::GetAvailableColorCodings() +void mitk::FiberBundleX::SetFiberColors(vtkSmartPointer fiberColors) { - std::vector availableColorCodings; - int numColors = m_FiberPolyData->GetPointData()->GetNumberOfArrays(); - for(int i=0; iGetNumberOfPoints(); ++i) { - availableColorCodings.push_back(m_FiberPolyData->GetPointData()->GetArrayName(i)); - } - - //this controlstructure shall be implemented by the calling method - if (availableColorCodings.empty()) - MITK_DEBUG << "no colorcodings available in fiberbundleX"; - - return availableColorCodings; -} - - -char* mitk::FiberBundleX::GetCurrentColorCoding() -{ - return m_CurrentColorCoding; -} - -void mitk::FiberBundleX::SetColorCoding(const char* requestedColorCoding) -{ - if (requestedColorCoding==NULL) - return; - - if( strcmp (COLORCODING_ORIENTATION_BASED,requestedColorCoding) == 0 ) { - this->m_CurrentColorCoding = (char*) COLORCODING_ORIENTATION_BASED; - - } else if( strcmp (COLORCODING_FA_BASED,requestedColorCoding) == 0 ) { - this->m_CurrentColorCoding = (char*) COLORCODING_FA_BASED; - - } else if( strcmp (COLORCODING_CUSTOM,requestedColorCoding) == 0 ) { - this->m_CurrentColorCoding = (char*) COLORCODING_CUSTOM; - - } else { - MITK_DEBUG << "FIBERBUNDLE X: UNKNOWN COLORCODING in FIBERBUNDLEX Datastructure"; - this->m_CurrentColorCoding = (char*) COLORCODING_CUSTOM; //will cause blank colorcoding of fibers + unsigned char source[4] = {0,0,0,0}; + fiberColors->GetTupleValue(i, source); + + unsigned char target[4] = {0,0,0,0}; + target[0] = source[0]; + target[1] = source[1]; + target[2] = source[2]; + target[3] = source[3]; + m_FiberColors->InsertTupleValue(i, target); } - m_UpdateTime3D.Modified(); m_UpdateTime2D.Modified(); } itk::Matrix< double, 3, 3 > mitk::FiberBundleX::TransformMatrix(itk::Matrix< double, 3, 3 > m, double rx, double ry, double rz) { rx = rx*M_PI/180; ry = ry*M_PI/180; rz = rz*M_PI/180; itk::Matrix< double, 3, 3 > rotX; rotX.SetIdentity(); rotX[1][1] = cos(rx); rotX[2][2] = rotX[1][1]; rotX[1][2] = -sin(rx); rotX[2][1] = -rotX[1][2]; itk::Matrix< double, 3, 3 > rotY; rotY.SetIdentity(); rotY[0][0] = cos(ry); rotY[2][2] = rotY[0][0]; rotY[0][2] = sin(ry); rotY[2][0] = -rotY[0][2]; itk::Matrix< double, 3, 3 > rotZ; rotZ.SetIdentity(); rotZ[0][0] = cos(rz); rotZ[1][1] = rotZ[0][0]; rotZ[0][1] = -sin(rz); rotZ[1][0] = -rotZ[0][1]; itk::Matrix< double, 3, 3 > rot = rotZ*rotY*rotX; m = rot*m; return m; } itk::Point mitk::FiberBundleX::TransformPoint(vnl_vector_fixed< double, 3 > point, double rx, double ry, double rz, double tx, double ty, double tz) { rx = rx*M_PI/180; ry = ry*M_PI/180; rz = rz*M_PI/180; vnl_matrix_fixed< double, 3, 3 > rotX; rotX.set_identity(); rotX[1][1] = cos(rx); rotX[2][2] = rotX[1][1]; rotX[1][2] = -sin(rx); rotX[2][1] = -rotX[1][2]; vnl_matrix_fixed< double, 3, 3 > rotY; rotY.set_identity(); rotY[0][0] = cos(ry); rotY[2][2] = rotY[0][0]; rotY[0][2] = sin(ry); rotY[2][0] = -rotY[0][2]; vnl_matrix_fixed< double, 3, 3 > rotZ; rotZ.set_identity(); rotZ[0][0] = cos(rz); rotZ[1][1] = rotZ[0][0]; rotZ[0][1] = -sin(rz); rotZ[1][0] = -rotZ[0][1]; vnl_matrix_fixed< double, 3, 3 > rot = rotZ*rotY*rotX; mitk::BaseGeometry::Pointer geom = this->GetGeometry(); mitk::Point3D center = geom->GetCenter(); point[0] -= center[0]; point[1] -= center[1]; point[2] -= center[2]; point = rot*point; point[0] += center[0]+tx; point[1] += center[1]+ty; point[2] += center[2]+tz; itk::Point out; out[0] = point[0]; out[1] = point[1]; out[2] = point[2]; return out; } void mitk::FiberBundleX::TransformFibers(double rx, double ry, double rz, double tx, double ty, double tz) { rx = rx*M_PI/180; ry = ry*M_PI/180; rz = rz*M_PI/180; vnl_matrix_fixed< double, 3, 3 > rotX; rotX.set_identity(); rotX[1][1] = cos(rx); rotX[2][2] = rotX[1][1]; rotX[1][2] = -sin(rx); rotX[2][1] = -rotX[1][2]; vnl_matrix_fixed< double, 3, 3 > rotY; rotY.set_identity(); rotY[0][0] = cos(ry); rotY[2][2] = rotY[0][0]; rotY[0][2] = sin(ry); rotY[2][0] = -rotY[0][2]; vnl_matrix_fixed< double, 3, 3 > rotZ; rotZ.set_identity(); rotZ[0][0] = cos(rz); rotZ[1][1] = rotZ[0][0]; rotZ[0][1] = -sin(rz); rotZ[1][0] = -rotZ[0][1]; vnl_matrix_fixed< double, 3, 3 > rot = rotZ*rotY*rotX; mitk::BaseGeometry::Pointer geom = this->GetGeometry(); mitk::Point3D center = geom->GetCenter(); vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j); vnl_vector_fixed< double, 3 > dir; dir[0] = p[0]-center[0]; dir[1] = p[1]-center[1]; dir[2] = p[2]-center[2]; dir = rot*dir; dir[0] += center[0]+tx; dir[1] += center[1]+ty; dir[2] += center[2]+tz; vtkIdType id = vtkNewPoints->InsertNextPoint(dir.data_block()); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); } void mitk::FiberBundleX::RotateAroundAxis(double x, double y, double z) { x = x*M_PI/180; y = y*M_PI/180; z = z*M_PI/180; vnl_matrix_fixed< double, 3, 3 > rotX; rotX.set_identity(); rotX[1][1] = cos(x); rotX[2][2] = rotX[1][1]; rotX[1][2] = -sin(x); rotX[2][1] = -rotX[1][2]; vnl_matrix_fixed< double, 3, 3 > rotY; rotY.set_identity(); rotY[0][0] = cos(y); rotY[2][2] = rotY[0][0]; rotY[0][2] = sin(y); rotY[2][0] = -rotY[0][2]; vnl_matrix_fixed< double, 3, 3 > rotZ; rotZ.set_identity(); rotZ[0][0] = cos(z); rotZ[1][1] = rotZ[0][0]; rotZ[0][1] = -sin(z); rotZ[1][0] = -rotZ[0][1]; mitk::BaseGeometry::Pointer geom = this->GetGeometry(); mitk::Point3D center = geom->GetCenter(); vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j); vnl_vector_fixed< double, 3 > dir; dir[0] = p[0]-center[0]; dir[1] = p[1]-center[1]; dir[2] = p[2]-center[2]; dir = rotZ*rotY*rotX*dir; dir[0] += center[0]; dir[1] += center[1]; dir[2] += center[2]; vtkIdType id = vtkNewPoints->InsertNextPoint(dir.data_block()); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); } void mitk::FiberBundleX::ScaleFibers(double x, double y, double z, bool subtractCenter) { MITK_INFO << "Scaling fibers"; boost::progress_display disp(m_NumFibers); mitk::BaseGeometry* geom = this->GetGeometry(); mitk::Point3D c = geom->GetCenter(); vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j); if (subtractCenter) { p[0] -= c[0]; p[1] -= c[1]; p[2] -= c[2]; } p[0] *= x; p[1] *= y; p[2] *= z; if (subtractCenter) { p[0] += c[0]; p[1] += c[1]; p[2] += c[2]; } vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); } void mitk::FiberBundleX::TranslateFibers(double x, double y, double z) { vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j); p[0] += x; p[1] += y; p[2] += z; vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); } void mitk::FiberBundleX::MirrorFibers(unsigned int axis) { if (axis>2) return; MITK_INFO << "Mirroring fibers"; boost::progress_display disp(m_NumFibers); vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j); p[axis] = -p[axis]; vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); } void mitk::FiberBundleX::RemoveDir(vnl_vector_fixed dir, double threshold) { dir.normalize(); vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); boost::progress_display disp(m_FiberPolyData->GetNumberOfCells()); for (int i=0; iGetNumberOfCells(); i++) { ++disp ; vtkCell* cell = m_FiberPolyData->GetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); // calculate curvatures vtkSmartPointer container = vtkSmartPointer::New(); bool discard = false; for (int j=0; jGetPoint(j, p1); double p2[3]; points->GetPoint(j+1, p2); vnl_vector_fixed< double, 3 > v1; v1[0] = p2[0]-p1[0]; v1[1] = p2[1]-p1[1]; v1[2] = p2[2]-p1[2]; if (v1.magnitude()>0.001) { v1.normalize(); if (fabs(dot_product(v1,dir))>threshold) { discard = true; break; } } } if (!discard) { for (int j=0; jGetPoint(j, p1); vtkIdType id = vtkNewPoints->InsertNextPoint(p1); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); } } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); -// UpdateColorCoding(); -// UpdateFiberGeometry(); + // UpdateColorCoding(); + // UpdateFiberGeometry(); } bool mitk::FiberBundleX::ApplyCurvatureThreshold(float minRadius, bool deleteFibers) { if (minRadius<0) return true; vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); MITK_INFO << "Applying curvature threshold"; boost::progress_display disp(m_FiberPolyData->GetNumberOfCells()); for (int i=0; iGetNumberOfCells(); i++) { ++disp ; vtkCell* cell = m_FiberPolyData->GetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); // calculate curvatures vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j, p1); double p2[3]; points->GetPoint(j+1, p2); double p3[3]; points->GetPoint(j+2, p3); vnl_vector_fixed< float, 3 > v1, v2, v3; v1[0] = p2[0]-p1[0]; v1[1] = p2[1]-p1[1]; v1[2] = p2[2]-p1[2]; v2[0] = p3[0]-p2[0]; v2[1] = p3[1]-p2[1]; v2[2] = p3[2]-p2[2]; v3[0] = p1[0]-p3[0]; v3[1] = p1[1]-p3[1]; v3[2] = p1[2]-p3[2]; float a = v1.magnitude(); float b = v2.magnitude(); float c = v3.magnitude(); float r = a*b*c/std::sqrt((a+b+c)*(a+b-c)*(b+c-a)*(a-b+c)); // radius of triangle via Heron's formula (area of triangle) vtkIdType id = vtkNewPoints->InsertNextPoint(p1); container->GetPointIds()->InsertNextId(id); if (deleteFibers && rInsertNextCell(container); container = vtkSmartPointer::New(); } else if (j==numPoints-3) { id = vtkNewPoints->InsertNextPoint(p2); container->GetPointIds()->InsertNextId(id); id = vtkNewPoints->InsertNextPoint(p3); container->GetPointIds()->InsertNextId(id); vtkNewCells->InsertNextCell(container); } } } if (vtkNewCells->GetNumberOfCells()<=0) return false; m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); return true; } bool mitk::FiberBundleX::RemoveShortFibers(float lengthInMM) { MITK_INFO << "Removing short fibers"; if (lengthInMM<=0 || lengthInMMm_MaxFiberLength) // can't remove all fibers { MITK_WARN << "Process aborted. No fibers would be left!"; return false; } vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); float min = m_MaxFiberLength; boost::progress_display disp(m_NumFibers); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); if (m_FiberLengths.at(i)>=lengthInMM) { vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j); vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); if (m_FiberLengths.at(i)GetNumberOfCells()<=0) return false; m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); return true; } bool mitk::FiberBundleX::RemoveLongFibers(float lengthInMM) { if (lengthInMM<=0 || lengthInMM>m_MaxFiberLength) return true; if (lengthInMM vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); MITK_INFO << "Removing long fibers"; boost::progress_display disp(m_NumFibers); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); if (m_FiberLengths.at(i)<=lengthInMM) { vtkSmartPointer container = vtkSmartPointer::New(); for (int j=0; jGetPoint(j); vtkIdType id = vtkNewPoints->InsertNextPoint(p); container->GetPointIds()->InsertNextId(id); } vtkNewCells->InsertNextCell(container); } } if (vtkNewCells->GetNumberOfCells()<=0) return false; m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); return true; } void mitk::FiberBundleX::ResampleSpline(float pointDistance, double tension, double continuity, double bias ) { if (pointDistance<=0) return; vtkSmartPointer vtkSmoothPoints = vtkSmartPointer::New(); //in smoothpoints the interpolated points representing a fiber are stored. //in vtkcells all polylines are stored, actually all id's of them are stored vtkSmartPointer vtkSmoothCells = vtkSmartPointer::New(); //cellcontainer for smoothed lines vtkIdType pointHelperCnt = 0; MITK_INFO << "Smoothing fibers"; boost::progress_display disp(m_NumFibers); for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkSmartPointer newPoints = vtkSmartPointer::New(); for (int j=0; jInsertNextPoint(points->GetPoint(j)); float length = m_FiberLengths.at(i); int sampling = std::ceil(length/pointDistance); vtkSmartPointer xSpline = vtkSmartPointer::New(); vtkSmartPointer ySpline = vtkSmartPointer::New(); vtkSmartPointer zSpline = vtkSmartPointer::New(); xSpline->SetDefaultBias(bias); xSpline->SetDefaultTension(tension); xSpline->SetDefaultContinuity(continuity); ySpline->SetDefaultBias(bias); ySpline->SetDefaultTension(tension); ySpline->SetDefaultContinuity(continuity); zSpline->SetDefaultBias(bias); zSpline->SetDefaultTension(tension); zSpline->SetDefaultContinuity(continuity); vtkSmartPointer spline = vtkSmartPointer::New(); spline->SetXSpline(xSpline); spline->SetYSpline(ySpline); spline->SetZSpline(zSpline); spline->SetPoints(newPoints); vtkSmartPointer functionSource = vtkSmartPointer::New(); functionSource->SetParametricFunction(spline); functionSource->SetUResolution(sampling); functionSource->SetVResolution(sampling); functionSource->SetWResolution(sampling); functionSource->Update(); vtkPolyData* outputFunction = functionSource->GetOutput(); vtkPoints* tmpSmoothPnts = outputFunction->GetPoints(); //smoothPoints of current fiber vtkSmartPointer smoothLine = vtkSmartPointer::New(); smoothLine->GetPointIds()->SetNumberOfIds(tmpSmoothPnts->GetNumberOfPoints()); for (int j=0; jGetNumberOfPoints(); j++) { smoothLine->GetPointIds()->SetId(j, j+pointHelperCnt); vtkSmoothPoints->InsertNextPoint(tmpSmoothPnts->GetPoint(j)); } vtkSmoothCells->InsertNextCell(smoothLine); pointHelperCnt += tmpSmoothPnts->GetNumberOfPoints(); } m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkSmoothPoints); m_FiberPolyData->SetLines(vtkSmoothCells); this->SetFiberPolyData(m_FiberPolyData, true); m_FiberSampling = 10/pointDistance; } void mitk::FiberBundleX::ResampleSpline(float pointDistance) { ResampleSpline(pointDistance, 0, 0, 0 ); } unsigned long mitk::FiberBundleX::GetNumberOfPoints() { unsigned long points = 0; for (int i=0; iGetNumberOfCells(); i++) { vtkCell* cell = m_FiberPolyData->GetCell(i); points += cell->GetNumberOfPoints(); } return points; } void mitk::FiberBundleX::Compress(float error) { vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); vtkSmartPointer vtkNewCells = vtkSmartPointer::New(); MITK_INFO << "Compressing fibers"; unsigned long numRemovedPoints = 0; boost::progress_display disp(m_FiberPolyData->GetNumberOfCells()); for (int i=0; iGetNumberOfCells(); i++) { ++disp; vtkCell* cell = m_FiberPolyData->GetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); // calculate curvatures std::vector< int > removedPoints; removedPoints.resize(numPoints, 0); removedPoints[0]=-1; removedPoints[numPoints-1]=-1; vtkSmartPointer container = vtkSmartPointer::New(); bool pointFound = true; while (pointFound) { pointFound = false; double minError = error; int removeIndex = -1; for (int j=0; jGetPoint(j, cand); vnl_vector_fixed< double, 3 > candV; candV[0]=cand[0]; candV[1]=cand[1]; candV[2]=cand[2]; int validP = -1; vnl_vector_fixed< double, 3 > pred; for (int k=j-1; k>=0; k--) if (removedPoints[k]<=0) { double ref[3]; points->GetPoint(k, ref); pred[0]=ref[0]; pred[1]=ref[1]; pred[2]=ref[2]; validP = k; break; } int validS = -1; vnl_vector_fixed< double, 3 > succ; for (int k=j+1; kGetPoint(k, ref); succ[0]=ref[0]; succ[1]=ref[1]; succ[2]=ref[2]; validS = k; break; } if (validP>=0 && validS>=0) { double a = (candV-pred).magnitude(); double b = (candV-succ).magnitude(); double c = (pred-succ).magnitude(); double s=0.5*(a+b+c); double hc=(2.0/c)*sqrt(fabs(s*(s-a)*(s-b)*(s-c))); if (hcGetPoint(j, cand); vtkIdType id = vtkNewPoints->InsertNextPoint(cand); container->GetPointIds()->InsertNextId(id); } } vtkNewCells->InsertNextCell(container); } if (vtkNewCells->GetNumberOfCells()>0) { MITK_INFO << "Removed points: " << numRemovedPoints; m_FiberPolyData = vtkSmartPointer::New(); m_FiberPolyData->SetPoints(vtkNewPoints); m_FiberPolyData->SetLines(vtkNewCells); this->SetFiberPolyData(m_FiberPolyData, true); } } -// reapply selected colorcoding in case polydata structure has changed -void mitk::FiberBundleX::UpdateColorCoding() -{ - char* cc = GetCurrentColorCoding(); - - if( strcmp (COLORCODING_ORIENTATION_BASED,cc) == 0 ) - DoColorCodingOrientationBased(); - else if( strcmp (COLORCODING_FA_BASED,cc) == 0 ) - DoColorCodingFaBased(); -} - // reapply selected colorcoding in case polydata structure has changed bool mitk::FiberBundleX::Equals(mitk::FiberBundleX* fib, double eps) { if (fib==NULL) { MITK_INFO << "Reference bundle is NULL!"; return false; } if (m_NumFibers!=fib->GetNumFibers()) { MITK_INFO << "Unequal number of fibers!"; MITK_INFO << m_NumFibers << " vs. " << fib->GetNumFibers(); return false; } for (int i=0; iGetCell(i); int numPoints = cell->GetNumberOfPoints(); vtkPoints* points = cell->GetPoints(); vtkCell* cell2 = fib->GetFiberPolyData()->GetCell(i); int numPoints2 = cell2->GetNumberOfPoints(); vtkPoints* points2 = cell2->GetPoints(); if (numPoints2!=numPoints) { MITK_INFO << "Unequal number of points in fiber " << i << "!"; MITK_INFO << numPoints2 << " vs. " << numPoints; return false; } for (int j=0; jGetPoint(j); double* p2 = points2->GetPoint(j); if (fabs(p1[0]-p2[0])>eps || fabs(p1[1]-p2[1])>eps || fabs(p1[2]-p2[2])>eps) { MITK_INFO << "Unequal points in fiber " << i << " at position " << j << "!"; MITK_INFO << "p1: " << p1[0] << ", " << p1[1] << ", " << p1[2]; MITK_INFO << "p2: " << p2[0] << ", " << p2[1] << ", " << p2[2]; return false; } } } return true; } /* ESSENTIAL IMPLEMENTATION OF SUPERCLASS METHODS */ void mitk::FiberBundleX::UpdateOutputInformation() { } void mitk::FiberBundleX::SetRequestedRegionToLargestPossibleRegion() { } bool mitk::FiberBundleX::RequestedRegionIsOutsideOfTheBufferedRegion() { return false; } bool mitk::FiberBundleX::VerifyRequestedRegion() { return true; } void mitk::FiberBundleX::SetRequestedRegion(const itk::DataObject* ) { } diff --git a/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.h b/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.h index 76d23c5d77..37d44ad5f2 100644 --- a/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.h +++ b/Modules/DiffusionImaging/FiberTracking/IODataStructures/FiberBundleX/mitkFiberBundleX.h @@ -1,184 +1,178 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _MITK_FiberBundleX_H #define _MITK_FiberBundleX_H //includes for MITK datastructure #include #include #include //includes storing fiberdata #include #include #include #include #include #include //#include #include #include #include namespace mitk { /** * \brief Base Class for Fiber Bundles; */ class MitkFiberTracking_EXPORT FiberBundleX : public BaseData { public: typedef itk::Image ItkUcharImgType; // fiber colorcodings - static const char* COLORCODING_ORIENTATION_BASED; - static const char* COLORCODING_FA_BASED; - static const char* COLORCODING_CUSTOM; static const char* FIBER_ID_ARRAY; virtual void UpdateOutputInformation(); virtual void SetRequestedRegionToLargestPossibleRegion(); virtual bool RequestedRegionIsOutsideOfTheBufferedRegion(); virtual bool VerifyRequestedRegion(); virtual void SetRequestedRegion(const itk::DataObject*); mitkClassMacro( FiberBundleX, BaseData ) itkFactorylessNewMacro(Self) itkCloneMacro(Self) mitkNewMacro1Param(Self, vtkSmartPointer) // custom constructor // colorcoding related methods - void SetColorCoding(const char*); - void SetFAMap(mitk::Image::Pointer); + void ColorFibersByScalarMap(mitk::Image::Pointer, bool opacity); template - void SetFAMap(const mitk::PixelType pixelType, mitk::Image::Pointer); + void ColorFibersByScalarMap(const mitk::PixelType pixelType, mitk::Image::Pointer, bool opacity); void DoColorCodingOrientationBased(); - void DoColorCodingFaBased(); - void DoUseFaFiberOpacity(); + void SetFiberOpacity(vtkDoubleArray *FAValArray); void ResetFiberOpacity(); + void SetFiberColors(vtkSmartPointer fiberColors); + void SetFiberColors(float r, float g, float b, float alpha=255); + vtkSmartPointer GetFiberColors() const { return m_FiberColors; } // fiber compression void Compress(float error = 0.0); // fiber resampling void ResampleSpline(float pointDistance=1); void ResampleSpline(float pointDistance, double tension, double continuity, double bias ); bool RemoveShortFibers(float lengthInMM); bool RemoveLongFibers(float lengthInMM); bool ApplyCurvatureThreshold(float minRadius, bool deleteFibers); void MirrorFibers(unsigned int axis); void RotateAroundAxis(double x, double y, double z); void TranslateFibers(double x, double y, double z); void ScaleFibers(double x, double y, double z, bool subtractCenter=true); void TransformFibers(double rx, double ry, double rz, double tx, double ty, double tz); void RemoveDir(vnl_vector_fixed dir, double threshold); itk::Point TransformPoint(vnl_vector_fixed< double, 3 > point, double rx, double ry, double rz, double tx, double ty, double tz); itk::Matrix< double, 3, 3 > TransformMatrix(itk::Matrix< double, 3, 3 > m, double rx, double ry, double rz); // add/subtract fibers FiberBundleX::Pointer AddBundle(FiberBundleX* fib); FiberBundleX::Pointer SubtractBundle(FiberBundleX* fib); // fiber subset extraction FiberBundleX::Pointer ExtractFiberSubset(BaseData* roi); std::vector ExtractFiberIdSubset(BaseData* roi); FiberBundleX::Pointer ExtractFiberSubset(ItkUcharImgType* mask, bool anyPoint, bool invert=false); FiberBundleX::Pointer RemoveFibersOutside(ItkUcharImgType* mask, bool invert=false); vtkSmartPointer GeneratePolyDataByIds( std::vector ); // TODO: make protected void GenerateFiberIds(); // TODO: make protected // get/set data vtkSmartPointer GetFiberWeights() const { return m_FiberWeights; } float GetFiberWeight(unsigned int fiber); void SetFiberWeights(float newWeight); void SetFiberWeight(unsigned int fiber, float weight); void SetFiberWeights(vtkSmartPointer weights); void SetFiberPolyData(vtkSmartPointer, bool updateGeometry = true); vtkSmartPointer GetFiberPolyData() const; - std::vector< std::string > GetAvailableColorCodings(); - char* GetCurrentColorCoding(); itkGetMacro( NumFibers, int) //itkGetMacro( FiberSampling, int) int GetNumFibers() const {return m_NumFibers;} itkGetMacro( MinFiberLength, float ) itkGetMacro( MaxFiberLength, float ) itkGetMacro( MeanFiberLength, float ) itkGetMacro( MedianFiberLength, float ) itkGetMacro( LengthStDev, float ) itkGetMacro( UpdateTime2D, itk::TimeStamp ) itkGetMacro( UpdateTime3D, itk::TimeStamp ) void RequestUpdate2D(){ m_UpdateTime2D.Modified(); } void RequestUpdate3D(){ m_UpdateTime3D.Modified(); } + void RequestUpdate(){ m_UpdateTime2D.Modified(); m_UpdateTime3D.Modified(); } unsigned long GetNumberOfPoints(); // copy fiber bundle mitk::FiberBundleX::Pointer GetDeepCopy(); // compare fiber bundles bool Equals(FiberBundleX* fib, double eps=0.0001); itkSetMacro( ReferenceGeometry, mitk::BaseGeometry::Pointer ) itkGetConstMacro( ReferenceGeometry, mitk::BaseGeometry::Pointer ) protected: FiberBundleX( vtkPolyData* fiberPolyData = NULL ); virtual ~FiberBundleX(); itk::Point GetItkPoint(double point[3]); // calculate geometry from fiber extent void UpdateFiberGeometry(); - // calculate colorcoding values according to m_CurrentColorCoding - void UpdateColorCoding(); - private: // actual fiber container vtkSmartPointer m_FiberPolyData; // contains fiber ids vtkSmartPointer m_FiberIdDataSet; - char* m_CurrentColorCoding; int m_NumFibers; + vtkSmartPointer m_FiberColors; vtkSmartPointer m_FiberWeights; std::vector< float > m_FiberLengths; float m_MinFiberLength; float m_MaxFiberLength; float m_MeanFiberLength; float m_MedianFiberLength; float m_LengthStDev; int m_FiberSampling; itk::TimeStamp m_UpdateTime2D; itk::TimeStamp m_UpdateTime3D; mitk::BaseGeometry::Pointer m_ReferenceGeometry; }; } // namespace mitk #endif /* _MITK_FiberBundleX_H */ diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp index 50cfe086bc..cc6b0cb384 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp @@ -1,1839 +1,1869 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkControlVisualizationPropertiesView.h" #include "mitkNodePredicateDataType.h" #include "mitkDataNodeObject.h" #include "mitkOdfNormalizationMethodProperty.h" #include "mitkOdfScaleByProperty.h" #include "mitkResliceMethodProperty.h" #include "mitkRenderingManager.h" #include "mitkTbssImage.h" #include "mitkPlanarFigure.h" #include "mitkFiberBundleX.h" #include "QmitkDataStorageComboBox.h" #include "QmitkStdMultiWidget.h" #include "mitkFiberBundleInteractor.h" #include "mitkPlanarFigureInteractor.h" #include #include #include #include #include #include "mitkGlobalInteraction.h" #include "usModuleRegistry.h" #include "mitkPlaneGeometry.h" #include "berryIWorkbenchWindow.h" #include "berryIWorkbenchPage.h" #include "berryISelectionService.h" #include "berryConstants.h" #include "berryPlatformUI.h" #include "itkRGBAPixel.h" #include #include "qwidgetaction.h" #include "qcolordialog.h" +#include #include #define ROUND(a) ((a)>0 ? (int)((a)+0.5) : -(int)(0.5-(a))) static bool DetermineAffectedImageSlice( const mitk::Image* image, const mitk::PlaneGeometry* plane, int& affectedDimension, int& affectedSlice ) { - assert(image); - assert(plane); - - // compare normal of plane to the three axis vectors of the image - mitk::Vector3D normal = plane->GetNormal(); - mitk::Vector3D imageNormal0 = image->GetSlicedGeometry()->GetAxisVector(0); - mitk::Vector3D imageNormal1 = image->GetSlicedGeometry()->GetAxisVector(1); - mitk::Vector3D imageNormal2 = image->GetSlicedGeometry()->GetAxisVector(2); - - normal.Normalize(); - imageNormal0.Normalize(); - imageNormal1.Normalize(); - imageNormal2.Normalize(); - - imageNormal0.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal0.GetVnlVector()) ); - imageNormal1.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal1.GetVnlVector()) ); - imageNormal2.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal2.GetVnlVector()) ); - - double eps( 0.00001 ); - // axial - if ( imageNormal2.GetNorm() <= eps ) - { - affectedDimension = 2; - } - // sagittal - else if ( imageNormal1.GetNorm() <= eps ) - { - affectedDimension = 1; - } - // frontal - else if ( imageNormal0.GetNorm() <= eps ) - { - affectedDimension = 0; - } - else - { - affectedDimension = -1; // no idea - return false; - } - - // determine slice number in image - mitk::BaseGeometry* imageGeometry = image->GetGeometry(0); - mitk::Point3D testPoint = imageGeometry->GetCenter(); - mitk::Point3D projectedPoint; - plane->Project( testPoint, projectedPoint ); - - mitk::Point3D indexPoint; - - imageGeometry->WorldToIndex( projectedPoint, indexPoint ); - affectedSlice = ROUND( indexPoint[affectedDimension] ); - MITK_DEBUG << "indexPoint " << indexPoint << " affectedDimension " << affectedDimension << " affectedSlice " << affectedSlice; - - // check if this index is still within the image - if ( affectedSlice < 0 || affectedSlice >= static_cast(image->GetDimension(affectedDimension)) ) return false; - - return true; -} - -const std::string QmitkControlVisualizationPropertiesView::VIEW_ID = "org.mitk.views.controlvisualizationpropertiesview"; - -using namespace berry; - -struct CvpSelListener : ISelectionListener -{ - - berryObjectMacro(CvpSelListener); - - CvpSelListener(QmitkControlVisualizationPropertiesView* view) - { - m_View = view; - } - - void ApplySettings(mitk::DataNode::Pointer node) - { - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) + assert(image); + assert(plane); + + // compare normal of plane to the three axis vectors of the image + mitk::Vector3D normal = plane->GetNormal(); + mitk::Vector3D imageNormal0 = image->GetSlicedGeometry()->GetAxisVector(0); + mitk::Vector3D imageNormal1 = image->GetSlicedGeometry()->GetAxisVector(1); + mitk::Vector3D imageNormal2 = image->GetSlicedGeometry()->GetAxisVector(2); + + normal.Normalize(); + imageNormal0.Normalize(); + imageNormal1.Normalize(); + imageNormal2.Normalize(); + + imageNormal0.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal0.GetVnlVector()) ); + imageNormal1.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal1.GetVnlVector()) ); + imageNormal2.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal2.GetVnlVector()) ); + + double eps( 0.00001 ); + // axial + if ( imageNormal2.GetNorm() <= eps ) { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; + affectedDimension = 2; + } + // sagittal + else if ( imageNormal1.GetNorm() <= eps ) + { + affectedDimension = 1; + } + // frontal + else if ( imageNormal0.GetNorm() <= eps ) + { + affectedDimension = 0; } else { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; + affectedDimension = -1; // no idea + return false; } - int val; - node->GetIntProperty("ShowMaxNumber", val); - m_View->m_Controls->m_ShowMaxNumber->setValue(val); + // determine slice number in image + mitk::BaseGeometry* imageGeometry = image->GetGeometry(0); + mitk::Point3D testPoint = imageGeometry->GetCenter(); + mitk::Point3D projectedPoint; + plane->Project( testPoint, projectedPoint ); - m_View->m_Controls->m_NormalizationDropdown->setCurrentIndex(dynamic_cast(node->GetProperty("Normalization"))->GetValueAsId()); + mitk::Point3D indexPoint; - float fval; - node->GetFloatProperty("Scaling",fval); - m_View->m_Controls->m_ScalingFactor->setValue(fval); + imageGeometry->WorldToIndex( projectedPoint, indexPoint ); + affectedSlice = ROUND( indexPoint[affectedDimension] ); + MITK_DEBUG << "indexPoint " << indexPoint << " affectedDimension " << affectedDimension << " affectedSlice " << affectedSlice; - m_View->m_Controls->m_AdditionalScaling->setCurrentIndex(dynamic_cast(node->GetProperty("ScaleBy"))->GetValueAsId()); + // check if this index is still within the image + if ( affectedSlice < 0 || affectedSlice >= static_cast(image->GetDimension(affectedDimension)) ) return false; - node->GetFloatProperty("IndexParam1",fval); - m_View->m_Controls->m_IndexParam1->setValue(fval); - - node->GetFloatProperty("IndexParam2",fval); - m_View->m_Controls->m_IndexParam2->setValue(fval); - } + return true; +} - void DoSelectionChanged(ISelection::ConstPointer selection) - { - // save current selection in member variable - m_View->m_CurrentSelection = selection.Cast(); +const std::string QmitkControlVisualizationPropertiesView::VIEW_ID = "org.mitk.views.controlvisualizationpropertiesview"; - m_View->m_Controls->m_VisibleOdfsON_T->setVisible(false); - m_View->m_Controls->m_VisibleOdfsON_S->setVisible(false); - m_View->m_Controls->m_VisibleOdfsON_C->setVisible(false); - m_View->m_Controls->m_TextureIntON->setVisible(false); +using namespace berry; - m_View->m_Controls->m_ImageControlsFrame->setVisible(false); - m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(false); - m_View->m_Controls->m_BundleControlsFrame->setVisible(false); - m_View->m_SelectedNode = 0; +struct CvpSelListener : ISelectionListener +{ - if(m_View->m_CurrentSelection.IsNull()) - return; + berryObjectMacro(CvpSelListener); - if(m_View->m_CurrentSelection->Size() == 1) + CvpSelListener(QmitkControlVisualizationPropertiesView* view) { - mitk::DataNodeObject::Pointer nodeObj = m_View->m_CurrentSelection->Begin()->Cast(); - if(nodeObj.IsNotNull()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - mitk::BaseData* nodeData = node->GetData(); + m_View = view; + } - if(nodeData != NULL ) + void ApplySettings(mitk::DataNode::Pointer node) + { + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) { - if(dynamic_cast(nodeData) != 0) - { - m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(true); - m_View->m_SelectedNode = node; - - float val; - node->GetFloatProperty("planarfigure.line.width", val); - m_View->m_Controls->m_PFWidth->setValue((int)(val*10.0)); - - QString label = "Width %1"; - label = label.arg(val); - m_View->m_Controls->label_pfwidth->setText(label); - - float color[3]; - node->GetColor( color, NULL, "planarfigure.default.line.color"); - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color[0]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[1]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[2]*255.0)); - styleSheet.append(")"); - m_View->m_Controls->m_PFColor->setAutoFillBackground(true); - m_View->m_Controls->m_PFColor->setStyleSheet(styleSheet); - - node->GetColor( color, NULL, "color"); - styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color[0]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[1]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[2]*255.0)); - styleSheet.append(")"); - - m_View->PlanarFigureFocus(); - } - - if(dynamic_cast(nodeData) != 0) - { - m_View->m_Controls->m_BundleControlsFrame->setVisible(true); - m_View->m_SelectedNode = node; - - if(m_View->m_CurrentPickingNode != 0 && node.GetPointer() != m_View->m_CurrentPickingNode) - { - m_View->m_Controls->m_Crosshair->setEnabled(false); - } - else - { - m_View->m_Controls->m_Crosshair->setEnabled(true); - } + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } - int width; - node->GetIntProperty("LineWidth", width); - m_View->m_Controls->m_LineWidth->setValue(width); + int val; + node->GetIntProperty("ShowMaxNumber", val); + m_View->m_Controls->m_ShowMaxNumber->setValue(val); - float range; - node->GetFloatProperty("Fiber2DSliceThickness",range); - mitk::FiberBundleX::Pointer fib = dynamic_cast(node->GetData()); - mitk::BaseGeometry::Pointer geo = fib->GetGeometry(); - mitk::ScalarType max = geo->GetExtentInMM(0); - max = std::max(max, geo->GetExtentInMM(1)); - max = std::max(max, geo->GetExtentInMM(2)); + m_View->m_Controls->m_NormalizationDropdown->setCurrentIndex(dynamic_cast(node->GetProperty("Normalization"))->GetValueAsId()); - m_View->m_Controls->m_FiberThicknessSlider->setMaximum(max * 10); + float fval; + node->GetFloatProperty("Scaling",fval); + m_View->m_Controls->m_ScalingFactor->setValue(fval); - m_View->m_Controls->m_FiberThicknessSlider->setValue(range * 10); + m_View->m_Controls->m_AdditionalScaling->setCurrentIndex(dynamic_cast(node->GetProperty("ScaleBy"))->GetValueAsId()); - } + node->GetFloatProperty("IndexParam1",fval); + m_View->m_Controls->m_IndexParam1->setValue(fval); - } // check node data != NULL - } + node->GetFloatProperty("IndexParam2",fval); + m_View->m_Controls->m_IndexParam2->setValue(fval); } - if(m_View->m_CurrentSelection->Size() > 0 && m_View->m_SelectedNode == 0) + void DoSelectionChanged(ISelection::ConstPointer selection) { - m_View->m_Controls->m_ImageControlsFrame->setVisible(true); - - bool foundDiffusionImage = false; - bool foundQBIVolume = false; - bool foundTensorVolume = false; - bool foundImage = false; - bool foundMultipleOdfImages = false; - bool foundRGBAImage = false; - bool foundTbssImage = false; - - // do something with the selected items - if(m_View->m_CurrentSelection) - { - // iterate selection - for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); - i != m_View->m_CurrentSelection->End(); ++i) - { + // save current selection in member variable + m_View->m_CurrentSelection = selection.Cast(); - // extract datatree node - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + m_View->m_Controls->m_VisibleOdfsON_T->setVisible(false); + m_View->m_Controls->m_VisibleOdfsON_S->setVisible(false); + m_View->m_Controls->m_VisibleOdfsON_C->setVisible(false); + m_View->m_Controls->m_TextureIntON->setVisible(false); - mitk::BaseData* nodeData = node->GetData(); + m_View->m_Controls->m_ImageControlsFrame->setVisible(false); + m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(false); + m_View->m_Controls->m_BundleControlsFrame->setVisible(false); + m_View->m_SelectedNode = 0; - if(nodeData != NULL ) + if(m_View->m_CurrentSelection.IsNull()) + return; + + if(m_View->m_CurrentSelection->Size() == 1) + { + mitk::DataNodeObject::Pointer nodeObj = m_View->m_CurrentSelection->Begin()->Cast(); + if(nodeObj.IsNotNull()) { - // only look at interesting types - if(QString("DiffusionImage").compare(nodeData->GetNameOfClass())==0) - { - foundDiffusionImage = true; - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; - } - else - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; - } - int val; - node->GetIntProperty("DisplayChannel", val); - m_View->m_Controls->m_DisplayIndex->setValue(val); - m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); - - QString label = "Channel %1"; - label = label.arg(val); - m_View->m_Controls->label_channel->setText(label); - - mitk::DiffusionPropertyHelper::ImageType::Pointer itkVectorImagePointer = mitk::DiffusionPropertyHelper::ImageType::New(); - mitk::CastToItkImage(dynamic_cast(nodeData), itkVectorImagePointer); - - int maxVal = itkVectorImagePointer->GetVectorLength(); - m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); - m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); - } - - if(QString("TbssImage").compare(nodeData->GetNameOfClass())==0) - { - foundTbssImage = true; - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; - } - else - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; - } - int val; - node->GetIntProperty("DisplayChannel", val); - m_View->m_Controls->m_DisplayIndex->setValue(val); - m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); - - QString label = "Channel %1"; - label = label.arg(val); - m_View->m_Controls->label_channel->setText(label); - - int maxVal = (dynamic_cast(nodeData))->GetImage()->GetVectorLength(); - m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); - m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); - } - - - else if(QString("QBallImage").compare(nodeData->GetNameOfClass())==0) - { - foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; - foundQBIVolume = true; - ApplySettings(node); - } - - else if(QString("TensorImage").compare(nodeData->GetNameOfClass())==0) - { - foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; - foundTensorVolume = true; - ApplySettings(node); - } - - else if(QString("Image").compare(nodeData->GetNameOfClass())==0) - { - foundImage = true; - mitk::Image::Pointer img = dynamic_cast(nodeData); - if(img.IsNotNull() - && img->GetPixelType().GetPixelType() == itk::ImageIOBase::RGBA - && img->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR ) - { - foundRGBAImage = true; - } + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + mitk::BaseData* nodeData = node->GetData(); + + if(nodeData != NULL ) { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; - } - else + if(dynamic_cast(nodeData) != 0) + { + m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(true); + m_View->m_SelectedNode = node; + + float val; + node->GetFloatProperty("planarfigure.line.width", val); + m_View->m_Controls->m_PFWidth->setValue((int)(val*10.0)); + + QString label = "Width %1"; + label = label.arg(val); + m_View->m_Controls->label_pfwidth->setText(label); + + float color[3]; + node->GetColor( color, NULL, "planarfigure.default.line.color"); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color[0]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[1]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[2]*255.0)); + styleSheet.append(")"); + m_View->m_Controls->m_PFColor->setAutoFillBackground(true); + m_View->m_Controls->m_PFColor->setStyleSheet(styleSheet); + + node->GetColor( color, NULL, "color"); + styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color[0]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[1]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[2]*255.0)); + styleSheet.append(")"); + + m_View->PlanarFigureFocus(); + } + + if(dynamic_cast(nodeData) != 0) + { + m_View->m_Controls->m_BundleControlsFrame->setVisible(true); + m_View->m_SelectedNode = node; + + if(m_View->m_CurrentPickingNode != 0 && node.GetPointer() != m_View->m_CurrentPickingNode) + { + m_View->m_Controls->m_Crosshair->setEnabled(false); + } + else + { + m_View->m_Controls->m_Crosshair->setEnabled(true); + } + + int width; + node->GetIntProperty("LineWidth", width); + m_View->m_Controls->m_LineWidth->setValue(width); + + float range; + node->GetFloatProperty("Fiber2DSliceThickness",range); + mitk::FiberBundleX::Pointer fib = dynamic_cast(node->GetData()); + mitk::BaseGeometry::Pointer geo = fib->GetGeometry(); + mitk::ScalarType max = geo->GetExtentInMM(0); + max = std::max(max, geo->GetExtentInMM(1)); + max = std::max(max, geo->GetExtentInMM(2)); + + m_View->m_Controls->m_FiberThicknessSlider->setMaximum(max * 10); + + m_View->m_Controls->m_FiberThicknessSlider->setValue(range * 10); + } + + } // check node data != NULL + } + } + + if(m_View->m_CurrentSelection->Size() > 0 && m_View->m_SelectedNode == 0) + { + m_View->m_Controls->m_ImageControlsFrame->setVisible(true); + + bool foundDiffusionImage = false; + bool foundQBIVolume = false; + bool foundTensorVolume = false; + bool foundImage = false; + bool foundMultipleOdfImages = false; + bool foundRGBAImage = false; + bool foundTbssImage = false; + + // do something with the selected items + if(m_View->m_CurrentSelection) + { + // iterate selection + for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); + i != m_View->m_CurrentSelection->End(); ++i) { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; - } - } - } // END CHECK node != NULL - } - } - } + // extract datatree node + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + + mitk::BaseData* nodeData = node->GetData(); + + if(nodeData != NULL ) + { + // only look at interesting types + if(QString("DiffusionImage").compare(nodeData->GetNameOfClass())==0) + { + foundDiffusionImage = true; + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } + int val; + node->GetIntProperty("DisplayChannel", val); + m_View->m_Controls->m_DisplayIndex->setValue(val); + m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); + + QString label = "Channel %1"; + label = label.arg(val); + m_View->m_Controls->label_channel->setText(label); + + mitk::DiffusionPropertyHelper::ImageType::Pointer itkVectorImagePointer = mitk::DiffusionPropertyHelper::ImageType::New(); + mitk::CastToItkImage(dynamic_cast(nodeData), itkVectorImagePointer); + + int maxVal = itkVectorImagePointer->GetVectorLength(); + m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); + m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); + } + + if(QString("TbssImage").compare(nodeData->GetNameOfClass())==0) + { + foundTbssImage = true; + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } + int val; + node->GetIntProperty("DisplayChannel", val); + m_View->m_Controls->m_DisplayIndex->setValue(val); + m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); + + QString label = "Channel %1"; + label = label.arg(val); + m_View->m_Controls->label_channel->setText(label); + + int maxVal = (dynamic_cast(nodeData))->GetImage()->GetVectorLength(); + m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); + m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); + } + + + else if(QString("QBallImage").compare(nodeData->GetNameOfClass())==0) + { + foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; + foundQBIVolume = true; + ApplySettings(node); + } + + else if(QString("TensorImage").compare(nodeData->GetNameOfClass())==0) + { + foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; + foundTensorVolume = true; + ApplySettings(node); + } + + else if(QString("Image").compare(nodeData->GetNameOfClass())==0) + { + foundImage = true; + mitk::Image::Pointer img = dynamic_cast(nodeData); + if(img.IsNotNull() + && img->GetPixelType().GetPixelType() == itk::ImageIOBase::RGBA + && img->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR ) + { + foundRGBAImage = true; + } + + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } + } + + } // END CHECK node != NULL + } + } + } - m_View->m_FoundSingleOdfImage = (foundQBIVolume || foundTensorVolume) - && !foundMultipleOdfImages; - m_View->m_Controls->m_NumberGlyphsFrame->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_FoundSingleOdfImage = (foundQBIVolume || foundTensorVolume) + && !foundMultipleOdfImages; + m_View->m_Controls->m_NumberGlyphsFrame->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_NormalizationDropdown->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->label->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_ScalingFactor->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_AdditionalScaling->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_NormalizationScalingFrame->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_NormalizationDropdown->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->label->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_ScalingFactor->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_AdditionalScaling->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_NormalizationScalingFrame->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->OpacMinFrame->setVisible(foundRGBAImage || m_View->m_FoundSingleOdfImage); + m_View->m_Controls->OpacMinFrame->setVisible(foundRGBAImage || m_View->m_FoundSingleOdfImage); - // changed for SPIE paper, Principle curvature scaling - //m_View->m_Controls->params_frame->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->params_frame->setVisible(false); + // changed for SPIE paper, Principle curvature scaling + //m_View->m_Controls->params_frame->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->params_frame->setVisible(false); - m_View->m_Controls->m_VisibleOdfsON_T->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_VisibleOdfsON_S->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_VisibleOdfsON_C->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_VisibleOdfsON_T->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_VisibleOdfsON_S->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_VisibleOdfsON_C->setVisible(m_View->m_FoundSingleOdfImage); - bool foundAnyImage = foundDiffusionImage || - foundQBIVolume || foundTensorVolume || foundImage || foundTbssImage; + bool foundAnyImage = foundDiffusionImage || + foundQBIVolume || foundTensorVolume || foundImage || foundTbssImage; - m_View->m_Controls->m_Reinit->setVisible(foundAnyImage); - m_View->m_Controls->m_TextureIntON->setVisible(foundAnyImage); - m_View->m_Controls->m_TSMenu->setVisible(foundAnyImage); + m_View->m_Controls->m_Reinit->setVisible(foundAnyImage); + m_View->m_Controls->m_TextureIntON->setVisible(foundAnyImage); + m_View->m_Controls->m_TSMenu->setVisible(foundAnyImage); + } } - } - void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) - { - // check, if selection comes from datamanager - if (part) + void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) { - QString partname(part->GetPartName().c_str()); - if(partname.compare("Data Manager")==0) - { + // check, if selection comes from datamanager + if (part) + { + QString partname(part->GetPartName().c_str()); + if(partname.compare("Data Manager")==0) + { - // apply selection - DoSelectionChanged(selection); + // apply selection + DoSelectionChanged(selection); - } + } + } } - } - QmitkControlVisualizationPropertiesView* m_View; + QmitkControlVisualizationPropertiesView* m_View; }; QmitkControlVisualizationPropertiesView::QmitkControlVisualizationPropertiesView() - : QmitkFunctionality(), - m_Controls(NULL), - m_MultiWidget(NULL), - m_NodeUsedForOdfVisualization(NULL), - m_IconTexOFF(new QIcon(":/QmitkDiffusionImaging/texIntOFFIcon.png")), - m_IconTexON(new QIcon(":/QmitkDiffusionImaging/texIntONIcon.png")), - m_IconGlyOFF_T(new QIcon(":/QmitkDiffusionImaging/glyphsoff_T.png")), - m_IconGlyON_T(new QIcon(":/QmitkDiffusionImaging/glyphson_T.png")), - m_IconGlyOFF_C(new QIcon(":/QmitkDiffusionImaging/glyphsoff_C.png")), - m_IconGlyON_C(new QIcon(":/QmitkDiffusionImaging/glyphson_C.png")), - m_IconGlyOFF_S(new QIcon(":/QmitkDiffusionImaging/glyphsoff_S.png")), - m_IconGlyON_S(new QIcon(":/QmitkDiffusionImaging/glyphson_S.png")), - m_CurrentSelection(0), - m_CurrentPickingNode(0), - m_GlyIsOn_S(false), - m_GlyIsOn_C(false), - m_GlyIsOn_T(false), - m_FiberBundleObserverTag(0), - m_Color(NULL) + : QmitkFunctionality(), + m_Controls(NULL), + m_MultiWidget(NULL), + m_NodeUsedForOdfVisualization(NULL), + m_IconTexOFF(new QIcon(":/QmitkDiffusionImaging/texIntOFFIcon.png")), + m_IconTexON(new QIcon(":/QmitkDiffusionImaging/texIntONIcon.png")), + m_IconGlyOFF_T(new QIcon(":/QmitkDiffusionImaging/glyphsoff_T.png")), + m_IconGlyON_T(new QIcon(":/QmitkDiffusionImaging/glyphson_T.png")), + m_IconGlyOFF_C(new QIcon(":/QmitkDiffusionImaging/glyphsoff_C.png")), + m_IconGlyON_C(new QIcon(":/QmitkDiffusionImaging/glyphson_C.png")), + m_IconGlyOFF_S(new QIcon(":/QmitkDiffusionImaging/glyphsoff_S.png")), + m_IconGlyON_S(new QIcon(":/QmitkDiffusionImaging/glyphson_S.png")), + m_CurrentSelection(0), + m_CurrentPickingNode(0), + m_GlyIsOn_S(false), + m_GlyIsOn_C(false), + m_GlyIsOn_T(false), + m_FiberBundleObserverTag(0), + m_FiberBundleObserveOpacityTag(0), + m_Color(NULL) { - currentThickSlicesMode = 1; - m_MyMenu = NULL; - int numThread = itk::MultiThreader::GetGlobalMaximumNumberOfThreads(); - if (numThread > 12) - numThread = 12; - itk::MultiThreader::SetGlobalDefaultNumberOfThreads(numThread); + currentThickSlicesMode = 1; + m_MyMenu = NULL; + int numThread = itk::MultiThreader::GetGlobalMaximumNumberOfThreads(); + if (numThread > 12) + numThread = 12; + itk::MultiThreader::SetGlobalDefaultNumberOfThreads(numThread); } QmitkControlVisualizationPropertiesView::QmitkControlVisualizationPropertiesView(const QmitkControlVisualizationPropertiesView& other) { - Q_UNUSED(other) + Q_UNUSED(other) throw std::runtime_error("Copy constructor not implemented"); } QmitkControlVisualizationPropertiesView::~QmitkControlVisualizationPropertiesView() { - if(m_SlicesRotationObserverTag1 ) - { - mitk::SlicesCoordinator::Pointer coordinator = m_MultiWidget->GetSlicesRotator(); - if( coordinator.IsNotNull() ) - coordinator->RemoveObserver(m_SlicesRotationObserverTag1); - } - if( m_SlicesRotationObserverTag2) - { - mitk::SlicesCoordinator::Pointer coordinator = m_MultiWidget->GetSlicesRotator(); - if( coordinator.IsNotNull() ) - coordinator->RemoveObserver(m_SlicesRotationObserverTag1); - } - - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); + if(m_SlicesRotationObserverTag1 ) + { + mitk::SlicesCoordinator::Pointer coordinator = m_MultiWidget->GetSlicesRotator(); + if( coordinator.IsNotNull() ) + coordinator->RemoveObserver(m_SlicesRotationObserverTag1); + } + if( m_SlicesRotationObserverTag2) + { + mitk::SlicesCoordinator::Pointer coordinator = m_MultiWidget->GetSlicesRotator(); + if( coordinator.IsNotNull() ) + coordinator->RemoveObserver(m_SlicesRotationObserverTag1); + } + + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); } void QmitkControlVisualizationPropertiesView::OnThickSlicesModeSelected( QAction* action ) { - currentThickSlicesMode = action->data().toInt(); - - switch(currentThickSlicesMode) - { - default: - case 1: - this->m_Controls->m_TSMenu->setText("MIP"); - break; - case 2: - this->m_Controls->m_TSMenu->setText("SUM"); - break; - case 3: - this->m_Controls->m_TSMenu->setText("WEIGH"); - break; - } - - mitk::DataNode* n; - n = this->m_MultiWidget->GetWidgetPlane1(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - n = this->m_MultiWidget->GetWidgetPlane2(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - n = this->m_MultiWidget->GetWidgetPlane3(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - - mitk::BaseRenderer::Pointer renderer = - this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer->GetRenderingManager()->RequestUpdateAll(); -} + currentThickSlicesMode = action->data().toInt(); + + switch(currentThickSlicesMode) + { + default: + case 1: + this->m_Controls->m_TSMenu->setText("MIP"); + break; + case 2: + this->m_Controls->m_TSMenu->setText("SUM"); + break; + case 3: + this->m_Controls->m_TSMenu->setText("WEIGH"); + break; + } -void QmitkControlVisualizationPropertiesView::OnTSNumChanged(int num) -{ - if(num==0) - { - mitk::DataNode* n; - n = this->m_MultiWidget->GetWidgetPlane1(); - if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); - if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); - - n = this->m_MultiWidget->GetWidgetPlane2(); - if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); - if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); - - n = this->m_MultiWidget->GetWidgetPlane3(); - if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); - if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); - } - else - { mitk::DataNode* n; - n = this->m_MultiWidget->GetWidgetPlane1(); - if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + n = this->m_MultiWidget->GetWidgetPlane1(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + n = this->m_MultiWidget->GetWidgetPlane2(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + n = this->m_MultiWidget->GetWidgetPlane3(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - n = this->m_MultiWidget->GetWidgetPlane2(); - if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + mitk::BaseRenderer::Pointer renderer = + this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); + if(renderer.IsNotNull()) + { + renderer->SendUpdateSlice(); + } + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); + if(renderer.IsNotNull()) + { + renderer->SendUpdateSlice(); + } + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); + if(renderer.IsNotNull()) + { + renderer->SendUpdateSlice(); + } + renderer->GetRenderingManager()->RequestUpdateAll(); +} - n = this->m_MultiWidget->GetWidgetPlane3(); - if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); - } +void QmitkControlVisualizationPropertiesView::OnTSNumChanged(int num) +{ + if(num==0) + { + mitk::DataNode* n; + n = this->m_MultiWidget->GetWidgetPlane1(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); + + n = this->m_MultiWidget->GetWidgetPlane2(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); + + n = this->m_MultiWidget->GetWidgetPlane3(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); + } + else + { + mitk::DataNode* n; + n = this->m_MultiWidget->GetWidgetPlane1(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + + n = this->m_MultiWidget->GetWidgetPlane2(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + + n = this->m_MultiWidget->GetWidgetPlane3(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + } - m_TSLabel->setText(QString::number(num*2+1)); + m_TSLabel->setText(QString::number(num*2+1)); - mitk::BaseRenderer::Pointer renderer = this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); - if(renderer.IsNotNull()) - renderer->SendUpdateSlice(); + mitk::BaseRenderer::Pointer renderer = this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); + if(renderer.IsNotNull()) + renderer->SendUpdateSlice(); - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); - if(renderer.IsNotNull()) - renderer->SendUpdateSlice(); + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); + if(renderer.IsNotNull()) + renderer->SendUpdateSlice(); - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); - if(renderer.IsNotNull()) - renderer->SendUpdateSlice(); + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); + if(renderer.IsNotNull()) + renderer->SendUpdateSlice(); - renderer->GetRenderingManager()->RequestUpdateAll(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS); + renderer->GetRenderingManager()->RequestUpdateAll(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS); } void QmitkControlVisualizationPropertiesView::CreateQtPartControl(QWidget *parent) { - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkControlVisualizationPropertiesViewControls; - m_Controls->setupUi(parent); - this->CreateConnections(); + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkControlVisualizationPropertiesViewControls; + m_Controls->setupUi(parent); + this->CreateConnections(); - // hide warning (ODFs in rotated planes) - m_Controls->m_lblRotatedPlanesWarning->hide(); + // hide warning (ODFs in rotated planes) + m_Controls->m_lblRotatedPlanesWarning->hide(); - m_MyMenu = new QMenu(parent); + m_MyMenu = new QMenu(parent); - // button for changing rotation mode - m_Controls->m_TSMenu->setMenu( m_MyMenu ); - //m_CrosshairModeButton->setIcon( QIcon( iconCrosshairMode_xpm ) ); + // button for changing rotation mode + m_Controls->m_TSMenu->setMenu( m_MyMenu ); + //m_CrosshairModeButton->setIcon( QIcon( iconCrosshairMode_xpm ) ); - m_Controls->params_frame->setVisible(false); + m_Controls->params_frame->setVisible(false); - QIcon icon5(":/QmitkDiffusionImaging/Refresh_48.png"); - m_Controls->m_Reinit->setIcon(icon5); - m_Controls->m_Focus->setIcon(icon5); + QIcon icon5(":/QmitkDiffusionImaging/Refresh_48.png"); + m_Controls->m_Reinit->setIcon(icon5); + m_Controls->m_Focus->setIcon(icon5); - QIcon iconColor(":/QmitkDiffusionImaging/color24.gif"); - m_Controls->m_PFColor->setIcon(iconColor); - m_Controls->m_Color->setIcon(iconColor); + QIcon iconColor(":/QmitkDiffusionImaging/color24.gif"); + m_Controls->m_PFColor->setIcon(iconColor); + m_Controls->m_Color->setIcon(iconColor); - QIcon iconReset(":/QmitkDiffusionImaging/reset.png"); - m_Controls->m_ResetColoring->setIcon(iconReset); + QIcon iconReset(":/QmitkDiffusionImaging/reset.png"); + m_Controls->m_ResetColoring->setIcon(iconReset); - m_Controls->m_PFColor->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + m_Controls->m_PFColor->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - QIcon iconCrosshair(":/QmitkDiffusionImaging/crosshair.png"); - m_Controls->m_Crosshair->setIcon(iconCrosshair); - // was is los - QIcon iconPaint(":/QmitkDiffusionImaging/paint2.png"); - m_Controls->m_TDI->setIcon(iconPaint); + QIcon iconCrosshair(":/QmitkDiffusionImaging/crosshair.png"); + m_Controls->m_Crosshair->setIcon(iconCrosshair); + // was is los + QIcon iconPaint(":/QmitkDiffusionImaging/paint2.png"); + m_Controls->m_TDI->setIcon(iconPaint); - QIcon iconFiberFade(":/QmitkDiffusionImaging/MapperEfx2D.png"); - m_Controls->m_FiberFading2D->setIcon(iconFiberFade); + QIcon iconFiberFade(":/QmitkDiffusionImaging/MapperEfx2D.png"); + m_Controls->m_FiberFading2D->setIcon(iconFiberFade); - m_Controls->m_TextureIntON->setCheckable(true); + m_Controls->m_TextureIntON->setCheckable(true); #ifndef DIFFUSION_IMAGING_EXTENDED - int size = m_Controls->m_AdditionalScaling->count(); - for(int t=0; tm_AdditionalScaling->itemText(t).toStdString() == "Scale by ASR") - { - m_Controls->m_AdditionalScaling->removeItem(t); - } - } + int size = m_Controls->m_AdditionalScaling->count(); + for(int t=0; tm_AdditionalScaling->itemText(t).toStdString() == "Scale by ASR") + { + m_Controls->m_AdditionalScaling->removeItem(t); + } + } #endif - m_Controls->m_OpacitySlider->setRange(0.0,1.0); - m_Controls->m_OpacitySlider->setMinimumValue(0.0); - m_Controls->m_OpacitySlider->setMaximumValue(0.0); - - m_Controls->m_ScalingFrame->setVisible(false); - m_Controls->m_NormalizationFrame->setVisible(false); - } - - m_IsInitialized = false; - m_SelListener = berry::ISelectionListener::Pointer(new CvpSelListener(this)); - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); - m_IsInitialized = true; + m_Controls->m_OpacitySlider->setRange(0.0,1.0); + m_Controls->m_OpacitySlider->setMinimumValue(0.0); + m_Controls->m_OpacitySlider->setMaximumValue(0.0); + + m_Controls->m_ScalingFrame->setVisible(false); + m_Controls->m_NormalizationFrame->setVisible(false); + } + + m_IsInitialized = false; + m_SelListener = berry::ISelectionListener::Pointer(new CvpSelListener(this)); + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); + m_IsInitialized = true; } void QmitkControlVisualizationPropertiesView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { - m_MultiWidget = &stdMultiWidget; + m_MultiWidget = &stdMultiWidget; - if (m_MultiWidget) - { - mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); - if (coordinator) + if (m_MultiWidget) { - itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); - command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); - m_SlicesRotationObserverTag1 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); - } + mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); + if (coordinator) + { + itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); + command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); + m_SlicesRotationObserverTag1 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + } - coordinator = m_MultiWidget->GetSlicesSwiveller(); - if (coordinator) - { - itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); - command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); - m_SlicesRotationObserverTag2 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + coordinator = m_MultiWidget->GetSlicesSwiveller(); + if (coordinator) + { + itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); + command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); + m_SlicesRotationObserverTag2 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + } } - } } void QmitkControlVisualizationPropertiesView::SliceRotation(const itk::EventObject&) { - // test if plane rotated - if( m_GlyIsOn_T || m_GlyIsOn_C || m_GlyIsOn_S ) - { - if( this->IsPlaneRotated() ) - { - // show label - m_Controls->m_lblRotatedPlanesWarning->show(); - } - else + // test if plane rotated + if( m_GlyIsOn_T || m_GlyIsOn_C || m_GlyIsOn_S ) { - //hide label - m_Controls->m_lblRotatedPlanesWarning->hide(); + if( this->IsPlaneRotated() ) + { + // show label + m_Controls->m_lblRotatedPlanesWarning->show(); + } + else + { + //hide label + m_Controls->m_lblRotatedPlanesWarning->hide(); + } } - } } void QmitkControlVisualizationPropertiesView::StdMultiWidgetNotAvailable() { - m_MultiWidget = NULL; + m_MultiWidget = NULL; } void QmitkControlVisualizationPropertiesView::NodeRemoved(const mitk::DataNode* node) { } #include void QmitkControlVisualizationPropertiesView::CreateConnections() { - if ( m_Controls ) - { - connect( (QObject*)(m_Controls->m_DisplayIndex), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); - connect( (QObject*)(m_Controls->m_DisplayIndexSpinBox), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); - connect( (QObject*)(m_Controls->m_TextureIntON), SIGNAL(clicked()), this, SLOT(TextIntON()) ); - connect( (QObject*)(m_Controls->m_Reinit), SIGNAL(clicked()), this, SLOT(Reinit()) ); - connect( (QObject*)(m_Controls->m_VisibleOdfsON_T), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_T()) ); - connect( (QObject*)(m_Controls->m_VisibleOdfsON_S), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_S()) ); - connect( (QObject*)(m_Controls->m_VisibleOdfsON_C), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_C()) ); - connect( (QObject*)(m_Controls->m_ShowMaxNumber), SIGNAL(editingFinished()), this, SLOT(ShowMaxNumberChanged()) ); - connect( (QObject*)(m_Controls->m_NormalizationDropdown), SIGNAL(currentIndexChanged(int)), this, SLOT(NormalizationDropdownChanged(int)) ); - connect( (QObject*)(m_Controls->m_ScalingFactor), SIGNAL(valueChanged(double)), this, SLOT(ScalingFactorChanged(double)) ); - connect( (QObject*)(m_Controls->m_AdditionalScaling), SIGNAL(currentIndexChanged(int)), this, SLOT(AdditionalScaling(int)) ); - connect( (QObject*)(m_Controls->m_IndexParam1), SIGNAL(valueChanged(double)), this, SLOT(IndexParam1Changed(double)) ); - connect( (QObject*)(m_Controls->m_IndexParam2), SIGNAL(valueChanged(double)), this, SLOT(IndexParam2Changed(double)) ); - connect( (QObject*)(m_Controls->m_ScalingCheckbox), SIGNAL(clicked()), this, SLOT(ScalingCheckbox()) ); - connect( (QObject*)(m_Controls->m_OpacitySlider), SIGNAL(spanChanged(double,double)), this, SLOT(OpacityChanged(double,double)) ); - connect((QObject*) m_Controls->m_Color, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationColor())); - connect((QObject*) m_Controls->m_ResetColoring, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationResetColoring())); - connect((QObject*) m_Controls->m_Focus, SIGNAL(clicked()), (QObject*) this, SLOT(PlanarFigureFocus())); - connect((QObject*) m_Controls->m_FiberFading2D, SIGNAL(clicked()), (QObject*) this, SLOT( Fiber2DfadingEFX() ) ); - connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(sliderReleased()), (QObject*) this, SLOT( FiberSlicingThickness2D() ) ); - connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(valueChanged(int)), (QObject*) this, SLOT( FiberSlicingUpdateLabel(int) )); - connect((QObject*) m_Controls->m_Crosshair, SIGNAL(clicked()), (QObject*) this, SLOT(SetInteractor())); - connect((QObject*) m_Controls->m_PFWidth, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(PFWidth(int))); - connect((QObject*) m_Controls->m_PFColor, SIGNAL(clicked()), (QObject*) this, SLOT(PFColor())); - connect((QObject*) m_Controls->m_TDI, SIGNAL(clicked()), (QObject*) this, SLOT(GenerateTdi())); - connect((QObject*) m_Controls->m_LineWidth, SIGNAL(editingFinished()), (QObject*) this, SLOT(LineWidthChanged())); - } + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->m_DisplayIndex), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); + connect( (QObject*)(m_Controls->m_DisplayIndexSpinBox), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); + connect( (QObject*)(m_Controls->m_TextureIntON), SIGNAL(clicked()), this, SLOT(TextIntON()) ); + connect( (QObject*)(m_Controls->m_Reinit), SIGNAL(clicked()), this, SLOT(Reinit()) ); + connect( (QObject*)(m_Controls->m_VisibleOdfsON_T), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_T()) ); + connect( (QObject*)(m_Controls->m_VisibleOdfsON_S), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_S()) ); + connect( (QObject*)(m_Controls->m_VisibleOdfsON_C), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_C()) ); + connect( (QObject*)(m_Controls->m_ShowMaxNumber), SIGNAL(editingFinished()), this, SLOT(ShowMaxNumberChanged()) ); + connect( (QObject*)(m_Controls->m_NormalizationDropdown), SIGNAL(currentIndexChanged(int)), this, SLOT(NormalizationDropdownChanged(int)) ); + connect( (QObject*)(m_Controls->m_ScalingFactor), SIGNAL(valueChanged(double)), this, SLOT(ScalingFactorChanged(double)) ); + connect( (QObject*)(m_Controls->m_AdditionalScaling), SIGNAL(currentIndexChanged(int)), this, SLOT(AdditionalScaling(int)) ); + connect( (QObject*)(m_Controls->m_IndexParam1), SIGNAL(valueChanged(double)), this, SLOT(IndexParam1Changed(double)) ); + connect( (QObject*)(m_Controls->m_IndexParam2), SIGNAL(valueChanged(double)), this, SLOT(IndexParam2Changed(double)) ); + connect( (QObject*)(m_Controls->m_ScalingCheckbox), SIGNAL(clicked()), this, SLOT(ScalingCheckbox()) ); + connect( (QObject*)(m_Controls->m_OpacitySlider), SIGNAL(spanChanged(double,double)), this, SLOT(OpacityChanged(double,double)) ); + connect((QObject*) m_Controls->m_Color, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationColor())); + connect((QObject*) m_Controls->m_ResetColoring, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationResetColoring())); + connect((QObject*) m_Controls->m_Focus, SIGNAL(clicked()), (QObject*) this, SLOT(PlanarFigureFocus())); + connect((QObject*) m_Controls->m_FiberFading2D, SIGNAL(clicked()), (QObject*) this, SLOT( Fiber2DfadingEFX() ) ); + connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(sliderReleased()), (QObject*) this, SLOT( FiberSlicingThickness2D() ) ); + connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(valueChanged(int)), (QObject*) this, SLOT( FiberSlicingUpdateLabel(int) )); + connect((QObject*) m_Controls->m_Crosshair, SIGNAL(clicked()), (QObject*) this, SLOT(SetInteractor())); + connect((QObject*) m_Controls->m_PFWidth, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(PFWidth(int))); + connect((QObject*) m_Controls->m_PFColor, SIGNAL(clicked()), (QObject*) this, SLOT(PFColor())); + connect((QObject*) m_Controls->m_TDI, SIGNAL(clicked()), (QObject*) this, SLOT(GenerateTdi())); + connect((QObject*) m_Controls->m_LineWidth, SIGNAL(editingFinished()), (QObject*) this, SLOT(LineWidthChanged())); + } } void QmitkControlVisualizationPropertiesView::Activated() { - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); - QmitkFunctionality::Activated(); + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); + QmitkFunctionality::Activated(); } void QmitkControlVisualizationPropertiesView::Deactivated() { - QmitkFunctionality::Deactivated(); + QmitkFunctionality::Deactivated(); } int QmitkControlVisualizationPropertiesView::GetSizeFlags(bool width) { - if(!width) - { - return berry::Constants::MIN | berry::Constants::MAX | berry::Constants::FILL; - } - else - { - return 0; - } + if(!width) + { + return berry::Constants::MIN | berry::Constants::MAX | berry::Constants::FILL; + } + else + { + return 0; + } } int QmitkControlVisualizationPropertiesView::ComputePreferredSize(bool width, int /*availableParallel*/, int /*availablePerpendicular*/, int preferredResult) { - if(width==false) - { - return m_FoundSingleOdfImage ? 120 : 80; - } - else - { - return preferredResult; - } + if(width==false) + { + return m_FoundSingleOdfImage ? 120 : 80; + } + else + { + return preferredResult; + } } // set diffusion image channel to b0 volume void QmitkControlVisualizationPropertiesView::NodeAdded(const mitk::DataNode *node) { - mitk::DataNode* notConst = const_cast(node); + mitk::DataNode* notConst = const_cast(node); - bool isDiffusionImage( mitk::DiffusionPropertyHelper::IsDiffusionWeightedImage( dynamic_cast(node->GetData())) ); + bool isDiffusionImage( mitk::DiffusionPropertyHelper::IsDiffusionWeightedImage( dynamic_cast(node->GetData())) ); - if (isDiffusionImage) - { - mitk::Image::Pointer dimg = dynamic_cast(notConst->GetData()); + if (isDiffusionImage) + { + mitk::Image::Pointer dimg = dynamic_cast(notConst->GetData()); - // if there is no b0 image in the dataset, the GetB0Indices() returns a vector of size 0 - // and hence we cannot set the Property directly to .front() - int displayChannelPropertyValue = 0; - mitk::BValueMapProperty* bmapproperty = static_cast(dimg->GetProperty(mitk::DiffusionPropertyHelper::BVALUEMAPPROPERTYNAME.c_str()).GetPointer() ); - mitk::DiffusionPropertyHelper::BValueMapType map = bmapproperty->GetBValueMap(); - if( map[0].size() > 0) - displayChannelPropertyValue = map[0].front(); + // if there is no b0 image in the dataset, the GetB0Indices() returns a vector of size 0 + // and hence we cannot set the Property directly to .front() + int displayChannelPropertyValue = 0; + mitk::BValueMapProperty* bmapproperty = static_cast(dimg->GetProperty(mitk::DiffusionPropertyHelper::BVALUEMAPPROPERTYNAME.c_str()).GetPointer() ); + mitk::DiffusionPropertyHelper::BValueMapType map = bmapproperty->GetBValueMap(); + if( map[0].size() > 0) + displayChannelPropertyValue = map[0].front(); - notConst->SetIntProperty("DisplayChannel", displayChannelPropertyValue ); - } + notConst->SetIntProperty("DisplayChannel", displayChannelPropertyValue ); + } } /* OnSelectionChanged is registered to SelectionService, therefore no need to implement SelectionService Listener explicitly */ void QmitkControlVisualizationPropertiesView::OnSelectionChanged( std::vector nodes ) { - // deactivate channel slider if no diffusion weighted image or tbss image is selected - m_Controls->m_DisplayIndex->setVisible(false); - m_Controls->m_DisplayIndexSpinBox->setVisible(false); - m_Controls->label_channel->setVisible(false); + // deactivate channel slider if no diffusion weighted image or tbss image is selected + m_Controls->m_DisplayIndex->setVisible(false); + m_Controls->m_DisplayIndexSpinBox->setVisible(false); + m_Controls->label_channel->setVisible(false); - for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) - { - mitk::DataNode::Pointer node = *it; + for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) + { + mitk::DataNode::Pointer node = *it; + + float color[3]; + node->GetColor(color); + m_Controls->m_Color->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color[0]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[1]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[2]*255.0)); + styleSheet.append(")"); + m_Controls->m_Color->setStyleSheet(styleSheet); - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - mitk::BaseData* nodeData = node->GetData(); - if(nodeData == NULL) - continue; + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + mitk::BaseData* nodeData = node->GetData(); + if(nodeData == NULL) + continue; - bool isDiffusionImage( mitk::DiffusionPropertyHelper::IsDiffusionWeightedImage( dynamic_cast(node->GetData())) ); + bool isDiffusionImage( mitk::DiffusionPropertyHelper::IsDiffusionWeightedImage( dynamic_cast(node->GetData())) ); - if (node.IsNotNull() && (dynamic_cast(nodeData) || - isDiffusionImage)) - { - m_Controls->m_DisplayIndex->setVisible(true); - m_Controls->m_DisplayIndexSpinBox->setVisible(true); - m_Controls->label_channel->setVisible(true); - } - else if (node.IsNotNull() && dynamic_cast(node->GetData())) - { - if (m_Color.IsNotNull()) - m_Color->RemoveObserver(m_FiberBundleObserverTag); - - itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); - command->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SetFiberBundleCustomColor ); - m_Color = dynamic_cast(node->GetProperty("color", NULL)); - if (m_Color.IsNotNull()) - m_FiberBundleObserverTag = m_Color->AddObserver( itk::ModifiedEvent(), command ); + if (node.IsNotNull() && (dynamic_cast(nodeData) || + isDiffusionImage)) + { + m_Controls->m_DisplayIndex->setVisible(true); + m_Controls->m_DisplayIndexSpinBox->setVisible(true); + m_Controls->label_channel->setVisible(true); + } + else if (node.IsNotNull() && dynamic_cast(node->GetData())) + { + if (m_Color.IsNotNull()) + m_Color->RemoveObserver(m_FiberBundleObserverTag); + + itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); + command->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SetFiberBundleCustomColor ); + m_Color = dynamic_cast(node->GetProperty("color", NULL)); + if (m_Color.IsNotNull()) + m_FiberBundleObserverTag = m_Color->AddObserver( itk::ModifiedEvent(), command ); + + if (m_Opacity.IsNotNull()) + m_Opacity->RemoveObserver(m_FiberBundleObserveOpacityTag); + itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); + command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SetFiberBundleOpacity ); + m_Opacity = dynamic_cast(node->GetProperty("opacity", NULL)); + if (m_Opacity.IsNotNull()) + m_FiberBundleObserveOpacityTag = m_Opacity->AddObserver( itk::ModifiedEvent(), command2 ); + } } - } - for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) - { - mitk::DataNode::Pointer node = *it; - - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - mitk::BaseData* nodeData = node->GetData(); - if(nodeData == NULL) - continue; - - if( node.IsNotNull() && (dynamic_cast(nodeData) || dynamic_cast(nodeData)) ) + for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) { - if(m_NodeUsedForOdfVisualization.IsNotNull()) - { - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", false); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", false); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", false); - } - m_NodeUsedForOdfVisualization = node; - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + mitk::DataNode::Pointer node = *it; - m_Controls->m_TSMenu->setVisible(false); // deactivate mip etc. for tensor and q-ball images - break; + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + mitk::BaseData* nodeData = node->GetData(); + if(nodeData == NULL) + continue; + + if( node.IsNotNull() && (dynamic_cast(nodeData) || dynamic_cast(nodeData)) ) + { + if(m_NodeUsedForOdfVisualization.IsNotNull()) + { + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", false); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", false); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", false); + } + m_NodeUsedForOdfVisualization = node; + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); + + m_Controls->m_TSMenu->setVisible(false); // deactivate mip etc. for tensor and q-ball images + break; + } + else if( node.IsNotNull() && dynamic_cast(nodeData) ) + m_Controls->m_TSMenu->setVisible(false); + else + m_Controls->m_TSMenu->setVisible(true); } - else if( node.IsNotNull() && dynamic_cast(nodeData) ) - m_Controls->m_TSMenu->setVisible(false); - else - m_Controls->m_TSMenu->setVisible(true); - } - // if selection changes, set the current selction member and call SellListener::DoSelectionChanged - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); + // if selection changes, set the current selction member and call SellListener::DoSelectionChanged + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); - // adapt thick slice controls - // THICK SLICE SUPPORT + // adapt thick slice controls + // THICK SLICE SUPPORT - if( nodes.size() < 1) - return; + if( nodes.size() < 1) + return; - mitk::DataNode::Pointer node = nodes.at(0); + mitk::DataNode::Pointer node = nodes.at(0); - if( node.IsNull() ) - return; + if( node.IsNull() ) + return; - QMenu *myMenu = m_MyMenu; - myMenu->clear(); + QMenu *myMenu = m_MyMenu; + myMenu->clear(); - QActionGroup* thickSlicesActionGroup = new QActionGroup(myMenu); - thickSlicesActionGroup->setExclusive(true); + QActionGroup* thickSlicesActionGroup = new QActionGroup(myMenu); + thickSlicesActionGroup->setExclusive(true); - int currentTSMode = 0; - { - mitk::ResliceMethodProperty::Pointer m = dynamic_cast(node->GetProperty( "reslice.thickslices" )); - if( m.IsNotNull() ) - currentTSMode = m->GetValueAsId(); - } + int currentTSMode = 0; + { + mitk::ResliceMethodProperty::Pointer m = dynamic_cast(node->GetProperty( "reslice.thickslices" )); + if( m.IsNotNull() ) + currentTSMode = m->GetValueAsId(); + } - int maxTS = 30; + int maxTS = 30; - for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) - { - mitk::Image* image = dynamic_cast((*it)->GetData()); - if (image) + for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) { - int size = std::max(image->GetDimension(0), std::max(image->GetDimension(1), image->GetDimension(2))); - if (size>maxTS) - maxTS=size; + mitk::Image* image = dynamic_cast((*it)->GetData()); + if (image) + { + int size = std::max(image->GetDimension(0), std::max(image->GetDimension(1), image->GetDimension(2))); + if (size>maxTS) + maxTS=size; + } } - } - maxTS /= 2; + maxTS /= 2; - int currentNum = 0; - { - mitk::IntProperty::Pointer m = dynamic_cast(node->GetProperty( "reslice.thickslices.num" )); - if( m.IsNotNull() ) + int currentNum = 0; { - currentNum = m->GetValue(); - if(currentNum < 0) currentNum = 0; - if(currentNum > maxTS) currentNum = maxTS; + mitk::IntProperty::Pointer m = dynamic_cast(node->GetProperty( "reslice.thickslices.num" )); + if( m.IsNotNull() ) + { + currentNum = m->GetValue(); + if(currentNum < 0) currentNum = 0; + if(currentNum > maxTS) currentNum = maxTS; + } } - } - if(currentTSMode==0) - currentNum=0; + if(currentTSMode==0) + currentNum=0; - QSlider *m_TSSlider = new QSlider(myMenu); - m_TSSlider->setMinimum(0); - m_TSSlider->setMaximum(maxTS-1); - m_TSSlider->setValue(currentNum); + QSlider *m_TSSlider = new QSlider(myMenu); + m_TSSlider->setMinimum(0); + m_TSSlider->setMaximum(maxTS-1); + m_TSSlider->setValue(currentNum); - m_TSSlider->setOrientation(Qt::Horizontal); + m_TSSlider->setOrientation(Qt::Horizontal); - connect( m_TSSlider, SIGNAL( valueChanged(int) ), this, SLOT( OnTSNumChanged(int) ) ); + connect( m_TSSlider, SIGNAL( valueChanged(int) ), this, SLOT( OnTSNumChanged(int) ) ); - QHBoxLayout* _TSLayout = new QHBoxLayout; - _TSLayout->setContentsMargins(4,4,4,4); - _TSLayout->addWidget(m_TSSlider); - _TSLayout->addWidget(m_TSLabel=new QLabel(QString::number(currentNum*2+1),myMenu)); + QHBoxLayout* _TSLayout = new QHBoxLayout; + _TSLayout->setContentsMargins(4,4,4,4); + _TSLayout->addWidget(m_TSSlider); + _TSLayout->addWidget(m_TSLabel=new QLabel(QString::number(currentNum*2+1),myMenu)); - QWidget* _TSWidget = new QWidget; - _TSWidget->setLayout(_TSLayout); + QWidget* _TSWidget = new QWidget; + _TSWidget->setLayout(_TSLayout); - QActionGroup* thickSliceModeActionGroup = new QActionGroup(myMenu); - thickSliceModeActionGroup->setExclusive(true); + QActionGroup* thickSliceModeActionGroup = new QActionGroup(myMenu); + thickSliceModeActionGroup->setExclusive(true); - QWidgetAction *m_TSSliderAction = new QWidgetAction(myMenu); - m_TSSliderAction->setDefaultWidget(_TSWidget); - myMenu->addAction(m_TSSliderAction); + QWidgetAction *m_TSSliderAction = new QWidgetAction(myMenu); + m_TSSliderAction->setDefaultWidget(_TSWidget); + myMenu->addAction(m_TSSliderAction); - QAction* mipThickSlicesAction = new QAction(myMenu); - mipThickSlicesAction->setActionGroup(thickSliceModeActionGroup); - mipThickSlicesAction->setText("MIP (max. intensity proj.)"); - mipThickSlicesAction->setCheckable(true); - mipThickSlicesAction->setChecked(currentThickSlicesMode==1); - mipThickSlicesAction->setData(1); - myMenu->addAction( mipThickSlicesAction ); + QAction* mipThickSlicesAction = new QAction(myMenu); + mipThickSlicesAction->setActionGroup(thickSliceModeActionGroup); + mipThickSlicesAction->setText("MIP (max. intensity proj.)"); + mipThickSlicesAction->setCheckable(true); + mipThickSlicesAction->setChecked(currentThickSlicesMode==1); + mipThickSlicesAction->setData(1); + myMenu->addAction( mipThickSlicesAction ); - QAction* sumThickSlicesAction = new QAction(myMenu); - sumThickSlicesAction->setActionGroup(thickSliceModeActionGroup); - sumThickSlicesAction->setText("SUM (sum intensity proj.)"); - sumThickSlicesAction->setCheckable(true); - sumThickSlicesAction->setChecked(currentThickSlicesMode==2); - sumThickSlicesAction->setData(2); - myMenu->addAction( sumThickSlicesAction ); + QAction* sumThickSlicesAction = new QAction(myMenu); + sumThickSlicesAction->setActionGroup(thickSliceModeActionGroup); + sumThickSlicesAction->setText("SUM (sum intensity proj.)"); + sumThickSlicesAction->setCheckable(true); + sumThickSlicesAction->setChecked(currentThickSlicesMode==2); + sumThickSlicesAction->setData(2); + myMenu->addAction( sumThickSlicesAction ); - QAction* weightedThickSlicesAction = new QAction(myMenu); - weightedThickSlicesAction->setActionGroup(thickSliceModeActionGroup); - weightedThickSlicesAction->setText("WEIGHTED (gaussian proj.)"); - weightedThickSlicesAction->setCheckable(true); - weightedThickSlicesAction->setChecked(currentThickSlicesMode==3); - weightedThickSlicesAction->setData(3); - myMenu->addAction( weightedThickSlicesAction ); + QAction* weightedThickSlicesAction = new QAction(myMenu); + weightedThickSlicesAction->setActionGroup(thickSliceModeActionGroup); + weightedThickSlicesAction->setText("WEIGHTED (gaussian proj.)"); + weightedThickSlicesAction->setCheckable(true); + weightedThickSlicesAction->setChecked(currentThickSlicesMode==3); + weightedThickSlicesAction->setData(3); + myMenu->addAction( weightedThickSlicesAction ); - connect( thickSliceModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(OnThickSlicesModeSelected(QAction*)) ); + connect( thickSliceModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(OnThickSlicesModeSelected(QAction*)) ); } mitk::DataStorage::SetOfObjects::Pointer - QmitkControlVisualizationPropertiesView::ActiveSet(std::string classname) +QmitkControlVisualizationPropertiesView::ActiveSet(std::string classname) { - if (m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - int at = 0; - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) + if (m_CurrentSelection) { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + int at = 0; + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - const mitk::BaseData* nodeData = node->GetData(); - if(nodeData == NULL) - continue; + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString(classname.c_str()).compare(nodeData->GetNameOfClass())==0) - { - set->InsertElement(at++, node); + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + const mitk::BaseData* nodeData = node->GetData(); + if(nodeData == NULL) + continue; + + if(QString(classname.c_str()).compare(nodeData->GetNameOfClass())==0) + { + set->InsertElement(at++, node); + } + } } - } - } - return set; - } + return set; + } - return 0; + return 0; } void QmitkControlVisualizationPropertiesView::SetBoolProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, bool value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, bool value) { - if(set.IsNotNull()) - { - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetBoolProperty(name.c_str(), value); - ++itemiter; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetBoolProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetIntProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, int value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, int value) { - if(set.IsNotNull()) - { - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetIntProperty(name.c_str(), value); - ++itemiter; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetIntProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetFloatProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, float value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, float value) { - if(set.IsNotNull()) - { - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetFloatProperty(name.c_str(), value); - ++itemiter; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetFloatProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetLevelWindowProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, mitk::LevelWindow value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, mitk::LevelWindow value) { - if(set.IsNotNull()) - { + if(set.IsNotNull()) + { - mitk::LevelWindowProperty::Pointer prop = mitk::LevelWindowProperty::New(value); + mitk::LevelWindowProperty::Pointer prop = mitk::LevelWindowProperty::New(value); - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) - { - (*itemiter)->SetProperty(name.c_str(), prop); - ++itemiter; + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetProperty(name.c_str(), prop); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetEnumProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, mitk::EnumerationProperty::Pointer value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, mitk::EnumerationProperty::Pointer value) { - if(set.IsNotNull()) - { - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetProperty(name.c_str(), value); - ++itemiter; + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::DisplayIndexChanged(int dispIndex) { - m_Controls->m_DisplayIndex->setValue(dispIndex); - m_Controls->m_DisplayIndexSpinBox->setValue(dispIndex); + m_Controls->m_DisplayIndex->setValue(dispIndex); + m_Controls->m_DisplayIndexSpinBox->setValue(dispIndex); - QString label = "Channel %1"; - label = label.arg(dispIndex); - m_Controls->label_channel->setText(label); + QString label = "Channel %1"; + label = label.arg(dispIndex); + m_Controls->label_channel->setText(label); - std::vector sets; - sets.push_back("TbssImage"); + std::vector sets; + sets.push_back("TbssImage"); - std::vector::iterator it = sets.begin(); - while(it != sets.end()) - { - std::string s = *it; - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet(s); - - if(set.IsNotNull()) + std::vector::iterator it = sets.begin(); + while(it != sets.end()) { + std::string s = *it; + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet(s); - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) - { - (*itemiter)->SetIntProperty("DisplayChannel", dispIndex); - ++itemiter; - } + if(set.IsNotNull()) + { - //m_MultiWidget->RequestUpdate(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetIntProperty("DisplayChannel", dispIndex); + ++itemiter; + } - it++; - } + //m_MultiWidget->RequestUpdate(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + + it++; + } } void QmitkControlVisualizationPropertiesView::Reinit() { - if (m_CurrentSelection) - { - mitk::DataNodeObject::Pointer nodeObj = - m_CurrentSelection->Begin()->Cast(); - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - mitk::BaseData::Pointer basedata = node->GetData(); - if (basedata.IsNotNull()) + if (m_CurrentSelection) { - mitk::RenderingManager::GetInstance()->InitializeViews( - basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + mitk::DataNodeObject::Pointer nodeObj = + m_CurrentSelection->Begin()->Cast(); + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + mitk::BaseData::Pointer basedata = node->GetData(); + if (basedata.IsNotNull()) + { + mitk::RenderingManager::GetInstance()->InitializeViews( + basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } } - } } void QmitkControlVisualizationPropertiesView::TextIntON() { - if(m_TexIsOn) - { - m_Controls->m_TextureIntON->setIcon(*m_IconTexOFF); - } - else - { - m_Controls->m_TextureIntON->setIcon(*m_IconTexON); - } + if(m_TexIsOn) + { + m_Controls->m_TextureIntON->setIcon(*m_IconTexOFF); + } + else + { + m_Controls->m_TextureIntON->setIcon(*m_IconTexON); + } - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("DiffusionImage"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("DiffusionImage"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - set = ActiveSet("TensorImage"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + set = ActiveSet("TensorImage"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - set = ActiveSet("QBallImage"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + set = ActiveSet("QBallImage"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - set = ActiveSet("Image"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + set = ActiveSet("Image"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - m_TexIsOn = !m_TexIsOn; + m_TexIsOn = !m_TexIsOn; - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON_S() { - m_GlyIsOn_S = m_Controls->m_VisibleOdfsON_S->isChecked(); - if (m_NodeUsedForOdfVisualization.IsNull()) - { - MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; - return; - } - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); - VisibleOdfsON(0); + m_GlyIsOn_S = m_Controls->m_VisibleOdfsON_S->isChecked(); + if (m_NodeUsedForOdfVisualization.IsNull()) + { + MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; + return; + } + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); + VisibleOdfsON(0); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON_T() { - m_GlyIsOn_T = m_Controls->m_VisibleOdfsON_T->isChecked(); - if (m_NodeUsedForOdfVisualization.IsNull()) - { - MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; - return; - } - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); - VisibleOdfsON(1); + m_GlyIsOn_T = m_Controls->m_VisibleOdfsON_T->isChecked(); + if (m_NodeUsedForOdfVisualization.IsNull()) + { + MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; + return; + } + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); + VisibleOdfsON(1); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON_C() { - m_GlyIsOn_C = m_Controls->m_VisibleOdfsON_C->isChecked(); - if (m_NodeUsedForOdfVisualization.IsNull()) - { - MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; - return; - } - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); - VisibleOdfsON(2); + m_GlyIsOn_C = m_Controls->m_VisibleOdfsON_C->isChecked(); + if (m_NodeUsedForOdfVisualization.IsNull()) + { + MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; + return; + } + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); + VisibleOdfsON(2); } bool QmitkControlVisualizationPropertiesView::IsPlaneRotated() { - // for all 2D renderwindows of m_MultiWidget check alignment - mitk::PlaneGeometry::ConstPointer displayPlane = dynamic_cast( m_MultiWidget->GetRenderWindow1()->GetRenderer()->GetCurrentWorldGeometry2D() ); - if (displayPlane.IsNull()) return false; + // for all 2D renderwindows of m_MultiWidget check alignment + mitk::PlaneGeometry::ConstPointer displayPlane = dynamic_cast( m_MultiWidget->GetRenderWindow1()->GetRenderer()->GetCurrentWorldGeometry2D() ); + if (displayPlane.IsNull()) return false; - mitk::Image* currentImage = dynamic_cast( m_NodeUsedForOdfVisualization->GetData() ); - if( currentImage == NULL ) - { - MITK_ERROR << " Casting problems. Returning false"; - return false; - } + mitk::Image* currentImage = dynamic_cast( m_NodeUsedForOdfVisualization->GetData() ); + if( currentImage == NULL ) + { + MITK_ERROR << " Casting problems. Returning false"; + return false; + } - int affectedDimension(-1); - int affectedSlice(-1); - return !(DetermineAffectedImageSlice( currentImage, displayPlane, affectedDimension, affectedSlice )); + int affectedDimension(-1); + int affectedSlice(-1); + return !(DetermineAffectedImageSlice( currentImage, displayPlane, affectedDimension, affectedSlice )); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON(int view) { - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::ShowMaxNumberChanged() { - int maxNr = m_Controls->m_ShowMaxNumber->value(); - if ( maxNr < 1 ) - { - m_Controls->m_ShowMaxNumber->setValue( 1 ); - maxNr = 1; - } + int maxNr = m_Controls->m_ShowMaxNumber->value(); + if ( maxNr < 1 ) + { + m_Controls->m_ShowMaxNumber->setValue( 1 ); + maxNr = 1; + } - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetIntProp(set,"ShowMaxNumber", maxNr); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetIntProp(set,"ShowMaxNumber", maxNr); - set = ActiveSet("TensorImage"); - SetIntProp(set,"ShowMaxNumber", maxNr); + set = ActiveSet("TensorImage"); + SetIntProp(set,"ShowMaxNumber", maxNr); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::NormalizationDropdownChanged(int normDropdown) { - typedef mitk::OdfNormalizationMethodProperty PropType; - PropType::Pointer normMeth = PropType::New(); - - switch(normDropdown) - { - case 0: - normMeth->SetNormalizationToMinMax(); - break; - case 1: - normMeth->SetNormalizationToMax(); - break; - case 2: - normMeth->SetNormalizationToNone(); - break; - case 3: - normMeth->SetNormalizationToGlobalMax(); - break; - default: - normMeth->SetNormalizationToMinMax(); - } - - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetEnumProp(set,"Normalization", normMeth.GetPointer()); - - set = ActiveSet("TensorImage"); - SetEnumProp(set,"Normalization", normMeth.GetPointer()); - - // if(m_MultiWidget) - // m_MultiWidget->RequestUpdate(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + typedef mitk::OdfNormalizationMethodProperty PropType; + PropType::Pointer normMeth = PropType::New(); + + switch(normDropdown) + { + case 0: + normMeth->SetNormalizationToMinMax(); + break; + case 1: + normMeth->SetNormalizationToMax(); + break; + case 2: + normMeth->SetNormalizationToNone(); + break; + case 3: + normMeth->SetNormalizationToGlobalMax(); + break; + default: + normMeth->SetNormalizationToMinMax(); + } + + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetEnumProp(set,"Normalization", normMeth.GetPointer()); + + set = ActiveSet("TensorImage"); + SetEnumProp(set,"Normalization", normMeth.GetPointer()); + + // if(m_MultiWidget) + // m_MultiWidget->RequestUpdate(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkControlVisualizationPropertiesView::ScalingFactorChanged(double scalingFactor) { - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetFloatProp(set,"Scaling", scalingFactor); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetFloatProp(set,"Scaling", scalingFactor); - set = ActiveSet("TensorImage"); - SetFloatProp(set,"Scaling", scalingFactor); + set = ActiveSet("TensorImage"); + SetFloatProp(set,"Scaling", scalingFactor); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::AdditionalScaling(int additionalScaling) { - typedef mitk::OdfScaleByProperty PropType; - PropType::Pointer scaleBy = PropType::New(); - - switch(additionalScaling) - { - case 0: - scaleBy->SetScaleByNothing(); - break; - case 1: - scaleBy->SetScaleByGFA(); - //m_Controls->params_frame->setVisible(true); - break; + typedef mitk::OdfScaleByProperty PropType; + PropType::Pointer scaleBy = PropType::New(); + + switch(additionalScaling) + { + case 0: + scaleBy->SetScaleByNothing(); + break; + case 1: + scaleBy->SetScaleByGFA(); + //m_Controls->params_frame->setVisible(true); + break; #ifdef DIFFUSION_IMAGING_EXTENDED - case 2: - scaleBy->SetScaleByPrincipalCurvature(); - // commented in for SPIE paper, Principle curvature scaling - //m_Controls->params_frame->setVisible(true); - break; + case 2: + scaleBy->SetScaleByPrincipalCurvature(); + // commented in for SPIE paper, Principle curvature scaling + //m_Controls->params_frame->setVisible(true); + break; #endif - default: - scaleBy->SetScaleByNothing(); - } + default: + scaleBy->SetScaleByNothing(); + } - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); - set = ActiveSet("TensorImage"); - SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); + set = ActiveSet("TensorImage"); + SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::IndexParam1Changed(double param1) { - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetFloatProp(set,"IndexParam1", param1); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetFloatProp(set,"IndexParam1", param1); - set = ActiveSet("TensorImage"); - SetFloatProp(set,"IndexParam1", param1); + set = ActiveSet("TensorImage"); + SetFloatProp(set,"IndexParam1", param1); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::IndexParam2Changed(double param2) { - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetFloatProp(set,"IndexParam2", param2); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetFloatProp(set,"IndexParam2", param2); - set = ActiveSet("TensorImage"); - SetFloatProp(set,"IndexParam2", param2); + set = ActiveSet("TensorImage"); + SetFloatProp(set,"IndexParam2", param2); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::OpacityChanged(double l, double u) { - mitk::LevelWindow olw; - olw.SetRangeMinMax(l*255, u*255); + mitk::LevelWindow olw; + olw.SetRangeMinMax(l*255, u*255); - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetLevelWindowProp(set,"opaclevelwindow", olw); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetLevelWindowProp(set,"opaclevelwindow", olw); - set = ActiveSet("TensorImage"); - SetLevelWindowProp(set,"opaclevelwindow", olw); + set = ActiveSet("TensorImage"); + SetLevelWindowProp(set,"opaclevelwindow", olw); - set = ActiveSet("Image"); - SetLevelWindowProp(set,"opaclevelwindow", olw); + set = ActiveSet("Image"); + SetLevelWindowProp(set,"opaclevelwindow", olw); - m_Controls->m_OpacityMinFaLabel->setText(QString::number(l,'f',2) + " : " + QString::number(u,'f',2)); + m_Controls->m_OpacityMinFaLabel->setText(QString::number(l,'f',2) + " : " + QString::number(u,'f',2)); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::ScalingCheckbox() { - m_Controls->m_ScalingFrame->setVisible( - m_Controls->m_ScalingCheckbox->isChecked()); - - if(!m_Controls->m_ScalingCheckbox->isChecked()) - { - m_Controls->m_AdditionalScaling->setCurrentIndex(0); - m_Controls->m_ScalingFactor->setValue(1.0); - } + m_Controls->m_ScalingFrame->setVisible( + m_Controls->m_ScalingCheckbox->isChecked()); + + if(!m_Controls->m_ScalingCheckbox->isChecked()) + { + m_Controls->m_AdditionalScaling->setCurrentIndex(0); + m_Controls->m_ScalingFactor->setValue(1.0); + } } void QmitkControlVisualizationPropertiesView::Fiber2DfadingEFX() { - if (m_SelectedNode && dynamic_cast(m_SelectedNode->GetData()) ) - { - bool currentMode; - m_SelectedNode->GetBoolProperty("Fiber2DfadeEFX", currentMode); - m_SelectedNode->SetProperty("Fiber2DfadeEFX", mitk::BoolProperty::New(!currentMode)); - dynamic_cast(m_SelectedNode->GetData())->RequestUpdate2D(); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if (m_SelectedNode && dynamic_cast(m_SelectedNode->GetData()) ) + { + bool currentMode; + m_SelectedNode->GetBoolProperty("Fiber2DfadeEFX", currentMode); + m_SelectedNode->SetProperty("Fiber2DfadeEFX", mitk::BoolProperty::New(!currentMode)); + dynamic_cast(m_SelectedNode->GetData())->RequestUpdate2D(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::FiberSlicingThickness2D() { - if (m_SelectedNode && dynamic_cast(m_SelectedNode->GetData())) - { - float fibThickness = m_Controls->m_FiberThicknessSlider->value() * 0.1; - float currentThickness = 0; - m_SelectedNode->GetFloatProperty("Fiber2DSliceThickness", currentThickness); - if (fabs(fibThickness-currentThickness)<0.001) - return; - m_SelectedNode->SetProperty("Fiber2DSliceThickness", mitk::FloatProperty::New(fibThickness)); - dynamic_cast(m_SelectedNode->GetData())->RequestUpdate2D(); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if (m_SelectedNode && dynamic_cast(m_SelectedNode->GetData())) + { + float fibThickness = m_Controls->m_FiberThicknessSlider->value() * 0.1; + float currentThickness = 0; + m_SelectedNode->GetFloatProperty("Fiber2DSliceThickness", currentThickness); + if (fabs(fibThickness-currentThickness)<0.001) + return; + m_SelectedNode->SetProperty("Fiber2DSliceThickness", mitk::FloatProperty::New(fibThickness)); + dynamic_cast(m_SelectedNode->GetData())->RequestUpdate2D(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::FiberSlicingUpdateLabel(int value) { - QString label = "Range %1 mm"; - label = label.arg(value * 0.1); - m_Controls->label_range->setText(label); - this->FiberSlicingThickness2D(); + QString label = "Range %1 mm"; + label = label.arg(value * 0.1); + m_Controls->label_range->setText(label); + this->FiberSlicingThickness2D(); +} + +void QmitkControlVisualizationPropertiesView::SetFiberBundleOpacity(const itk::EventObject& /*e*/) +{ + if(m_SelectedNode) + { + mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); + fib->RequestUpdate(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::SetFiberBundleCustomColor(const itk::EventObject& /*e*/) { - float color[3]; - m_SelectedNode->GetColor(color); - m_Controls->m_Color->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color[0]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[1]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[2]*255.0)); - styleSheet.append(")"); - m_Controls->m_Color->setStyleSheet(styleSheet); - - m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color[0], color[1], color[2])); - mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); - fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_CUSTOM); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + if(m_SelectedNode && dynamic_cast(m_SelectedNode->GetData())) + { + float color[3]; + m_SelectedNode->GetColor(color); + m_Controls->m_Color->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color[0]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[1]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[2]*255.0)); + styleSheet.append(")"); + m_Controls->m_Color->setStyleSheet(styleSheet); + +// m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color[0], color[1], color[2])); + mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); + fib->SetFiberColors(color[0]*255, color[1]*255, color[2]*255); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::BundleRepresentationColor() { - if(m_SelectedNode) - { - QColor color = QColorDialog::getColor(); - if (!color.isValid()) - return; - - m_Controls->m_Color->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color.red())); - styleSheet.append(","); - styleSheet.append(QString::number(color.green())); - styleSheet.append(","); - styleSheet.append(QString::number(color.blue())); - styleSheet.append(")"); - m_Controls->m_Color->setStyleSheet(styleSheet); - - m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); - fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_CUSTOM); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if(m_SelectedNode && dynamic_cast(m_SelectedNode->GetData())) + { + QColor color; + color.setRgba(QColorDialog::getRgba()); + if (!color.isValid()) + return; + + m_Controls->m_Color->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color.red())); + styleSheet.append(","); + styleSheet.append(QString::number(color.green())); + styleSheet.append(","); + styleSheet.append(QString::number(color.blue())); + styleSheet.append(")"); + m_Controls->m_Color->setStyleSheet(styleSheet); + + mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); + m_SelectedNode->SetOpacity(color.alpha()/255.0); + fib->SetFiberColors(color.red(), color.green(), color.blue(), color.alpha()); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::BundleRepresentationResetColoring() { - if(m_SelectedNode) - { - MITK_INFO << "reset colorcoding to oBased"; - m_Controls->m_Color->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb(255,255,255)"; - m_Controls->m_Color->setStyleSheet(styleSheet); - // m_SelectedNode->SetProperty("color",NULL); - m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(1.0, 1.0, 1.0)); - - mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); - fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED); - fib->DoColorCodingOrientationBased(); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if(m_SelectedNode && dynamic_cast(m_SelectedNode->GetData())) + { + m_Controls->m_Color->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb(255,255,255)"; + m_Controls->m_Color->setStyleSheet(styleSheet); + mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); + fib->DoColorCodingOrientationBased(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::PlanarFigureFocus() { - if(m_SelectedNode) - { - mitk::PlanarFigure* _PlanarFigure = 0; - _PlanarFigure = dynamic_cast (m_SelectedNode->GetData()); - - if (_PlanarFigure && _PlanarFigure->GetPlaneGeometry()) + if(m_SelectedNode) { + mitk::PlanarFigure* _PlanarFigure = 0; + _PlanarFigure = dynamic_cast (m_SelectedNode->GetData()); - QmitkRenderWindow* selectedRenderWindow = 0; - bool PlanarFigureInitializedWindow = false; - - QmitkRenderWindow* RenderWindow1 = - this->GetActiveStdMultiWidget()->GetRenderWindow1(); - - if (m_SelectedNode->GetBoolProperty("PlanarFigureInitializedWindow", - PlanarFigureInitializedWindow, RenderWindow1->GetRenderer())) - { - selectedRenderWindow = RenderWindow1; - } - - QmitkRenderWindow* RenderWindow2 = - this->GetActiveStdMultiWidget()->GetRenderWindow2(); - - if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow2->GetRenderer())) - { - selectedRenderWindow = RenderWindow2; - } - - QmitkRenderWindow* RenderWindow3 = - this->GetActiveStdMultiWidget()->GetRenderWindow3(); - - if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow3->GetRenderer())) - { - selectedRenderWindow = RenderWindow3; - } - - QmitkRenderWindow* RenderWindow4 = - this->GetActiveStdMultiWidget()->GetRenderWindow4(); - - if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow4->GetRenderer())) - { - selectedRenderWindow = RenderWindow4; - } - - const mitk::PlaneGeometry* _PlaneGeometry = _PlanarFigure->GetPlaneGeometry(); - - mitk::VnlVector normal = _PlaneGeometry->GetNormalVnl(); - - mitk::Geometry2D::ConstPointer worldGeometry1 = - RenderWindow1->GetRenderer()->GetCurrentWorldGeometry2D(); - mitk::PlaneGeometry::ConstPointer _Plane1 = - dynamic_cast( worldGeometry1.GetPointer() ); - mitk::VnlVector normal1 = _Plane1->GetNormalVnl(); - - mitk::Geometry2D::ConstPointer worldGeometry2 = - RenderWindow2->GetRenderer()->GetCurrentWorldGeometry2D(); - mitk::PlaneGeometry::ConstPointer _Plane2 = - dynamic_cast( worldGeometry2.GetPointer() ); - mitk::VnlVector normal2 = _Plane2->GetNormalVnl(); - - mitk::Geometry2D::ConstPointer worldGeometry3 = - RenderWindow3->GetRenderer()->GetCurrentWorldGeometry2D(); - mitk::PlaneGeometry::ConstPointer _Plane3 = - dynamic_cast( worldGeometry3.GetPointer() ); - mitk::VnlVector normal3 = _Plane3->GetNormalVnl(); - - normal[0] = fabs(normal[0]); normal[1] = fabs(normal[1]); normal[2] = fabs(normal[2]); - normal1[0] = fabs(normal1[0]); normal1[1] = fabs(normal1[1]); normal1[2] = fabs(normal1[2]); - normal2[0] = fabs(normal2[0]); normal2[1] = fabs(normal2[1]); normal2[2] = fabs(normal2[2]); - normal3[0] = fabs(normal3[0]); normal3[1] = fabs(normal3[1]); normal3[2] = fabs(normal3[2]); - - double ang1 = angle(normal, normal1); - double ang2 = angle(normal, normal2); - double ang3 = angle(normal, normal3); - - if(ang1 < ang2 && ang1 < ang3) - { - selectedRenderWindow = RenderWindow1; - } - else - { - if(ang2 < ang3) + if (_PlanarFigure && _PlanarFigure->GetPlaneGeometry()) { - selectedRenderWindow = RenderWindow2; + + QmitkRenderWindow* selectedRenderWindow = 0; + bool PlanarFigureInitializedWindow = false; + + QmitkRenderWindow* RenderWindow1 = + this->GetActiveStdMultiWidget()->GetRenderWindow1(); + + if (m_SelectedNode->GetBoolProperty("PlanarFigureInitializedWindow", + PlanarFigureInitializedWindow, RenderWindow1->GetRenderer())) + { + selectedRenderWindow = RenderWindow1; + } + + QmitkRenderWindow* RenderWindow2 = + this->GetActiveStdMultiWidget()->GetRenderWindow2(); + + if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow2->GetRenderer())) + { + selectedRenderWindow = RenderWindow2; + } + + QmitkRenderWindow* RenderWindow3 = + this->GetActiveStdMultiWidget()->GetRenderWindow3(); + + if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow3->GetRenderer())) + { + selectedRenderWindow = RenderWindow3; + } + + QmitkRenderWindow* RenderWindow4 = + this->GetActiveStdMultiWidget()->GetRenderWindow4(); + + if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow4->GetRenderer())) + { + selectedRenderWindow = RenderWindow4; + } + + const mitk::PlaneGeometry* _PlaneGeometry = _PlanarFigure->GetPlaneGeometry(); + + mitk::VnlVector normal = _PlaneGeometry->GetNormalVnl(); + + mitk::Geometry2D::ConstPointer worldGeometry1 = + RenderWindow1->GetRenderer()->GetCurrentWorldGeometry2D(); + mitk::PlaneGeometry::ConstPointer _Plane1 = + dynamic_cast( worldGeometry1.GetPointer() ); + mitk::VnlVector normal1 = _Plane1->GetNormalVnl(); + + mitk::Geometry2D::ConstPointer worldGeometry2 = + RenderWindow2->GetRenderer()->GetCurrentWorldGeometry2D(); + mitk::PlaneGeometry::ConstPointer _Plane2 = + dynamic_cast( worldGeometry2.GetPointer() ); + mitk::VnlVector normal2 = _Plane2->GetNormalVnl(); + + mitk::Geometry2D::ConstPointer worldGeometry3 = + RenderWindow3->GetRenderer()->GetCurrentWorldGeometry2D(); + mitk::PlaneGeometry::ConstPointer _Plane3 = + dynamic_cast( worldGeometry3.GetPointer() ); + mitk::VnlVector normal3 = _Plane3->GetNormalVnl(); + + normal[0] = fabs(normal[0]); normal[1] = fabs(normal[1]); normal[2] = fabs(normal[2]); + normal1[0] = fabs(normal1[0]); normal1[1] = fabs(normal1[1]); normal1[2] = fabs(normal1[2]); + normal2[0] = fabs(normal2[0]); normal2[1] = fabs(normal2[1]); normal2[2] = fabs(normal2[2]); + normal3[0] = fabs(normal3[0]); normal3[1] = fabs(normal3[1]); normal3[2] = fabs(normal3[2]); + + double ang1 = angle(normal, normal1); + double ang2 = angle(normal, normal2); + double ang3 = angle(normal, normal3); + + if(ang1 < ang2 && ang1 < ang3) + { + selectedRenderWindow = RenderWindow1; + } + else + { + if(ang2 < ang3) + { + selectedRenderWindow = RenderWindow2; + } + else + { + selectedRenderWindow = RenderWindow3; + } + } + + // make node visible + if (selectedRenderWindow) + { + const mitk::Point3D& centerP = _PlaneGeometry->GetOrigin(); + selectedRenderWindow->GetSliceNavigationController()->ReorientSlices( + centerP, _PlaneGeometry->GetNormal()); + } } - else + + // set interactor for new node (if not already set) + mitk::PlanarFigureInteractor::Pointer figureInteractor + = dynamic_cast(m_SelectedNode->GetDataInteractor().GetPointer()); + + if(figureInteractor.IsNull()) { - selectedRenderWindow = RenderWindow3; + figureInteractor = mitk::PlanarFigureInteractor::New(); + us::Module* planarFigureModule = us::ModuleRegistry::GetModule( "MitkPlanarFigure" ); + figureInteractor->LoadStateMachine("PlanarFigureInteraction.xml", planarFigureModule ); + figureInteractor->SetEventConfig( "PlanarFigureConfig.xml", planarFigureModule ); + figureInteractor->SetDataNode( m_SelectedNode ); } - } - - // make node visible - if (selectedRenderWindow) - { - const mitk::Point3D& centerP = _PlaneGeometry->GetOrigin(); - selectedRenderWindow->GetSliceNavigationController()->ReorientSlices( - centerP, _PlaneGeometry->GetNormal()); - } - } - // set interactor for new node (if not already set) - mitk::PlanarFigureInteractor::Pointer figureInteractor - = dynamic_cast(m_SelectedNode->GetDataInteractor().GetPointer()); - - if(figureInteractor.IsNull()) - { - figureInteractor = mitk::PlanarFigureInteractor::New(); - us::Module* planarFigureModule = us::ModuleRegistry::GetModule( "MitkPlanarFigure" ); - figureInteractor->LoadStateMachine("PlanarFigureInteraction.xml", planarFigureModule ); - figureInteractor->SetEventConfig( "PlanarFigureConfig.xml", planarFigureModule ); - figureInteractor->SetDataNode( m_SelectedNode ); + m_SelectedNode->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true)); } - - m_SelectedNode->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true)); - } } void QmitkControlVisualizationPropertiesView::SetInteractor() { - typedef std::vector Container; - Container _NodeSet = this->GetDataManagerSelection(); - mitk::DataNode* node = 0; - mitk::FiberBundleX* bundle = 0; - mitk::FiberBundleInteractor::Pointer bundleInteractor = 0; - - // finally add all nodes to the model - for(Container::const_iterator it=_NodeSet.begin(); it!=_NodeSet.end() - ; it++) - { - node = const_cast(*it); - bundle = dynamic_cast(node->GetData()); - - if(bundle) + typedef std::vector Container; + Container _NodeSet = this->GetDataManagerSelection(); + mitk::DataNode* node = 0; + mitk::FiberBundleX* bundle = 0; + mitk::FiberBundleInteractor::Pointer bundleInteractor = 0; + + // finally add all nodes to the model + for(Container::const_iterator it=_NodeSet.begin(); it!=_NodeSet.end() + ; it++) { - bundleInteractor = dynamic_cast(node->GetInteractor()); - - if(bundleInteractor.IsNotNull()) - mitk::GlobalInteraction::GetInstance()->RemoveInteractor(bundleInteractor); - - if(!m_Controls->m_Crosshair->isChecked()) - { - m_Controls->m_Crosshair->setChecked(false); - this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::ArrowCursor); - m_CurrentPickingNode = 0; - } - else - { - m_Controls->m_Crosshair->setChecked(true); - bundleInteractor = mitk::FiberBundleInteractor::New("FiberBundleInteractor", node); - mitk::GlobalInteraction::GetInstance()->AddInteractor(bundleInteractor); - this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::CrossCursor); - m_CurrentPickingNode = node; - } + node = const_cast(*it); + bundle = dynamic_cast(node->GetData()); + if(bundle) + { + bundleInteractor = dynamic_cast(node->GetInteractor()); + + if(bundleInteractor.IsNotNull()) + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(bundleInteractor); + + if(!m_Controls->m_Crosshair->isChecked()) + { + m_Controls->m_Crosshair->setChecked(false); + this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::ArrowCursor); + m_CurrentPickingNode = 0; + } + else + { + m_Controls->m_Crosshair->setChecked(true); + bundleInteractor = mitk::FiberBundleInteractor::New("FiberBundleInteractor", node); + mitk::GlobalInteraction::GetInstance()->AddInteractor(bundleInteractor); + this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::CrossCursor); + m_CurrentPickingNode = node; + } + + } } - } } void QmitkControlVisualizationPropertiesView::PFWidth(int w) { - double width = w/10.0; - m_SelectedNode->SetProperty("planarfigure.line.width", mitk::FloatProperty::New(width) ); - m_SelectedNode->SetProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(width) ); - m_SelectedNode->SetProperty("planarfigure.outline.width", mitk::FloatProperty::New(width) ); - m_SelectedNode->SetProperty("planarfigure.helperline.width", mitk::FloatProperty::New(width) ); + double width = w/10.0; + m_SelectedNode->SetProperty("planarfigure.line.width", mitk::FloatProperty::New(width) ); + m_SelectedNode->SetProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(width) ); + m_SelectedNode->SetProperty("planarfigure.outline.width", mitk::FloatProperty::New(width) ); + m_SelectedNode->SetProperty("planarfigure.helperline.width", mitk::FloatProperty::New(width) ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - QString label = "Width %1"; - label = label.arg(width); - m_Controls->label_pfwidth->setText(label); + QString label = "Width %1"; + label = label.arg(width); + m_Controls->label_pfwidth->setText(label); } void QmitkControlVisualizationPropertiesView::PFColor() { - QColor color = QColorDialog::getColor(); - if (!color.isValid()) - return; - - m_Controls->m_PFColor->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color.red())); - styleSheet.append(","); - styleSheet.append(QString::number(color.green())); - styleSheet.append(","); - styleSheet.append(QString::number(color.blue())); - styleSheet.append(")"); - m_Controls->m_PFColor->setStyleSheet(styleSheet); - - m_SelectedNode->SetProperty( "planarfigure.default.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.markerline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.marker.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - - m_SelectedNode->SetProperty( "planarfigure.hover.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); - m_SelectedNode->SetProperty( "planarfigure.hover.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); - m_SelectedNode->SetProperty( "planarfigure.hover.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); - m_SelectedNode->SetProperty( "color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + QColor color = QColorDialog::getColor(); + if (!color.isValid()) + return; + + m_Controls->m_PFColor->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color.red())); + styleSheet.append(","); + styleSheet.append(QString::number(color.green())); + styleSheet.append(","); + styleSheet.append(QString::number(color.blue())); + styleSheet.append(")"); + m_Controls->m_PFColor->setStyleSheet(styleSheet); + + m_SelectedNode->SetProperty( "planarfigure.default.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.markerline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.marker.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + + m_SelectedNode->SetProperty( "planarfigure.hover.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); + m_SelectedNode->SetProperty( "planarfigure.hover.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); + m_SelectedNode->SetProperty( "planarfigure.hover.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); + m_SelectedNode->SetProperty( "color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkControlVisualizationPropertiesView::GenerateTdi() { - if(m_SelectedNode) - { - mitk::FiberBundleX* bundle = dynamic_cast(m_SelectedNode->GetData()); - if(!bundle) - return; - - typedef float OutPixType; - typedef itk::Image OutImageType; - - // run generator - itk::TractDensityImageFilter< OutImageType >::Pointer generator = itk::TractDensityImageFilter< OutImageType >::New(); - generator->SetFiberBundle(bundle); - generator->SetOutputAbsoluteValues(true); - generator->SetUpsamplingFactor(1); - generator->Update(); - - // get result - OutImageType::Pointer outImg = generator->GetOutput(); - - mitk::Image::Pointer img = mitk::Image::New(); - img->InitializeByItk(outImg.GetPointer()); - img->SetVolume(outImg->GetBufferPointer()); - - // to datastorage - mitk::DataNode::Pointer node = mitk::DataNode::New(); - node->SetData(img); - QString name(m_SelectedNode->GetName().c_str()); - name += "_TDI"; - node->SetName(name.toStdString()); - node->SetVisibility(true); - - GetDataStorage()->Add(node); - } + if(m_SelectedNode) + { + mitk::FiberBundleX* bundle = dynamic_cast(m_SelectedNode->GetData()); + if(!bundle) + return; + + typedef float OutPixType; + typedef itk::Image OutImageType; + + // run generator + itk::TractDensityImageFilter< OutImageType >::Pointer generator = itk::TractDensityImageFilter< OutImageType >::New(); + generator->SetFiberBundle(bundle); + generator->SetOutputAbsoluteValues(true); + generator->SetUpsamplingFactor(1); + generator->Update(); + + // get result + OutImageType::Pointer outImg = generator->GetOutput(); + + mitk::Image::Pointer img = mitk::Image::New(); + img->InitializeByItk(outImg.GetPointer()); + img->SetVolume(outImg->GetBufferPointer()); + + // to datastorage + mitk::DataNode::Pointer node = mitk::DataNode::New(); + node->SetData(img); + QString name(m_SelectedNode->GetName().c_str()); + name += "_TDI"; + node->SetName(name.toStdString()); + node->SetVisibility(true); + + GetDataStorage()->Add(node); + } } void QmitkControlVisualizationPropertiesView::LineWidthChanged() { - if(m_SelectedNode && dynamic_cast(m_SelectedNode->GetData())) - { - int newWidth = m_Controls->m_LineWidth->value(); - int currentWidth = 0; - m_SelectedNode->GetIntProperty("LineWidth", currentWidth); - if (currentWidth==newWidth) - return; - m_SelectedNode->SetIntProperty("LineWidth", newWidth); - dynamic_cast(m_SelectedNode->GetData())->RequestUpdate2D(); - dynamic_cast(m_SelectedNode->GetData())->RequestUpdate3D(); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if(m_SelectedNode && dynamic_cast(m_SelectedNode->GetData())) + { + int newWidth = m_Controls->m_LineWidth->value(); + int currentWidth = 0; + m_SelectedNode->GetIntProperty("LineWidth", currentWidth); + if (currentWidth==newWidth) + return; + m_SelectedNode->SetIntProperty("LineWidth", newWidth); + dynamic_cast(m_SelectedNode->GetData())->RequestUpdate2D(); + dynamic_cast(m_SelectedNode->GetData())->RequestUpdate3D(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::Welcome() { - berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( - GetSite()->GetWorkbenchWindow(), false); + berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( + GetSite()->GetWorkbenchWindow(), false); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h index 37198bfd6d..0a470ec63b 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h @@ -1,177 +1,180 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QMITKControlVisualizationPropertiesView_H_INCLUDED #define _QMITKControlVisualizationPropertiesView_H_INCLUDED #include #include #include "berryISelectionListener.h" #include "berryIStructuredSelection.h" #include "berryISizeProvider.h" #include "ui_QmitkControlVisualizationPropertiesViewControls.h" #include "mitkEnumerationProperty.h" /*! * \ingroup org_mitk_gui_qt_diffusionquantification_internal * * \brief QmitkControlVisualizationPropertiesView * * Document your class here. * * \sa QmitkFunctionality */ class QmitkControlVisualizationPropertiesView : public QmitkFunctionality//, public berry::ISizeProvider { friend struct CvpSelListener; // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT public: static const std::string VIEW_ID; QmitkControlVisualizationPropertiesView(); QmitkControlVisualizationPropertiesView(const QmitkControlVisualizationPropertiesView& other); virtual ~QmitkControlVisualizationPropertiesView(); virtual void CreateQtPartControl(QWidget *parent); /// \brief Creation of the connections of main and control widget virtual void CreateConnections(); /// \brief Called when the functionality is activated virtual void Activated(); virtual void Deactivated(); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); mitk::DataStorage::SetOfObjects::Pointer ActiveSet(std::string); void SetBoolProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,bool); void SetIntProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,int); void SetFloatProp(mitk::DataStorage::SetOfObjects::Pointer,std::string,float); void SetLevelWindowProp(mitk::DataStorage::SetOfObjects::Pointer,std::string,mitk::LevelWindow); void SetEnumProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,mitk::EnumerationProperty::Pointer); virtual int GetSizeFlags(bool width); virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredResult); protected slots: void DisplayIndexChanged(int); void TextIntON(); void Reinit(); void VisibleOdfsON(int view); void VisibleOdfsON_S(); void VisibleOdfsON_T(); void VisibleOdfsON_C(); void ShowMaxNumberChanged(); void NormalizationDropdownChanged(int); void ScalingFactorChanged(double); void AdditionalScaling(int); void IndexParam1Changed(double); void IndexParam2Changed(double); void OpacityChanged(double,double); void ScalingCheckbox(); void OnThickSlicesModeSelected( QAction* action ); void OnTSNumChanged(int num); void BundleRepresentationColor(); void BundleRepresentationResetColoring(); void PlanarFigureFocus(); void Fiber2DfadingEFX(); void FiberSlicingThickness2D(); void FiberSlicingUpdateLabel(int); void SetInteractor(); void PFWidth(int); void PFColor(); void LineWidthChanged(); void GenerateTdi(); void Welcome(); protected: virtual void NodeRemoved(const mitk::DataNode* node); /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( std::vector nodes ); virtual void NodeAdded(const mitk::DataNode *node); void SetFiberBundleCustomColor(const itk::EventObject& /*e*/); + void SetFiberBundleOpacity(const itk::EventObject& /*e*/); bool IsPlaneRotated(); void SliceRotation(const itk::EventObject&); Ui::QmitkControlVisualizationPropertiesViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; berry::ISelectionListener::Pointer m_SelListener; berry::IStructuredSelection::ConstPointer m_CurrentSelection; bool m_FoundSingleOdfImage; bool m_IsInitialized; mitk::DataNode::Pointer m_NodeUsedForOdfVisualization; QIcon* m_IconTexOFF; QIcon* m_IconTexON; QIcon* m_IconGlyOFF_T; QIcon* m_IconGlyON_T; QIcon* m_IconGlyOFF_C; QIcon* m_IconGlyON_C; QIcon* m_IconGlyOFF_S; QIcon* m_IconGlyON_S; bool m_TexIsOn; bool m_GlyIsOn_T; bool m_GlyIsOn_C; bool m_GlyIsOn_S; int currentThickSlicesMode; QLabel* m_TSLabel; QMenu* m_MyMenu; // for planarfigure and bundle handling: mitk::DataNode* m_SelectedNode; mitk::DataNode* m_CurrentPickingNode; unsigned long m_SlicesRotationObserverTag1; unsigned long m_SlicesRotationObserverTag2; unsigned long m_FiberBundleObserverTag; + unsigned long m_FiberBundleObserveOpacityTag; mitk::ColorProperty::Pointer m_Color; + mitk::FloatProperty::Pointer m_Opacity; }; #endif // _QMITKControlVisualizationPropertiesView_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp index 9c82ac9643..e116a924b7 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingView.cpp @@ -1,1489 +1,1487 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkFiberProcessingView.h" #include // Qt #include // MITK #include #include #include #include #include #include #include #include #include #include #include #include "usModuleRegistry.h" #include #include "mitkNodePredicateDataType.h" #include #include #include #include // ITK #include #include #include #include #include #include #include #define _USE_MATH_DEFINES #include const std::string QmitkFiberProcessingView::VIEW_ID = "org.mitk.views.fiberprocessing"; const std::string id_DataManager = "org.mitk.views.datamanager"; using namespace mitk; QmitkFiberProcessingView::QmitkFiberProcessingView() : QmitkFunctionality() , m_Controls( 0 ) , m_MultiWidget( NULL ) , m_CircleCounter(0) , m_PolygonCounter(0) , m_UpsamplingFactor(1) { } // Destructor QmitkFiberProcessingView::~QmitkFiberProcessingView() { } void QmitkFiberProcessingView::CreateQtPartControl( QWidget *parent ) { // build up qt view, unless already done if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkFiberProcessingViewControls; m_Controls->setupUi( parent ); connect( m_Controls->m_CircleButton, SIGNAL( clicked() ), this, SLOT( OnDrawCircle() ) ); connect( m_Controls->m_PolygonButton, SIGNAL( clicked() ), this, SLOT( OnDrawPolygon() ) ); connect(m_Controls->PFCompoANDButton, SIGNAL(clicked()), this, SLOT(GenerateAndComposite()) ); connect(m_Controls->PFCompoORButton, SIGNAL(clicked()), this, SLOT(GenerateOrComposite()) ); connect(m_Controls->PFCompoNOTButton, SIGNAL(clicked()), this, SLOT(GenerateNotComposite()) ); connect(m_Controls->m_GenerateRoiImage, SIGNAL(clicked()), this, SLOT(GenerateRoiImage()) ); connect(m_Controls->m_JoinBundles, SIGNAL(clicked()), this, SLOT(JoinBundles()) ); connect(m_Controls->m_SubstractBundles, SIGNAL(clicked()), this, SLOT(SubstractBundles()) ); connect(m_Controls->m_ExtractFibersButton, SIGNAL(clicked()), this, SLOT(Extract())); connect(m_Controls->m_RemoveButton, SIGNAL(clicked()), this, SLOT(Remove())); connect(m_Controls->m_ModifyButton, SIGNAL(clicked()), this, SLOT(Modify())); connect(m_Controls->m_ExtractionMethodBox, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateGui())); connect(m_Controls->m_RemovalMethodBox, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateGui())); connect(m_Controls->m_ModificationMethodBox, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateGui())); m_Controls->m_ColorMapBox->SetDataStorage(this->GetDataStorage()); mitk::TNodePredicateDataType::Pointer isMitkImage = mitk::TNodePredicateDataType::New(); mitk::NodePredicateDataType::Pointer isDwi = mitk::NodePredicateDataType::New("DiffusionImage"); mitk::NodePredicateDataType::Pointer isDti = mitk::NodePredicateDataType::New("TensorImage"); mitk::NodePredicateDataType::Pointer isQbi = mitk::NodePredicateDataType::New("QBallImage"); mitk::NodePredicateOr::Pointer isDiffusionImage = mitk::NodePredicateOr::New(isDwi, isDti); isDiffusionImage = mitk::NodePredicateOr::New(isDiffusionImage, isQbi); mitk::NodePredicateNot::Pointer noDiffusionImage = mitk::NodePredicateNot::New(isDiffusionImage); mitk::NodePredicateAnd::Pointer finalPredicate = mitk::NodePredicateAnd::New(isMitkImage, noDiffusionImage); m_Controls->m_ColorMapBox->SetPredicate(finalPredicate); } UpdateGui(); } void QmitkFiberProcessingView::Modify() { switch (m_Controls->m_ModificationMethodBox->currentIndex()) { case 0: { ResampleSelectedBundles(); break; } case 1: { CompressSelectedBundles(); break; } case 2: { DoImageColorCoding(); break; } case 3: { MirrorFibers(); break; } case 4: { WeightFibers(); break; } } } void QmitkFiberProcessingView::WeightFibers() { float weight = this->m_Controls->m_BundleWeightBox->value(); for (int i=0; i(m_SelectedFB.at(i)->GetData()); fib->SetFiberWeights(weight); } } void QmitkFiberProcessingView::Remove() { switch (m_Controls->m_RemovalMethodBox->currentIndex()) { case 0: { RemoveDir(); break; } case 1: { PruneBundle(); break; } case 2: { ApplyCurvatureThreshold(); break; } case 3: { RemoveWithMask(false); break; } case 4: { RemoveWithMask(true); break; } } } void QmitkFiberProcessingView::Extract() { switch (m_Controls->m_ExtractionMethodBox->currentIndex()) { case 0: { ExtractWithPlanarFigure(); break; } case 1: { switch (m_Controls->m_ExtractionBoxMask->currentIndex()) { { case 0: ExtractWithMask(true, false); break; } { case 1: ExtractWithMask(true, true); break; } { case 2: ExtractWithMask(false, false); break; } { case 3: ExtractWithMask(false, true); break; } } break; } } } void QmitkFiberProcessingView::PruneBundle() { int minLength = this->m_Controls->m_PruneFibersMinBox->value(); int maxLength = this->m_Controls->m_PruneFibersMaxBox->value(); for (int i=0; i(m_SelectedFB.at(i)->GetData()); if (!fib->RemoveShortFibers(minLength)) QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers."); else if (!fib->RemoveLongFibers(maxLength)) QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers."); } RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberProcessingView::ApplyCurvatureThreshold() { int angle = this->m_Controls->m_CurvSpinBox->value(); int dist = this->m_Controls->m_CurvDistanceSpinBox->value(); std::vector< DataNode::Pointer > nodes = m_SelectedFB; for (int i=0; i(nodes.at(i)->GetData()); itk::FiberCurvatureFilter::Pointer filter = itk::FiberCurvatureFilter::New(); filter->SetInputFiberBundle(fib); filter->SetAngularDeviation(angle); filter->SetDistance(dist); filter->SetRemoveFibers(m_Controls->m_RemoveCurvedFibersBox->isChecked()); filter->Update(); mitk::FiberBundleX::Pointer newFib = filter->GetOutputFiberBundle(); if (newFib->GetNumFibers()>0) { nodes.at(i)->SetVisibility(false); DataNode::Pointer newNode = DataNode::New(); newNode->SetData(newFib); newNode->SetName(nodes.at(i)->GetName()+"_Curvature"); GetDefaultDataStorage()->Add(newNode, nodes.at(i)); } else QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers."); // if (!fib->ApplyCurvatureThreshold(mm, this->m_Controls->m_RemoveCurvedFibersBox->isChecked())) // QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers."); } RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberProcessingView::RemoveDir() { for (unsigned int i=0; i(m_SelectedFB.at(i)->GetData()); vnl_vector_fixed dir; dir[0] = m_Controls->m_ExtractDirX->value(); dir[1] = m_Controls->m_ExtractDirY->value(); dir[2] = m_Controls->m_ExtractDirZ->value(); fib->RemoveDir(dir,cos((float)m_Controls->m_ExtractAngle->value()*M_PI/180)); } RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberProcessingView::RemoveWithMask(bool removeInside) { if (m_MaskImageNode.IsNull()) return; mitk::Image::Pointer mitkMask = dynamic_cast(m_MaskImageNode->GetData()); for (unsigned int i=0; i(m_SelectedFB.at(i)->GetData()); QString name(m_SelectedFB.at(i)->GetName().c_str()); itkUCharImageType::Pointer mask = itkUCharImageType::New(); mitk::CastToItkImage(mitkMask, mask); mitk::FiberBundleX::Pointer newFib = fib->RemoveFibersOutside(mask, removeInside); if (newFib->GetNumFibers()<=0) { QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers."); continue; } DataNode::Pointer newNode = DataNode::New(); newNode->SetData(newFib); if (removeInside) name += "_Inside"; else name += "_Outside"; newNode->SetName(name.toStdString()); GetDefaultDataStorage()->Add(newNode); m_SelectedFB.at(i)->SetVisibility(false); } } void QmitkFiberProcessingView::ExtractWithMask(bool onlyEnds, bool invert) { if (m_MaskImageNode.IsNull()) return; mitk::Image::Pointer mitkMask = dynamic_cast(m_MaskImageNode->GetData()); for (unsigned int i=0; i(m_SelectedFB.at(i)->GetData()); QString name(m_SelectedFB.at(i)->GetName().c_str()); itkUCharImageType::Pointer mask = itkUCharImageType::New(); mitk::CastToItkImage(mitkMask, mask); mitk::FiberBundleX::Pointer newFib = fib->ExtractFiberSubset(mask, onlyEnds, invert); if (newFib->GetNumFibers()<=0) { QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers."); continue; } DataNode::Pointer newNode = DataNode::New(); newNode->SetData(newFib); if (invert) { name += "_not"; if (onlyEnds) name += "-ending-in-mask"; else name += "-passing-mask"; } else { if (onlyEnds) name += "_ending-in-mask"; else name += "_passing-mask"; } newNode->SetName(name.toStdString()); GetDefaultDataStorage()->Add(newNode); m_SelectedFB.at(i)->SetVisibility(false); } } void QmitkFiberProcessingView::GenerateRoiImage() { if (m_SelectedPF.empty()) return; mitk::BaseGeometry::Pointer geometry; if (!m_SelectedFB.empty()) { mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedFB.front()->GetData()); geometry = fib->GetGeometry(); } else if (m_SelectedImage) geometry = m_SelectedImage->GetGeometry(); else return; itk::Vector spacing = geometry->GetSpacing(); spacing /= m_UpsamplingFactor; mitk::Point3D newOrigin = geometry->GetOrigin(); mitk::Geometry3D::BoundsArrayType bounds = geometry->GetBounds(); newOrigin[0] += bounds.GetElement(0); newOrigin[1] += bounds.GetElement(2); newOrigin[2] += bounds.GetElement(4); itk::Matrix direction; itk::ImageRegion<3> imageRegion; for (int i=0; i<3; i++) for (int j=0; j<3; j++) direction[j][i] = geometry->GetMatrixColumn(i)[j]/spacing[j]; imageRegion.SetSize(0, geometry->GetExtent(0)*m_UpsamplingFactor); imageRegion.SetSize(1, geometry->GetExtent(1)*m_UpsamplingFactor); imageRegion.SetSize(2, geometry->GetExtent(2)*m_UpsamplingFactor); m_PlanarFigureImage = itkUCharImageType::New(); m_PlanarFigureImage->SetSpacing( spacing ); // Set the image spacing m_PlanarFigureImage->SetOrigin( newOrigin ); // Set the image origin m_PlanarFigureImage->SetDirection( direction ); // Set the image direction m_PlanarFigureImage->SetRegions( imageRegion ); m_PlanarFigureImage->Allocate(); m_PlanarFigureImage->FillBuffer( 0 ); Image::Pointer tmpImage = Image::New(); tmpImage->InitializeByItk(m_PlanarFigureImage.GetPointer()); tmpImage->SetVolume(m_PlanarFigureImage->GetBufferPointer()); std::string name = m_SelectedPF.at(0)->GetName(); WritePfToImage(m_SelectedPF.at(0), tmpImage); for (unsigned int i=1; iGetName(); WritePfToImage(m_SelectedPF.at(i), tmpImage); } DataNode::Pointer node = DataNode::New(); tmpImage = Image::New(); tmpImage->InitializeByItk(m_PlanarFigureImage.GetPointer()); tmpImage->SetVolume(m_PlanarFigureImage->GetBufferPointer()); node->SetData(tmpImage); node->SetName(name); this->GetDefaultDataStorage()->Add(node); } void QmitkFiberProcessingView::WritePfToImage(mitk::DataNode::Pointer node, mitk::Image* image) { if (dynamic_cast(node->GetData())) { m_PlanarFigure = dynamic_cast(node->GetData()); AccessFixedDimensionByItk_2( image, InternalReorientImagePlane, 3, m_PlanarFigure->GetGeometry(), -1); AccessFixedDimensionByItk_2( m_InternalImage, InternalCalculateMaskFromPlanarFigure, 3, 2, node->GetName() ); } else if (dynamic_cast(node->GetData())) { mitk::PlanarFigureComposite* pfc = dynamic_cast(node->GetData()); for (int j=0; jgetNumberOfChildren(); j++) { WritePfToImage(pfc->getDataNodeAt(j), image); } } } template < typename TPixel, unsigned int VImageDimension > void QmitkFiberProcessingView::InternalReorientImagePlane( const itk::Image< TPixel, VImageDimension > *image, mitk::BaseGeometry* planegeo3D, int additionalIndex ) { typedef itk::Image< TPixel, VImageDimension > ImageType; typedef itk::Image< float, VImageDimension > FloatImageType; typedef itk::ResampleImageFilter ResamplerType; typename ResamplerType::Pointer resampler = ResamplerType::New(); mitk::PlaneGeometry* planegeo = dynamic_cast(planegeo3D); float upsamp = m_UpsamplingFactor; float gausssigma = 0.5; // Spacing typename ResamplerType::SpacingType spacing = planegeo->GetSpacing(); spacing[0] = image->GetSpacing()[0] / upsamp; spacing[1] = image->GetSpacing()[1] / upsamp; spacing[2] = image->GetSpacing()[2]; resampler->SetOutputSpacing( spacing ); // Size typename ResamplerType::SizeType size; size[0] = planegeo->GetExtentInMM(0) / spacing[0]; size[1] = planegeo->GetExtentInMM(1) / spacing[1]; size[2] = 1; resampler->SetSize( size ); // Origin typename mitk::Point3D orig = planegeo->GetOrigin(); typename mitk::Point3D corrorig; planegeo3D->WorldToIndex(orig,corrorig); corrorig[0] += 0.5/upsamp; corrorig[1] += 0.5/upsamp; corrorig[2] += 0; planegeo3D->IndexToWorld(corrorig,corrorig); resampler->SetOutputOrigin(corrorig ); // Direction typename ResamplerType::DirectionType direction; typename mitk::AffineTransform3D::MatrixType matrix = planegeo->GetIndexToWorldTransform()->GetMatrix(); for(int c=0; cSetOutputDirection( direction ); // Gaussian interpolation if(gausssigma != 0) { double sigma[3]; for( unsigned int d = 0; d < 3; d++ ) sigma[d] = gausssigma * image->GetSpacing()[d]; double alpha = 2.0; typedef itk::GaussianInterpolateImageFunction GaussianInterpolatorType; typename GaussianInterpolatorType::Pointer interpolator = GaussianInterpolatorType::New(); interpolator->SetInputImage( image ); interpolator->SetParameters( sigma, alpha ); resampler->SetInterpolator( interpolator ); } else { typedef typename itk::LinearInterpolateImageFunction InterpolatorType; typename InterpolatorType::Pointer interpolator = InterpolatorType::New(); interpolator->SetInputImage( image ); resampler->SetInterpolator( interpolator ); } resampler->SetInput( image ); resampler->SetDefaultPixelValue(0); resampler->Update(); if(additionalIndex < 0) { this->m_InternalImage = mitk::Image::New(); this->m_InternalImage->InitializeByItk( resampler->GetOutput() ); this->m_InternalImage->SetVolume( resampler->GetOutput()->GetBufferPointer() ); } } template < typename TPixel, unsigned int VImageDimension > void QmitkFiberProcessingView::InternalCalculateMaskFromPlanarFigure( itk::Image< TPixel, VImageDimension > *image, unsigned int axis, std::string ) { typedef itk::Image< TPixel, VImageDimension > ImageType; typedef itk::CastImageFilter< ImageType, itkUCharImageType > CastFilterType; // Generate mask image as new image with same header as input image and // initialize with "1". itkUCharImageType::Pointer newMaskImage = itkUCharImageType::New(); newMaskImage->SetSpacing( image->GetSpacing() ); // Set the image spacing newMaskImage->SetOrigin( image->GetOrigin() ); // Set the image origin newMaskImage->SetDirection( image->GetDirection() ); // Set the image direction newMaskImage->SetRegions( image->GetLargestPossibleRegion() ); newMaskImage->Allocate(); newMaskImage->FillBuffer( 1 ); // Generate VTK polygon from (closed) PlanarFigure polyline // (The polyline points are shifted by -0.5 in z-direction to make sure // that the extrusion filter, which afterwards elevates all points by +0.5 // in z-direction, creates a 3D object which is cut by the the plane z=0) const PlaneGeometry *planarFigurePlaneGeometry = m_PlanarFigure->GetPlaneGeometry(); const PlanarFigure::PolyLineType planarFigurePolyline = m_PlanarFigure->GetPolyLine( 0 ); const BaseGeometry *imageGeometry3D = m_InternalImage->GetGeometry( 0 ); vtkPolyData *polyline = vtkPolyData::New(); polyline->Allocate( 1, 1 ); // Determine x- and y-dimensions depending on principal axis int i0, i1; switch ( axis ) { case 0: i0 = 1; i1 = 2; break; case 1: i0 = 0; i1 = 2; break; case 2: default: i0 = 0; i1 = 1; break; } // Create VTK polydata object of polyline contour vtkPoints *points = vtkPoints::New(); PlanarFigure::PolyLineType::const_iterator it; unsigned int numberOfPoints = 0; for ( it = planarFigurePolyline.begin(); it != planarFigurePolyline.end(); ++it ) { Point3D point3D; // Convert 2D point back to the local index coordinates of the selected image Point2D point2D = *it; planarFigurePlaneGeometry->WorldToIndex(point2D, point2D); point2D[0] -= 0.5/m_UpsamplingFactor; point2D[1] -= 0.5/m_UpsamplingFactor; planarFigurePlaneGeometry->IndexToWorld(point2D, point2D); planarFigurePlaneGeometry->Map( point2D, point3D ); // Polygons (partially) outside of the image bounds can not be processed further due to a bug in vtkPolyDataToImageStencil if ( !imageGeometry3D->IsInside( point3D ) ) { float bounds[2] = {0,0}; bounds[0] = this->m_InternalImage->GetLargestPossibleRegion().GetSize().GetElement(i0); bounds[1] = this->m_InternalImage->GetLargestPossibleRegion().GetSize().GetElement(i1); imageGeometry3D->WorldToIndex( point3D, point3D ); if (point3D[i0]<0) point3D[i0] = 0.0; else if (point3D[i0]>bounds[0]) point3D[i0] = bounds[0]-0.001; if (point3D[i1]<0) point3D[i1] = 0.0; else if (point3D[i1]>bounds[1]) point3D[i1] = bounds[1]-0.001; points->InsertNextPoint( point3D[i0], point3D[i1], -0.5 ); numberOfPoints++; } else { imageGeometry3D->WorldToIndex( point3D, point3D ); // Add point to polyline array points->InsertNextPoint( point3D[i0], point3D[i1], -0.5 ); numberOfPoints++; } } polyline->SetPoints( points ); points->Delete(); vtkIdType *ptIds = new vtkIdType[numberOfPoints]; for ( vtkIdType i = 0; i < numberOfPoints; ++i ) ptIds[i] = i; polyline->InsertNextCell( VTK_POLY_LINE, numberOfPoints, ptIds ); // Extrude the generated contour polygon vtkLinearExtrusionFilter *extrudeFilter = vtkLinearExtrusionFilter::New(); extrudeFilter->SetInputData( polyline ); extrudeFilter->SetScaleFactor( 1 ); extrudeFilter->SetExtrusionTypeToNormalExtrusion(); extrudeFilter->SetVector( 0.0, 0.0, 1.0 ); // Make a stencil from the extruded polygon vtkPolyDataToImageStencil *polyDataToImageStencil = vtkPolyDataToImageStencil::New(); polyDataToImageStencil->SetInputConnection( extrudeFilter->GetOutputPort() ); // Export from ITK to VTK (to use a VTK filter) typedef itk::VTKImageImport< itkUCharImageType > ImageImportType; typedef itk::VTKImageExport< itkUCharImageType > ImageExportType; typename ImageExportType::Pointer itkExporter = ImageExportType::New(); itkExporter->SetInput( newMaskImage ); vtkImageImport *vtkImporter = vtkImageImport::New(); this->ConnectPipelines( itkExporter, vtkImporter ); vtkImporter->Update(); // Apply the generated image stencil to the input image vtkImageStencil *imageStencilFilter = vtkImageStencil::New(); imageStencilFilter->SetInputConnection( vtkImporter->GetOutputPort() ); imageStencilFilter->SetStencilConnection(polyDataToImageStencil->GetOutputPort() ); imageStencilFilter->ReverseStencilOff(); imageStencilFilter->SetBackgroundValue( 0 ); imageStencilFilter->Update(); // Export from VTK back to ITK vtkImageExport *vtkExporter = vtkImageExport::New(); vtkExporter->SetInputConnection( imageStencilFilter->GetOutputPort() ); vtkExporter->Update(); typename ImageImportType::Pointer itkImporter = ImageImportType::New(); this->ConnectPipelines( vtkExporter, itkImporter ); itkImporter->Update(); // calculate cropping bounding box m_InternalImageMask3D = itkImporter->GetOutput(); m_InternalImageMask3D->SetDirection(image->GetDirection()); itk::ImageRegionConstIterator itmask(m_InternalImageMask3D, m_InternalImageMask3D->GetLargestPossibleRegion()); itk::ImageRegionIterator itimage(image, image->GetLargestPossibleRegion()); itmask.GoToBegin(); itimage.GoToBegin(); typename ImageType::SizeType lowersize = {{9999999999,9999999999,9999999999}}; typename ImageType::SizeType uppersize = {{0,0,0}}; while( !itmask.IsAtEnd() ) { if(itmask.Get() == 0) itimage.Set(0); else { typename ImageType::IndexType index = itimage.GetIndex(); typename ImageType::SizeType signedindex; signedindex[0] = index[0]; signedindex[1] = index[1]; signedindex[2] = index[2]; lowersize[0] = signedindex[0] < lowersize[0] ? signedindex[0] : lowersize[0]; lowersize[1] = signedindex[1] < lowersize[1] ? signedindex[1] : lowersize[1]; lowersize[2] = signedindex[2] < lowersize[2] ? signedindex[2] : lowersize[2]; uppersize[0] = signedindex[0] > uppersize[0] ? signedindex[0] : uppersize[0]; uppersize[1] = signedindex[1] > uppersize[1] ? signedindex[1] : uppersize[1]; uppersize[2] = signedindex[2] > uppersize[2] ? signedindex[2] : uppersize[2]; } ++itmask; ++itimage; } typename ImageType::IndexType index; index[0] = lowersize[0]; index[1] = lowersize[1]; index[2] = lowersize[2]; typename ImageType::SizeType size; size[0] = uppersize[0] - lowersize[0] + 1; size[1] = uppersize[1] - lowersize[1] + 1; size[2] = uppersize[2] - lowersize[2] + 1; itk::ImageRegion<3> cropRegion = itk::ImageRegion<3>(index, size); // crop internal mask typedef itk::RegionOfInterestImageFilter< itkUCharImageType, itkUCharImageType > ROIMaskFilterType; typename ROIMaskFilterType::Pointer roi2 = ROIMaskFilterType::New(); roi2->SetRegionOfInterest(cropRegion); roi2->SetInput(m_InternalImageMask3D); roi2->Update(); m_InternalImageMask3D = roi2->GetOutput(); Image::Pointer tmpImage = Image::New(); tmpImage->InitializeByItk(m_InternalImageMask3D.GetPointer()); tmpImage->SetVolume(m_InternalImageMask3D->GetBufferPointer()); Image::Pointer tmpImage2 = Image::New(); tmpImage2->InitializeByItk(m_PlanarFigureImage.GetPointer()); const BaseGeometry *pfImageGeometry3D = tmpImage2->GetGeometry( 0 ); const BaseGeometry *intImageGeometry3D = tmpImage->GetGeometry( 0 ); typedef itk::ImageRegionIteratorWithIndex IteratorType; IteratorType imageIterator (m_InternalImageMask3D, m_InternalImageMask3D->GetRequestedRegion()); imageIterator.GoToBegin(); while ( !imageIterator.IsAtEnd() ) { unsigned char val = imageIterator.Value(); if (val>0) { itk::Index<3> index = imageIterator.GetIndex(); Point3D point; point[0] = index[0]; point[1] = index[1]; point[2] = index[2]; intImageGeometry3D->IndexToWorld(point, point); pfImageGeometry3D->WorldToIndex(point, point); point[i0] += 0.5; point[i1] += 0.5; index[0] = point[0]; index[1] = point[1]; index[2] = point[2]; if (pfImageGeometry3D->IsIndexInside(index)) m_PlanarFigureImage->SetPixel(index, 1); } ++imageIterator; } // Clean up VTK objects polyline->Delete(); extrudeFilter->Delete(); polyDataToImageStencil->Delete(); vtkImporter->Delete(); imageStencilFilter->Delete(); //vtkExporter->Delete(); // TODO: crashes when outcommented; memory leak?? delete[] ptIds; } void QmitkFiberProcessingView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkFiberProcessingView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } void QmitkFiberProcessingView::UpdateGui() { m_Controls->m_FibLabel->setText("mandatory"); m_Controls->m_PfLabel->setText("needed for extraction"); m_Controls->m_InputData->setTitle("Please Select Input Data"); m_Controls->m_RemoveButton->setEnabled(false); m_Controls->m_PlanarFigureButtonsFrame->setEnabled(false); m_Controls->PFCompoANDButton->setEnabled(false); m_Controls->PFCompoORButton->setEnabled(false); m_Controls->PFCompoNOTButton->setEnabled(false); m_Controls->m_GenerateRoiImage->setEnabled(false); m_Controls->m_ExtractFibersButton->setEnabled(false); m_Controls->m_ModifyButton->setEnabled(false); m_Controls->m_JoinBundles->setEnabled(false); m_Controls->m_SubstractBundles->setEnabled(false); // disable alle frames m_Controls->m_BundleWeightFrame->setVisible(false); m_Controls->m_ExtractionBoxMask->setVisible(false); m_Controls->m_ExtactionFramePF->setVisible(false); m_Controls->m_RemoveDirectionFrame->setVisible(false); m_Controls->m_RemoveLengthFrame->setVisible(false); m_Controls->m_RemoveCurvatureFrame->setVisible(false); m_Controls->m_SmoothFibersFrame->setVisible(false); m_Controls->m_CompressFibersFrame->setVisible(false); m_Controls->m_ColorFibersFrame->setVisible(false); m_Controls->m_MirrorFibersFrame->setVisible(false); bool pfSelected = !m_SelectedPF.empty(); bool fibSelected = !m_SelectedFB.empty(); bool multipleFibsSelected = (m_SelectedFB.size()>1); bool maskSelected = m_MaskImageNode.IsNotNull(); bool imageSelected = m_SelectedImage.IsNotNull(); // toggle visibility of elements according to selected method switch ( m_Controls->m_ExtractionMethodBox->currentIndex() ) { case 0: m_Controls->m_ExtactionFramePF->setVisible(true); break; case 1: m_Controls->m_ExtractionBoxMask->setVisible(true); break; } switch ( m_Controls->m_RemovalMethodBox->currentIndex() ) { case 0: m_Controls->m_RemoveDirectionFrame->setVisible(true); if ( fibSelected ) m_Controls->m_RemoveButton->setEnabled(true); break; case 1: m_Controls->m_RemoveLengthFrame->setVisible(true); if ( fibSelected ) m_Controls->m_RemoveButton->setEnabled(true); break; case 2: m_Controls->m_RemoveCurvatureFrame->setVisible(true); if ( fibSelected ) m_Controls->m_RemoveButton->setEnabled(true); break; case 3: break; case 4: break; } switch ( m_Controls->m_ModificationMethodBox->currentIndex() ) { case 0: m_Controls->m_SmoothFibersFrame->setVisible(true); break; case 1: m_Controls->m_CompressFibersFrame->setVisible(true); break; case 2: m_Controls->m_ColorFibersFrame->setVisible(true); break; case 3: m_Controls->m_MirrorFibersFrame->setVisible(true); break; case 4: m_Controls->m_BundleWeightFrame->setVisible(true); } // are fiber bundles selected? if ( fibSelected ) { m_Controls->m_ModifyButton->setEnabled(true); m_Controls->m_PlanarFigureButtonsFrame->setEnabled(true); m_Controls->m_FibLabel->setText(QString(m_SelectedFB.at(0)->GetName().c_str())); // one bundle and one planar figure needed to extract fibers if (pfSelected) { m_Controls->m_InputData->setTitle("Input Data"); m_Controls->m_PfLabel->setText(QString(m_SelectedPF.at(0)->GetName().c_str())); m_Controls->m_ExtractFibersButton->setEnabled(true); } // more than two bundles needed to join/subtract if (multipleFibsSelected) { m_Controls->m_FibLabel->setText("multiple bundles selected"); m_Controls->m_JoinBundles->setEnabled(true); m_Controls->m_SubstractBundles->setEnabled(true); } if (maskSelected) { m_Controls->m_RemoveButton->setEnabled(true); m_Controls->m_ExtractFibersButton->setEnabled(true); } } // are planar figures selected? if (pfSelected) { if ( fibSelected || m_SelectedImage.IsNotNull()) m_Controls->m_GenerateRoiImage->setEnabled(true); if (m_SelectedPF.size() > 1) { m_Controls->PFCompoANDButton->setEnabled(true); m_Controls->PFCompoORButton->setEnabled(true); } else m_Controls->PFCompoNOTButton->setEnabled(true); } // is image selected if (imageSelected || maskSelected) { m_Controls->m_PlanarFigureButtonsFrame->setEnabled(true); } } void QmitkFiberProcessingView::NodeRemoved(const mitk::DataNode* node) { std::vector nodes; OnSelectionChanged(nodes); } void QmitkFiberProcessingView::NodeAdded(const mitk::DataNode* node) { std::vector nodes; OnSelectionChanged(nodes); } void QmitkFiberProcessingView::OnSelectionChanged( std::vector nodes ) { //reset existing Vectors containing FiberBundles and PlanarFigures from a previous selection m_SelectedFB.clear(); m_SelectedPF.clear(); m_SelectedSurfaces.clear(); m_SelectedImage = NULL; m_MaskImageNode = NULL; for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) { mitk::DataNode::Pointer node = *it; if ( dynamic_cast(node->GetData()) ) m_SelectedFB.push_back(node); else if (dynamic_cast(node->GetData()) || dynamic_cast(node->GetData()) || dynamic_cast(node->GetData())) m_SelectedPF.push_back(node); else if (dynamic_cast(node->GetData())) { m_SelectedImage = dynamic_cast(node->GetData()); bool isBinary = false; node->GetPropertyValue("binary", isBinary); if (isBinary) m_MaskImageNode = node; } else if (dynamic_cast(node->GetData())) m_SelectedSurfaces.push_back(dynamic_cast(node->GetData())); } if (m_SelectedFB.empty()) { int maxLayer = 0; itk::VectorContainer::ConstPointer nodes = this->GetDefaultDataStorage()->GetAll(); for (unsigned int i=0; iSize(); i++) if (dynamic_cast(nodes->at(i)->GetData())) { mitk::DataStorage::SetOfObjects::ConstPointer sources = GetDataStorage()->GetSources(nodes->at(i)); if (sources->Size()>0) continue; int layer = 0; nodes->at(i)->GetPropertyValue("layer", layer); if (layer>=maxLayer) { maxLayer = layer; m_SelectedFB.clear(); m_SelectedFB.push_back(nodes->at(i)); } } } if (m_SelectedPF.empty()) { int maxLayer = 0; itk::VectorContainer::ConstPointer nodes = this->GetDefaultDataStorage()->GetAll(); for (unsigned int i=0; iSize(); i++) if (dynamic_cast(nodes->at(i)->GetData()) || dynamic_cast(nodes->at(i)->GetData()) || dynamic_cast(nodes->at(i)->GetData())) { mitk::DataStorage::SetOfObjects::ConstPointer sources = GetDataStorage()->GetSources(nodes->at(i)); if (sources->Size()>0) continue; int layer = 0; nodes->at(i)->GetPropertyValue("layer", layer); if (layer>=maxLayer) { maxLayer = layer; m_SelectedPF.clear(); m_SelectedPF.push_back(nodes->at(i)); } } } UpdateGui(); } void QmitkFiberProcessingView::OnDrawPolygon() { mitk::PlanarPolygon::Pointer figure = mitk::PlanarPolygon::New(); figure->ClosedOn(); this->AddFigureToDataStorage(figure, QString("Polygon%1").arg(++m_PolygonCounter)); } void QmitkFiberProcessingView::OnDrawCircle() { mitk::PlanarCircle::Pointer figure = mitk::PlanarCircle::New(); this->AddFigureToDataStorage(figure, QString("Circle%1").arg(++m_CircleCounter)); } void QmitkFiberProcessingView::Activated() { } void QmitkFiberProcessingView::AddFigureToDataStorage(mitk::PlanarFigure* figure, const QString& name, const char *, mitk::BaseProperty* ) { // initialize figure's geometry with empty geometry mitk::PlaneGeometry::Pointer emptygeometry = mitk::PlaneGeometry::New(); figure->SetPlaneGeometry( emptygeometry ); //set desired data to DataNode where Planarfigure is stored mitk::DataNode::Pointer newNode = mitk::DataNode::New(); newNode->SetName(name.toStdString()); newNode->SetData(figure); newNode->SetBoolProperty("planarfigure.3drendering", true); mitk::PlanarFigureInteractor::Pointer figureInteractor = dynamic_cast(newNode->GetDataInteractor().GetPointer()); if(figureInteractor.IsNull()) { figureInteractor = mitk::PlanarFigureInteractor::New(); us::Module* planarFigureModule = us::ModuleRegistry::GetModule( "MitkPlanarFigure" ); figureInteractor->LoadStateMachine("PlanarFigureInteraction.xml", planarFigureModule ); figureInteractor->SetEventConfig( "PlanarFigureConfig.xml", planarFigureModule ); figureInteractor->SetDataNode(newNode); } // figure drawn on the topmost layer / image GetDataStorage()->Add(newNode ); for(unsigned int i = 0; i < m_SelectedPF.size(); i++) m_SelectedPF[i]->SetSelected(false); newNode->SetSelected(true); m_SelectedPF.clear(); m_SelectedPF.push_back(newNode); UpdateGui(); } void QmitkFiberProcessingView::ExtractWithPlanarFigure() { if ( m_SelectedFB.empty() || m_SelectedPF.empty() ){ QMessageBox::information( NULL, "Warning", "No fibe bundle selected!"); return; } std::vector fiberBundles = m_SelectedFB; mitk::DataNode::Pointer planarFigure = m_SelectedPF.at(0); for (unsigned int i=0; i(fiberBundles.at(i)->GetData()); mitk::BaseData::Pointer roi = planarFigure->GetData(); mitk::FiberBundleX::Pointer extFB = fib->ExtractFiberSubset(roi); if (extFB->GetNumFibers()<=0) { QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers."); continue; } mitk::DataNode::Pointer node; node = mitk::DataNode::New(); node->SetData(extFB); QString name(fiberBundles.at(i)->GetName().c_str()); name += "_"; name += planarFigure->GetName().c_str(); node->SetName(name.toStdString()); fiberBundles.at(i)->SetVisibility(false); GetDataStorage()->Add(node); } } void QmitkFiberProcessingView::GenerateAndComposite() { mitk::PlanarFigureComposite::Pointer PFCAnd = mitk::PlanarFigureComposite::New(); PFCAnd->setOperationType(mitk::PFCOMPOSITION_AND_OPERATION); for( std::vector::iterator it = m_SelectedPF.begin(); it != m_SelectedPF.end(); ++it ) { mitk::DataNode::Pointer nodePF = *it; PFCAnd->addPlanarFigure( nodePF->GetData() ); PFCAnd->addDataNode( nodePF ); PFCAnd->setDisplayName("AND"); } AddCompositeToDatastorage(PFCAnd); } void QmitkFiberProcessingView::GenerateOrComposite() { mitk::PlanarFigureComposite::Pointer PFCOr = mitk::PlanarFigureComposite::New(); PFCOr->setOperationType(mitk::PFCOMPOSITION_OR_OPERATION); for( std::vector::iterator it = m_SelectedPF.begin(); it != m_SelectedPF.end(); ++it ) { mitk::DataNode::Pointer nodePF = *it; PFCOr->addPlanarFigure( nodePF->GetData() ); PFCOr->addDataNode( nodePF ); PFCOr->setDisplayName("OR"); } AddCompositeToDatastorage(PFCOr); } void QmitkFiberProcessingView::GenerateNotComposite() { mitk::PlanarFigureComposite::Pointer PFCNot = mitk::PlanarFigureComposite::New(); PFCNot->setOperationType(mitk::PFCOMPOSITION_NOT_OPERATION); for( std::vector::iterator it = m_SelectedPF.begin(); it != m_SelectedPF.end(); ++it ) { mitk::DataNode::Pointer nodePF = *it; PFCNot->addPlanarFigure( nodePF->GetData() ); PFCNot->addDataNode( nodePF ); PFCNot->setDisplayName("NOT"); } AddCompositeToDatastorage(PFCNot); } /* CLEANUP NEEDED */ void QmitkFiberProcessingView::AddCompositeToDatastorage(mitk::PlanarFigureComposite::Pointer pfc, mitk::DataNode::Pointer parentNode ) { mitk::DataNode::Pointer newPFCNode; newPFCNode = mitk::DataNode::New(); newPFCNode->SetName( pfc->getDisplayName() ); newPFCNode->SetData(pfc); switch (pfc->getOperationType()) { case 0: { if (parentNode.IsNotNull()) GetDataStorage()->Add(newPFCNode, parentNode); else GetDataStorage()->Add(newPFCNode); //iterate through its childs for(int i=0; igetNumberOfChildren(); ++i) { mitk::BaseData::Pointer tmpPFchild = pfc->getChildAt(i); mitk::DataNode::Pointer savedPFchildNode = pfc->getDataNodeAt(i); mitk::PlanarFigureComposite::Pointer pfcompcast= dynamic_cast(tmpPFchild.GetPointer()); if ( pfcompcast.IsNotNull() ) { // child is of type planar Figure composite // make new node of the child, cuz later the child has to be removed of its old position in datamanager // feed new dataNode with information of the savedDataNode, which is gonna be removed soon mitk::DataNode::Pointer newChildPFCNode; newChildPFCNode = mitk::DataNode::New(); newChildPFCNode->SetData(tmpPFchild); newChildPFCNode->SetName( savedPFchildNode->GetName() ); pfcompcast->setDisplayName( savedPFchildNode->GetName() ); //name might be changed in DataManager by user //update inside vector the dataNodePointer pfc->replaceDataNodeAt(i, newChildPFCNode); AddCompositeToDatastorage(pfcompcast, newPFCNode); //the current PFCNode becomes the childs parent // remove savedNode here, cuz otherwise its children will change their position in the dataNodeManager // without having its parent anymore GetDataStorage()->Remove(savedPFchildNode); } else { // child is not of type PlanarFigureComposite, so its one of the planarFigures // create new dataNode containing the data of the old dataNode, but position in dataManager will be // modified cuz we re setting a (new) parent. mitk::DataNode::Pointer newPFchildNode = mitk::DataNode::New(); newPFchildNode->SetName(savedPFchildNode->GetName() ); newPFchildNode->SetData(tmpPFchild); newPFchildNode->SetVisibility(true); newPFchildNode->SetBoolProperty("planarfigure.3drendering", true); // replace the dataNode in PFComp DataNodeVector pfc->replaceDataNodeAt(i, newPFchildNode); // remove old child position in dataStorage GetDataStorage()->Remove(savedPFchildNode); //add new child to datamanager with its new position as child of newPFCNode parent GetDataStorage()->Add(newPFchildNode, newPFCNode); } } break; } case 1: { if (!parentNode.IsNull()) GetDataStorage()->Add(newPFCNode, parentNode); else GetDataStorage()->Add(newPFCNode); for(int i=0; igetNumberOfChildren(); ++i) { mitk::BaseData::Pointer tmpPFchild = pfc->getChildAt(i); mitk::DataNode::Pointer savedPFchildNode = pfc->getDataNodeAt(i); mitk::PlanarFigureComposite::Pointer pfcompcast= dynamic_cast(tmpPFchild.GetPointer()); if ( !pfcompcast.IsNull() ) { // child is of type planar Figure composite // make new node of the child, cuz later the child has to be removed of its old position in datamanager // feed new dataNode with information of the savedDataNode, which is gonna be removed soon mitk::DataNode::Pointer newChildPFCNode; newChildPFCNode = mitk::DataNode::New(); newChildPFCNode->SetData(tmpPFchild); newChildPFCNode->SetName( savedPFchildNode->GetName() ); pfcompcast->setDisplayName( savedPFchildNode->GetName() ); //name might be changed in DataManager by user //update inside vector the dataNodePointer pfc->replaceDataNodeAt(i, newChildPFCNode); AddCompositeToDatastorage(pfcompcast, newPFCNode); //the current PFCNode becomes the childs parent // remove old child position in dataStorage GetDataStorage()->Remove(savedPFchildNode); } else { // child is not of type PlanarFigureComposite, so its one of the planarFigures // create new dataNode containing the data of the old dataNode, but position in dataManager will be // modified cuz we re setting a (new) parent. mitk::DataNode::Pointer newPFchildNode = mitk::DataNode::New(); newPFchildNode->SetName(savedPFchildNode->GetName() ); newPFchildNode->SetData(tmpPFchild); newPFchildNode->SetVisibility(true); newPFchildNode->SetBoolProperty("planarfigure.3drendering", true); // replace the dataNode in PFComp DataNodeVector pfc->replaceDataNodeAt(i, newPFchildNode); // remove old child position in dataStorage GetDataStorage()->Remove(savedPFchildNode); //add new child to datamanager with its new position as child of newPFCNode parent GetDataStorage()->Add(newPFchildNode, newPFCNode); } } break; } case 2: { if (!parentNode.IsNull()) GetDataStorage()->Add(newPFCNode, parentNode); else GetDataStorage()->Add(newPFCNode); //iterate through its childs for(int i=0; igetNumberOfChildren(); ++i) { mitk::BaseData::Pointer tmpPFchild = pfc->getChildAt(i); mitk::DataNode::Pointer savedPFchildNode = pfc->getDataNodeAt(i); mitk::PlanarFigureComposite::Pointer pfcompcast= dynamic_cast(tmpPFchild.GetPointer()); if ( !pfcompcast.IsNull() ) { // child is of type planar Figure composite // makeRemoveBundle new node of the child, cuz later the child has to be removed of its old position in datamanager // feed new dataNode with information of the savedDataNode, which is gonna be removed soon mitk::DataNode::Pointer newChildPFCNode; newChildPFCNode = mitk::DataNode::New(); newChildPFCNode->SetData(tmpPFchild); newChildPFCNode->SetName( savedPFchildNode->GetName() ); pfcompcast->setDisplayName( savedPFchildNode->GetName() ); //name might be changed in DataManager by user //update inside vector the dataNodePointer pfc->replaceDataNodeAt(i, newChildPFCNode); AddCompositeToDatastorage(pfcompcast, newPFCNode); //the current PFCNode becomes the childs parent // remove old child position in dataStorage GetDataStorage()->Remove(savedPFchildNode); } else { // child is not of type PlanarFigureComposite, so its one of the planarFigures // create new dataNode containing the data of the old dataNode, but position in dataManager will be // modified cuz we re setting a (new) parent. mitk::DataNode::Pointer newPFchildNode = mitk::DataNode::New(); newPFchildNode->SetName(savedPFchildNode->GetName() ); newPFchildNode->SetData(tmpPFchild); newPFchildNode->SetVisibility(true); newPFchildNode->SetBoolProperty("planarfigure.3drendering", true); // replace the dataNode in PFComp DataNodeVector pfc->replaceDataNodeAt(i, newPFchildNode); // remove old child position in dataStorage GetDataStorage()->Remove(savedPFchildNode); //add new child to datamanager with its new position as child of newPFCNode parent GetDataStorage()->Add(newPFchildNode, newPFCNode); } } break; } default: MITK_DEBUG << "we have an UNDEFINED composition... ERROR" ; break; } for(unsigned int i = 0; i < m_SelectedPF.size(); i++) m_SelectedPF[i]->SetSelected(false); newPFCNode->SetSelected(true); m_SelectedPF.clear(); m_SelectedPF.push_back(newPFCNode); UpdateGui(); } void QmitkFiberProcessingView::JoinBundles() { if ( m_SelectedFB.size()<2 ){ QMessageBox::information( NULL, "Warning", "Select at least two fiber bundles!"); MITK_WARN("QmitkFiberProcessingView") << "Select at least two fiber bundles!"; return; } mitk::FiberBundleX::Pointer newBundle = dynamic_cast(m_SelectedFB.at(0)->GetData()); m_SelectedFB.at(0)->SetVisibility(false); QString name(""); name += QString(m_SelectedFB.at(0)->GetName().c_str()); for (unsigned int i=1; iAddBundle(dynamic_cast(m_SelectedFB.at(i)->GetData())); name += "+"+QString(m_SelectedFB.at(i)->GetName().c_str()); m_SelectedFB.at(i)->SetVisibility(false); } mitk::DataNode::Pointer fbNode = mitk::DataNode::New(); fbNode->SetData(newBundle); fbNode->SetName(name.toStdString()); fbNode->SetVisibility(true); GetDataStorage()->Add(fbNode); } void QmitkFiberProcessingView::SubstractBundles() { if ( m_SelectedFB.size()<2 ){ QMessageBox::information( NULL, "Warning", "Select at least two fiber bundles!"); MITK_WARN("QmitkFiberProcessingView") << "Select at least two fiber bundles!"; return; } mitk::FiberBundleX::Pointer newBundle = dynamic_cast(m_SelectedFB.at(0)->GetData()); m_SelectedFB.at(0)->SetVisibility(false); QString name(""); name += QString(m_SelectedFB.at(0)->GetName().c_str()); for (unsigned int i=1; iSubtractBundle(dynamic_cast(m_SelectedFB.at(i)->GetData())); if (newBundle.IsNull()) break; name += "-"+QString(m_SelectedFB.at(i)->GetName().c_str()); m_SelectedFB.at(i)->SetVisibility(false); } if (newBundle.IsNull()) { QMessageBox::information(NULL, "No output generated:", "The resulting fiber bundle contains no fibers. Did you select the fiber bundles in the correct order? X-Y is not equal to Y-X!"); return; } mitk::DataNode::Pointer fbNode = mitk::DataNode::New(); fbNode->SetData(newBundle); fbNode->SetName(name.toStdString()); fbNode->SetVisibility(true); GetDataStorage()->Add(fbNode); } void QmitkFiberProcessingView::ResampleSelectedBundles() { double factor = this->m_Controls->m_SmoothFibersBox->value(); for (unsigned int i=0; i(m_SelectedFB.at(i)->GetData()); fib->ResampleSpline(factor); } RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberProcessingView::CompressSelectedBundles() { double factor = this->m_Controls->m_ErrorThresholdBox->value(); for (unsigned int i=0; i(m_SelectedFB.at(i)->GetData()); fib->Compress(factor); } RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberProcessingView::DoImageColorCoding() { if (m_Controls->m_ColorMapBox->GetSelectedNode().IsNull()) { QMessageBox::information(NULL, "Bundle coloring aborted:", "No image providing the scalar values for coloring the selected bundle available."); return; } for(unsigned int i=0; i(m_SelectedFB.at(i)->GetData()); - fib->SetFAMap(dynamic_cast(m_Controls->m_ColorMapBox->GetSelectedNode()->GetData())); - fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_FA_BASED); - fib->DoColorCodingFaBased(); + fib->ColorFibersByScalarMap(dynamic_cast(m_Controls->m_ColorMapBox->GetSelectedNode()->GetData()), m_Controls->m_FiberOpacityBox->isChecked()); } if(m_MultiWidget) m_MultiWidget->RequestUpdate(); } void QmitkFiberProcessingView::MirrorFibers() { unsigned int axis = this->m_Controls->m_MirrorFibersBox->currentIndex(); for (int i=0; i(m_SelectedFB.at(i)->GetData()); fib->MirrorFibers(axis); } if (m_SelectedSurfaces.size()>0) { for (int i=0; i poly = surf->GetVtkPolyData(); vtkSmartPointer vtkNewPoints = vtkSmartPointer::New(); for (int i=0; iGetNumberOfPoints(); i++) { double* point = poly->GetPoint(i); point[axis] *= -1; vtkNewPoints->InsertNextPoint(point); } poly->SetPoints(vtkNewPoints); surf->CalculateBoundingBox(); } } RenderingManager::GetInstance()->RequestUpdateAll(); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui index 92870999a5..51bfb4158d 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberProcessingViewControls.ui @@ -1,1339 +1,1320 @@ QmitkFiberProcessingViewControls 0 0 386 540 Form 0 0 0 355 302 Fiber Extraction Extract a fiber subset from the selected fiber bundle using manually placed planar figures as waypoints or binary regions of interest. false 0 0 200 16777215 11 Extract fibers passing through selected ROI or composite ROI. Select ROI and fiber bundle to execute. Extract Qt::Vertical 20 40 0 0 Ending in mask Not ending in mask Passing mask Not passing mask QFrame::NoFrame QFrame::Raised 9 9 9 9 0 false 0 0 16777215 16777215 11 Generate a binary image containing all selected ROIs. Select at least one ROI (planar figure) and a reference fiber bundle or image. Generate ROI Image 0 0 200 0 16777215 60 QFrame::NoFrame QFrame::Raised 0 0 0 0 false 60 16777215 Create OR composition with selected ROIs. OR Qt::Horizontal 40 20 false 60 16777215 Create NOT composition from selected ROI. NOT false 60 16777215 Create AND composition with selected ROIs. AND 0 0 200 0 16777215 60 QFrame::NoFrame QFrame::Raised 0 0 0 0 30 30 Draw circular ROI. Select reference fiber bundle to execute. :/QmitkDiffusionImaging/circle.png:/QmitkDiffusionImaging/circle.png 32 32 false true - - - - - 30 - 30 - - - - Draw rectangular ROI. Select reference fiber bundle to execute. - - - - - - - :/QmitkDiffusionImaging/rectangle.png:/QmitkDiffusionImaging/rectangle.png + + + + Qt::Horizontal - + - 32 - 32 + 40 + 20 - - true - - - true - - + - + 30 30 Draw polygonal ROI. Select reference fiber bundle to execute. :/QmitkDiffusionImaging/polygon.png:/QmitkDiffusionImaging/polygon.png 32 32 true true - - - - Qt::Horizontal - - - - 40 - 20 - - - - 0 0 Extract using planar figures Extract using binary ROI image 0 0 270 380 Fiber Removal Remove fibers that satisfy certain criteria from the selected bundle. 0 0 Remove fibers in direction Remove fibers by length Remove fibers by curvature Remove fiber parts outside mask Remove fiber parts inside mask QFrame::NoFrame QFrame::Raised 0 0 0 0 Qt::Horizontal 40 20 Minimum fiber length in mm 0 999999999 20 Max. Length: Min. Length: Maximum fiber length in mm 0 999999999 300 QFrame::NoFrame QFrame::Raised 0 0 0 0 0 X: Y: Z: Angle: Angular deviation threshold in degree 1 90.000000000000000 1.000000000000000 5.000000000000000 QFrame::NoFrame QFrame::Raised 0 0 0 0 If unchecked, the fiber exceeding the threshold will be split in two instead of removed. Remove Fiber false QFrame::NoFrame QFrame::Raised 0 0 0 0 0 Max. Angular Deviation: Qt::Horizontal 40 20 Maximum angular deviation in degree 180.000000000000000 0.100000000000000 15.000000000000000 Distance: Distance in mm 1 999.000000000000000 1.000000000000000 10.000000000000000 false 0 0 200 16777215 11 - Remove all fiber parts outside of the mask. + Remove Qt::Vertical 20 40 0 0 355 - 327 + 349 Bundle Modification Modify the selected bundle with operations such as fiber resampling, FA coloring, etc. QFrame::NoFrame QFrame::Raised 0 0 0 0 0 Error threshold in mm: 999999999.000000000000000 0.100000000000000 0.100000000000000 QFrame::NoFrame QFrame::Raised 0 0 0 0 0 Axial Sagittal Coronal Select direction: QFrame::NoFrame QFrame::Raised 0 0 0 0 0 - - - Scalar map: + + + + + + + If checked, the image values are not only used to color the fibers but are also used as opaxity values. + + + Values as opacity + + + true + + + 0 0 Smooth fibers Compress fibers Color fibers by scalar map (e.g. FA) Mirror fibers Weight Bundle QFrame::NoFrame QFrame::Raised 0 0 0 0 0 0.010000000000000 999999999.000000000000000 1.000000000000000 Point distance in mm: Qt::Vertical 20 40 false 0 0 200 16777215 11 - Remove all fiber parts outside of the mask. + Execute QFrame::NoFrame QFrame::Raised 0 0 0 0 0 Weight: 7 1.000000000000000 0.100000000000000 1.000000000000000 0 0 360 61 Binary Bundle Operations Join or subtract bundles. false 0 0 200 16777215 11 Returns all fibers contained in bundle X that are not contained in bundle Y (not commutative!). Select at least two fiber bundles to execute. Substract false 0 0 200 16777215 11 Merge selected fiber bundles. Select at least two fiber bundles to execute. Join Qt::Vertical 20 40 Please Select Input Data <html><head/><body><p><span style=" color:#ff0000;">mandatory</span></p></body></html> true <html><head/><body><p><span style=" color:#969696;">needed for extraction</span></p></body></html> true Input DTI Fiber Bundle: Binary seed ROI. If not specified, the whole image area is seeded. ROI: Qt::Vertical 20 40 QmitkDataStorageComboBox QComboBox
QmitkDataStorageComboBox.h