diff --git a/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractsToDWIImageFilter.cpp b/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractsToDWIImageFilter.cpp index 369b8a9dfc..f46691dc1b 100644 --- a/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractsToDWIImageFilter.cpp +++ b/Modules/DiffusionImaging/FiberTracking/Algorithms/itkTractsToDWIImageFilter.cpp @@ -1,624 +1,607 @@ /*=================================================================== 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 "itkTractsToDWIImageFilter.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace itk { TractsToDWIImageFilter::TractsToDWIImageFilter() : m_CircleDummy(false) , m_VolumeAccuracy(10) , m_Upsampling(1) , m_NumberOfRepetitions(1) , m_EnforcePureFiberVoxels(false) , m_InterpolationShrink(10) , m_FiberRadius(20) , m_SignalScale(300) { m_Spacing.Fill(2.5); m_Origin.Fill(0.0); m_DirectionMatrix.SetIdentity(); m_ImageRegion.SetSize(0, 10); m_ImageRegion.SetSize(1, 10); m_ImageRegion.SetSize(2, 10); } TractsToDWIImageFilter::~TractsToDWIImageFilter() { } std::vector< TractsToDWIImageFilter::DoubleDwiType::Pointer > TractsToDWIImageFilter::AddKspaceArtifacts( std::vector< DoubleDwiType::Pointer >& images ) { // create slice object SliceType::Pointer slice = SliceType::New(); ImageRegion<2> region; region.SetSize(0, m_UpsampledImageRegion.GetSize()[0]); region.SetSize(1, m_UpsampledImageRegion.GetSize()[1]); slice->SetLargestPossibleRegion( region ); slice->SetBufferedRegion( region ); slice->SetRequestedRegion( region ); slice->Allocate(); boost::progress_display disp(images.size()*images[0]->GetVectorLength()*images[0]->GetLargestPossibleRegion().GetSize(2)); std::vector< DoubleDwiType::Pointer > outImages; for (int i=0; iSetSpacing( m_Spacing ); newImage->SetOrigin( m_Origin ); newImage->SetDirection( m_DirectionMatrix ); newImage->SetLargestPossibleRegion( m_ImageRegion ); newImage->SetBufferedRegion( m_ImageRegion ); newImage->SetRequestedRegion( m_ImageRegion ); newImage->SetVectorLength( image->GetVectorLength() ); newImage->Allocate(); DiffusionSignalModel* signalModel; if (iGetVectorLength(); g++) for (int z=0; zGetLargestPossibleRegion().GetSize(2); z++) { ++disp; // extract slice from channel g for (int y=0; yGetLargestPossibleRegion().GetSize(1); y++) for (int x=0; xGetLargestPossibleRegion().GetSize(0); x++) { SliceType::IndexType index2D; index2D[0]=x; index2D[1]=y; DoubleDwiType::IndexType index3D; index3D[0]=x; index3D[1]=y; index3D[2]=z; SliceType::PixelType pix2D = image->GetPixel(index3D)[g]; slice->SetPixel(index2D, pix2D); } // fourier transform slice itk::FFTRealToComplexConjugateImageFilter< SliceType::PixelType, 2 >::Pointer fft = itk::FFTRealToComplexConjugateImageFilter< SliceType::PixelType, 2 >::New(); fft->SetInput(slice); fft->Update(); ComplexSliceType::Pointer fSlice = fft->GetOutput(); fSlice = RearrangeSlice(fSlice); // add artifacts for (int a=0; aSetT2(signalModel->GetT2()); fSlice = m_KspaceArtifacts.at(a)->AddArtifact(fSlice); } // save k-space slice of s0 image if (g==0) for (int y=0; yGetLargestPossibleRegion().GetSize(1); y++) for (int x=0; xGetLargestPossibleRegion().GetSize(0); x++) { DoubleDwiType::IndexType index3D; index3D[0]=x; index3D[1]=y; index3D[2]=z; SliceType::IndexType index2D; index2D[0]=x; index2D[1]=y; double kpix = sqrt(fSlice->GetPixel(index2D).real()*fSlice->GetPixel(index2D).real()+fSlice->GetPixel(index2D).imag()*fSlice->GetPixel(index2D).imag()); m_KspaceImage->SetPixel(index3D, kpix); } // inverse fourier transform slice SliceType::Pointer newSlice; itk::FFTComplexConjugateToRealImageFilter< SliceType::PixelType, 2 >::Pointer ifft = itk::FFTComplexConjugateToRealImageFilter< SliceType::PixelType, 2 >::New(); ifft->SetInput(fSlice); ifft->Update(); newSlice = ifft->GetOutput(); // put slice back into channel g for (int y=0; yGetLargestPossibleRegion().GetSize(1); y++) for (int x=0; xGetLargestPossibleRegion().GetSize(0); x++) { DoubleDwiType::IndexType index3D; index3D[0]=x; index3D[1]=y; index3D[2]=z; DoubleDwiType::PixelType pix3D = newImage->GetPixel(index3D); SliceType::IndexType index2D; index2D[0]=x; index2D[1]=y; pix3D[g] = newSlice->GetPixel(index2D); newImage->SetPixel(index3D, pix3D); } } outImages.push_back(newImage); } return outImages; } TractsToDWIImageFilter::ComplexSliceType::Pointer TractsToDWIImageFilter::RearrangeSlice(ComplexSliceType::Pointer slice) { ImageRegion<2> region = slice->GetLargestPossibleRegion(); ComplexSliceType::Pointer rearrangedSlice = ComplexSliceType::New(); rearrangedSlice->SetLargestPossibleRegion( region ); rearrangedSlice->SetBufferedRegion( region ); rearrangedSlice->SetRequestedRegion( region ); rearrangedSlice->Allocate(); int xHalf = region.GetSize(0)/2; int yHalf = region.GetSize(1)/2; for (int y=0; y pix = slice->GetPixel(idx); if( idx[0] < xHalf ) idx[0] = idx[0] + xHalf; else idx[0] = idx[0] - xHalf; if( idx[1] < yHalf ) idx[1] = idx[1] + yHalf; else idx[1] = idx[1] - yHalf; rearrangedSlice->SetPixel(idx, pix); } return rearrangedSlice; } void TractsToDWIImageFilter::GenerateData() { // check input data if (m_FiberBundle.IsNull()) itkExceptionMacro("Input fiber bundle is NULL!"); int numFibers = m_FiberBundle->GetNumFibers(); if (numFibers<=0) itkExceptionMacro("Input fiber bundle contains no fibers!"); if (m_FiberModels.empty()) itkExceptionMacro("No diffusion model for fiber compartments defined!"); if (m_NonFiberModels.empty()) itkExceptionMacro("No diffusion model for non-fiber compartments defined!"); int baselineIndex = m_FiberModels[0]->GetFirstBaselineIndex(); if (baselineIndex<0) itkExceptionMacro("No baseline index found!"); // determine k-space undersampling for (int i=0; i*>(m_KspaceArtifacts.at(i)) ) m_Upsampling = dynamic_cast*>(m_KspaceArtifacts.at(i))->GetKspaceCropping(); if (m_Upsampling<1) m_Upsampling = 1; if (m_TissueMask.IsNotNull()) { // use input tissue mask m_Spacing = m_TissueMask->GetSpacing(); m_Origin = m_TissueMask->GetOrigin(); m_DirectionMatrix = m_TissueMask->GetDirection(); m_ImageRegion = m_TissueMask->GetLargestPossibleRegion(); if (m_Upsampling>1) { ImageRegion<3> region = m_ImageRegion; region.SetSize(0, m_ImageRegion.GetSize(0)*m_Upsampling); region.SetSize(1, m_ImageRegion.GetSize(1)*m_Upsampling); mitk::Vector3D spacing = m_Spacing; spacing[0] /= m_Upsampling; spacing[1] /= m_Upsampling; itk::RescaleIntensityImageFilter::Pointer rescaler = itk::RescaleIntensityImageFilter::New(); rescaler->SetInput(0,m_TissueMask); rescaler->SetOutputMaximum(100); rescaler->SetOutputMinimum(0); rescaler->Update(); itk::ResampleImageFilter::Pointer resampler = itk::ResampleImageFilter::New(); resampler->SetInput(rescaler->GetOutput()); resampler->SetOutputParametersFromImage(m_TissueMask); resampler->SetSize(region.GetSize()); resampler->SetOutputSpacing(spacing); resampler->Update(); m_TissueMask = resampler->GetOutput(); } MITK_INFO << "Using tissue mask"; } // initialize output dwi image OutputImageType::Pointer outImage = OutputImageType::New(); outImage->SetSpacing( m_Spacing ); outImage->SetOrigin( m_Origin ); outImage->SetDirection( m_DirectionMatrix ); outImage->SetLargestPossibleRegion( m_ImageRegion ); outImage->SetBufferedRegion( m_ImageRegion ); outImage->SetRequestedRegion( m_ImageRegion ); outImage->SetVectorLength( m_FiberModels[0]->GetNumGradients() ); outImage->Allocate(); OutputImageType::PixelType temp; temp.SetSize(m_FiberModels[0]->GetNumGradients()); temp.Fill(0.0); outImage->FillBuffer(temp); // is input slize size a power of two? int x=2; int y=2; while (x " << x; m_ImageRegion.SetSize(0, x); } if (y!=m_ImageRegion.GetSize(1)) { MITK_INFO << "Adjusting image height: " << m_ImageRegion.GetSize(1) << " --> " << y; m_ImageRegion.SetSize(1, y); } // initialize k-space image m_KspaceImage = ItkDoubleImgType::New(); m_KspaceImage->SetSpacing( m_Spacing ); m_KspaceImage->SetOrigin( m_Origin ); m_KspaceImage->SetDirection( m_DirectionMatrix ); m_KspaceImage->SetLargestPossibleRegion( m_ImageRegion ); m_KspaceImage->SetBufferedRegion( m_ImageRegion ); m_KspaceImage->SetRequestedRegion( m_ImageRegion ); m_KspaceImage->Allocate(); m_KspaceImage->FillBuffer(0); // apply undersampling to image parameters m_UpsampledSpacing = m_Spacing; m_UpsampledImageRegion = m_ImageRegion; m_UpsampledSpacing[0] /= m_Upsampling; m_UpsampledSpacing[1] /= m_Upsampling; m_UpsampledImageRegion.SetSize(0, m_ImageRegion.GetSize()[0]*m_Upsampling); m_UpsampledImageRegion.SetSize(1, m_ImageRegion.GetSize()[1]*m_Upsampling); // everything from here on is using the upsampled image parameters!!! if (m_TissueMask.IsNull()) { m_TissueMask = ItkUcharImgType::New(); m_TissueMask->SetSpacing( m_UpsampledSpacing ); m_TissueMask->SetOrigin( m_Origin ); m_TissueMask->SetDirection( m_DirectionMatrix ); m_TissueMask->SetLargestPossibleRegion( m_UpsampledImageRegion ); m_TissueMask->SetBufferedRegion( m_UpsampledImageRegion ); m_TissueMask->SetRequestedRegion( m_UpsampledImageRegion ); m_TissueMask->Allocate(); m_TissueMask->FillBuffer(1); } // resample fiber bundle for sufficient voxel coverage - double segmentVolume = 1; + double segmentVolume = 0.0001; float minSpacing = 1; if(m_UpsampledSpacing[0]GetDeepCopy(); fiberBundle->ResampleFibers(minSpacing/m_VolumeAccuracy); double mmRadius = m_FiberRadius/1000; if (mmRadius>0) segmentVolume = M_PI*mmRadius*mmRadius*minSpacing/m_VolumeAccuracy; // generate double images to wokr with because we don't want to lose precision // we use a separate image for each compartment model std::vector< DoubleDwiType::Pointer > compartments; for (int i=0; iSetSpacing( m_UpsampledSpacing ); doubleDwi->SetOrigin( m_Origin ); doubleDwi->SetDirection( m_DirectionMatrix ); doubleDwi->SetLargestPossibleRegion( m_UpsampledImageRegion ); doubleDwi->SetBufferedRegion( m_UpsampledImageRegion ); doubleDwi->SetRequestedRegion( m_UpsampledImageRegion ); doubleDwi->SetVectorLength( m_FiberModels[0]->GetNumGradients() ); doubleDwi->Allocate(); DoubleDwiType::PixelType pix; pix.SetSize(m_FiberModels[0]->GetNumGradients()); pix.Fill(0.0); doubleDwi->FillBuffer(pix); compartments.push_back(doubleDwi); } - if (m_CircleDummy) + double interpFact = 2*atan(-0.5*m_InterpolationShrink); + double maxVolume = 0; + + vtkSmartPointer fiberPolyData = fiberBundle->GetFiberPolyData(); + vtkSmartPointer vLines = fiberPolyData->GetLines(); + vLines->InitTraversal(); + + MITK_INFO << "Generating signal of " << m_FiberModels.size() << " fiber compartments"; + boost::progress_display disp(numFibers); + for( int i=0; iGetNextCell ( numPoints, points ); + if (numPoints<2) + continue; + + for( int j=0; jGetNumGradients()); - pix.Fill(1); - - DoubleDwiType::Pointer doubleDwi = compartments.at(i); - ImageRegion<3> region = doubleDwi->GetLargestPossibleRegion(); - ImageRegionIterator it(doubleDwi, region); - while(!it.IsAtEnd()) + double* temp = fiberPolyData->GetPoint(points[j]); + itk::Point vertex = GetItkPoint(temp); + itk::Vector v = GetItkVector(temp); + + itk::Vector dir(3); + if (jGetPoint(points[j+1]))-v; + else + dir = v-GetItkVector(fiberPolyData->GetPoint(points[j-1])); + + itk::Index<3> idx; + itk::ContinuousIndex contIndex; + m_TissueMask->TransformPhysicalPointToIndex(vertex, idx); + m_TissueMask->TransformPhysicalPointToContinuousIndex(vertex, contIndex); + + double frac_x = contIndex[0] - idx[0]; + double frac_y = contIndex[1] - idx[1]; + double frac_z = contIndex[2] - idx[2]; + if (frac_x<0) { - DoubleDwiType::IndexType index = it.GetIndex(); - double t = region.GetSize(0)/2; - double d1 = index[0]-t+0.5; - t = region.GetSize(1)/2; - double d2 = index[1]-t+0.5; - if (sqrt(d1*d1+d2*d2)<20*m_Upsampling) - it.Set(pix); - ++it; + idx[0] -= 1; + frac_x += 1; + } + if (frac_y<0) + { + idx[1] -= 1; + frac_y += 1; + } + if (frac_z<0) + { + idx[2] -= 1; + frac_z += 1; } - } - } - else - { - double interpFact = 2*atan(-0.5*m_InterpolationShrink); - double maxVolume = 0; - vtkSmartPointer fiberPolyData = fiberBundle->GetFiberPolyData(); - vtkSmartPointer vLines = fiberPolyData->GetLines(); - vLines->InitTraversal(); + frac_x = atan((0.5-frac_x)*m_InterpolationShrink)/interpFact + 0.5; + frac_y = atan((0.5-frac_y)*m_InterpolationShrink)/interpFact + 0.5; + frac_z = atan((0.5-frac_z)*m_InterpolationShrink)/interpFact + 0.5; - MITK_INFO << "Generating signal of " << m_FiberModels.size() << " fiber compartments"; - boost::progress_display disp(numFibers); - for( int i=0; iGetNextCell ( numPoints, points ); - if (numPoints<2) - continue; - - for( int j=0; j newIdx; + for (int x=0; x<2; x++) { - double* temp = fiberPolyData->GetPoint(points[j]); - itk::Point vertex = GetItkPoint(temp); - itk::Vector v = GetItkVector(temp); - - itk::Vector dir(3); - if (jGetPoint(points[j+1]))-v; - else - dir = v-GetItkVector(fiberPolyData->GetPoint(points[j-1])); - - itk::Index<3> idx; - itk::ContinuousIndex contIndex; - m_TissueMask->TransformPhysicalPointToIndex(vertex, idx); - m_TissueMask->TransformPhysicalPointToContinuousIndex(vertex, contIndex); - - double frac_x = contIndex[0] - idx[0]; - double frac_y = contIndex[1] - idx[1]; - double frac_z = contIndex[2] - idx[2]; - if (frac_x<0) - { - idx[0] -= 1; - frac_x += 1; - } - if (frac_y<0) - { - idx[1] -= 1; - frac_y += 1; - } - if (frac_z<0) + frac_x = 1-frac_x; + for (int y=0; y<2; y++) { - idx[2] -= 1; - frac_z += 1; - } + frac_y = 1-frac_y; + for (int z=0; z<2; z++) + { + frac_z = 1-frac_z; - frac_x = atan((0.5-frac_x)*m_InterpolationShrink)/interpFact + 0.5; - frac_y = atan((0.5-frac_y)*m_InterpolationShrink)/interpFact + 0.5; - frac_z = atan((0.5-frac_z)*m_InterpolationShrink)/interpFact + 0.5; + newIdx[0] = idx[0]+x; + newIdx[1] = idx[1]+y; + newIdx[2] = idx[2]+z; - // use trilinear interpolation - itk::Index<3> newIdx; - for (int x=0; x<2; x++) - { - frac_x = 1-frac_x; - for (int y=0; y<2; y++) - { - frac_y = 1-frac_y; - for (int z=0; z<2; z++) + double frac = frac_x*frac_y*frac_z; + + // is position valid? + if (!m_TissueMask->GetLargestPossibleRegion().IsInside(newIdx) || m_TissueMask->GetPixel(newIdx)<=0) + continue; + + // generate signal for each fiber compartment + for (int k=0; kGetLargestPossibleRegion().IsInside(newIdx) || m_TissueMask->GetPixel(newIdx)<=0) - continue; - - // generate signal for each fiber compartment - for (int k=0; kSetFiberDirection(dir); - DoubleDwiType::PixelType pix = doubleDwi->GetPixel(newIdx); - pix += segmentVolume*frac*m_FiberModels[k]->SimulateMeasurement(); - doubleDwi->SetPixel(newIdx, pix ); - if (pix[baselineIndex]>maxVolume) - maxVolume = pix[baselineIndex]; - } + DoubleDwiType::Pointer doubleDwi = compartments.at(k); + m_FiberModels[k]->SetFiberDirection(dir); + DoubleDwiType::PixelType pix = doubleDwi->GetPixel(newIdx); + pix += segmentVolume*frac*m_FiberModels[k]->SimulateMeasurement(); + doubleDwi->SetPixel(newIdx, pix ); + if (pix[baselineIndex]>maxVolume) + maxVolume = pix[baselineIndex]; } } } } } + } - MITK_INFO << "Generating signal of " << m_NonFiberModels.size() << " non-fiber compartments"; - ImageRegionIterator it3(m_TissueMask, m_TissueMask->GetLargestPossibleRegion()); - boost::progress_display disp3(m_TissueMask->GetLargestPossibleRegion().GetNumberOfPixels()); - double voxelVolume = m_UpsampledSpacing[0]*m_UpsampledSpacing[1]*m_UpsampledSpacing[2]; + MITK_INFO << "Generating signal of " << m_NonFiberModels.size() << " non-fiber compartments"; + ImageRegionIterator it3(m_TissueMask, m_TissueMask->GetLargestPossibleRegion()); + boost::progress_display disp3(m_TissueMask->GetLargestPossibleRegion().GetNumberOfPixels()); + double voxelVolume = m_UpsampledSpacing[0]*m_UpsampledSpacing[1]*m_UpsampledSpacing[2]; - double fact = 1; - if (m_FiberRadius<0.0001) - fact = voxelVolume/maxVolume; + double fact = 1; + if (m_FiberRadius<0.0001) + fact = voxelVolume/maxVolume; - while(!it3.IsAtEnd()) + while(!it3.IsAtEnd()) + { + ++disp3; + DoubleDwiType::IndexType index = it3.GetIndex(); + + if (it3.Get()>0) { - ++disp3; - DoubleDwiType::IndexType index = it3.GetIndex(); + // get fiber volume fraction + DoubleDwiType::Pointer fiberDwi = compartments.at(0); + DoubleDwiType::PixelType fiberPix = fiberDwi->GetPixel(index); // intra axonal compartment + if (fact>1) // auto scale intra-axonal if no fiber radius is specified + { + fiberPix *= fact; + fiberDwi->SetPixel(index, fiberPix); + } + double f = fiberPix[baselineIndex]; - if (it3.Get()>0) + if (f>voxelVolume || f>0 && m_EnforcePureFiberVoxels) // more fiber than space in voxel? { - // get fiber volume fraction - double w = 0; - for (int i=0; iSetPixel(index, fiberPix*voxelVolume/f); + + for (int i=1; iGetPixel(index); - if (fact<1) - { - pix *= fact; - compartments.at(i)->SetPixel(index, pix); - } - w += pix[baselineIndex]; + DoubleDwiType::PixelType pix; pix.Fill(0.0); + compartments.at(i)->SetPixel(index, pix); } - - if (w>voxelVolume || w>0 && m_EnforcePureFiberVoxels) // more fiber than space in voxel? + } + else + { + double nonf = voxelVolume-f; // non-fiber volume + double inter = 0; + if (m_FiberModels.size()>1) + inter = nonf * f; // intra-axonal fraction of non fiber compartment scales linearly with f + double other = nonf - inter; // rest of compartment + + // adjust non-fiber and intra-axonal signal + for (int i=1; iSetPixel(index, doubleDwi->GetPixel(index)*voxelVolume/w); - } + DoubleDwiType::Pointer doubleDwi = compartments.at(i); + DoubleDwiType::PixelType pix = doubleDwi->GetPixel(index); + if (pix[baselineIndex]>0) + pix /= pix[baselineIndex]; + pix *= inter; + doubleDwi->SetPixel(index, pix); } - else + for (int i=0; iGetPixel(index) + m_NonFiberModels[i]->SimulateMeasurement()*w*m_NonFiberModels[i]->GetWeight(); - doubleDwi->SetPixel(index, pix); - } + DoubleDwiType::Pointer doubleDwi = compartments.at(i+m_FiberModels.size()); + DoubleDwiType::PixelType pix = doubleDwi->GetPixel(index) + m_NonFiberModels[i]->SimulateMeasurement()*other*m_NonFiberModels[i]->GetWeight(); + doubleDwi->SetPixel(index, pix); } } - ++it3; } + ++it3; } // do k-space stuff if (!m_KspaceArtifacts.empty()) MITK_INFO << "Generating k-space artifacts"; else MITK_INFO << "Generating k-space image"; compartments = AddKspaceArtifacts(compartments); MITK_INFO << "Summing compartments and adding noise"; - double correction = m_SignalScale; ///(m_Upsampling*m_Upsampling); ImageRegionIterator it4 (outImage, outImage->GetLargestPossibleRegion()); DoubleDwiType::PixelType signal; signal.SetSize(m_FiberModels[0]->GetNumGradients()); boost::progress_display disp4(outImage->GetLargestPossibleRegion().GetNumberOfPixels()); while(!it4.IsAtEnd()) { ++disp4; DWIImageType::IndexType index = it4.GetIndex(); signal.Fill(0.0); // adjust fiber signal for (int i=0; iGetPixel(index)*correction; + signal += compartments.at(i)->GetPixel(index)*m_SignalScale; // adjust non-fiber signal for (int i=0; iGetPixel(index)*correction; + signal += compartments.at(m_FiberModels.size()+i)->GetPixel(index)*m_SignalScale; DoubleDwiType::PixelType accu = signal; accu.Fill(0.0); for (int i=0; iAddNoise(temp); accu += temp; } signal = accu/m_NumberOfRepetitions; for (int i=0; i0) signal[i] = floor(signal[i]+0.5); else signal[i] = ceil(signal[i]-0.5); } it4.Set(signal); ++it4; } this->SetNthOutput(0, outImage); } itk::Point TractsToDWIImageFilter::GetItkPoint(double point[3]) { itk::Point itkPoint; itkPoint[0] = point[0]; itkPoint[1] = point[1]; itkPoint[2] = point[2]; return itkPoint; } itk::Vector TractsToDWIImageFilter::GetItkVector(double point[3]) { itk::Vector itkVector; itkVector[0] = point[0]; itkVector[1] = point[1]; itkVector[2] = point[2]; return itkVector; } vnl_vector_fixed TractsToDWIImageFilter::GetVnlVector(double point[3]) { vnl_vector_fixed vnlVector; vnlVector[0] = point[0]; vnlVector[1] = point[1]; vnlVector[2] = point[2]; return vnlVector; } vnl_vector_fixed TractsToDWIImageFilter::GetVnlVector(Vector& vector) { vnl_vector_fixed vnlVector; vnlVector[0] = vector[0]; vnlVector[1] = vector[1]; vnlVector[2] = vector[2]; return vnlVector; } } diff --git a/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.cpp b/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.cpp index b23d6d6443..28ee1cb38c 100644 --- a/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.cpp +++ b/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.cpp @@ -1,115 +1,80 @@ /*=================================================================== 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 #include template< class ScalarType > TensorModel< ScalarType >::TensorModel() - : m_KernelFA(0.6) - , m_KernelADC(0.001) - , m_BValue(1000) + : m_BValue(1000) { m_KernelDirection[0]=1; m_KernelDirection[1]=0; m_KernelDirection[2]=0; - UpdateKernelTensor(); -} - -template< class ScalarType > -TensorModel< ScalarType >::~TensorModel() -{ - -} - -template< class ScalarType > -void TensorModel< ScalarType >::UpdateKernelTensor() -{ - ItkTensorType tensor; tensor.Fill(0.0); - float e1 = m_KernelADC*(1+2*m_KernelFA/sqrt(3-2*m_KernelFA*m_KernelFA)); - float e2 = m_KernelADC*(1-m_KernelFA/sqrt(3-2*m_KernelFA*m_KernelFA)); - tensor.SetElement(0, e1); - tensor.SetElement(3, e2); - tensor.SetElement(5, e2); - m_KernelTensorMatrix.fill(0.0); - m_KernelTensorMatrix[0][0] = e1; m_KernelTensorMatrix[1][1] = e2; m_KernelTensorMatrix[2][2] = e2; -} - -template< class ScalarType > -void TensorModel< ScalarType >::SetKernelFA(float FA) -{ - m_KernelFA = FA; - UpdateKernelTensor(); + m_KernelTensorMatrix[0][0] = 0.002; + m_KernelTensorMatrix[1][1] = 0.0005; + m_KernelTensorMatrix[2][2] = 0.0005; } template< class ScalarType > -void TensorModel< ScalarType >::SetKernelADC(float ADC) +TensorModel< ScalarType >::~TensorModel() { - m_KernelADC = ADC; - UpdateKernelTensor(); -} -template< class ScalarType > -void TensorModel< ScalarType >::SetKernelTensor(ItkTensorType& tensor) -{ - m_KernelTensorMatrix[0][0] = tensor[0]; m_KernelTensorMatrix[0][1] = tensor[1]; m_KernelTensorMatrix[0][2] = tensor[2]; - m_KernelTensorMatrix[1][0] = tensor[1]; m_KernelTensorMatrix[1][1] = tensor[3]; m_KernelTensorMatrix[1][2] = tensor[4]; - m_KernelTensorMatrix[2][0] = tensor[2]; m_KernelTensorMatrix[2][1] = tensor[4]; m_KernelTensorMatrix[2][2] = tensor[5]; } template< class ScalarType > typename TensorModel< ScalarType >::PixelType TensorModel< ScalarType >::SimulateMeasurement() { PixelType signal; signal.SetSize(this->m_GradientList.size()); signal.Fill(0.0); ItkTensorType tensor; tensor.Fill(0.0); this->m_FiberDirection.Normalize(); vnl_vector_fixed axis = itk::CrossProduct(m_KernelDirection, this->m_FiberDirection).GetVnlVector(); axis.normalize(); vnl_quaternion rotation(axis, acos(m_KernelDirection*this->m_FiberDirection)); rotation.normalize(); vnl_matrix_fixed matrix = rotation.rotation_matrix_transpose(); vnl_matrix_fixed tensorMatrix = matrix.transpose()*m_KernelTensorMatrix*matrix; tensor[0] = tensorMatrix[0][0]; tensor[1] = tensorMatrix[0][1]; tensor[2] = tensorMatrix[0][2]; tensor[3] = tensorMatrix[1][1]; tensor[4] = tensorMatrix[1][2]; tensor[5] = tensorMatrix[2][2]; for( unsigned int i=0; im_GradientList.size(); i++) { GradientType g = this->m_GradientList[i]; double bVal = g.GetNorm(); bVal *= bVal; if (bVal>0.0001) { itk::DiffusionTensor3D S; S[0] = g[0]*g[0]; S[1] = g[1]*g[0]; S[2] = g[2]*g[0]; S[3] = g[1]*g[1]; S[4] = g[2]*g[1]; S[5] = g[2]*g[2]; double D = tensor[0]*S[0] + tensor[1]*S[1] + tensor[2]*S[2] + tensor[1]*S[1] + tensor[3]*S[3] + tensor[4]*S[4] + tensor[2]*S[2] + tensor[4]*S[4] + tensor[5]*S[5]; // check for corrupted tensor and generate signal if (D>=0) signal[i] = exp ( -m_BValue * bVal * D ); } else signal[i] = 1; } return signal; } diff --git a/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.h b/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.h index fbb6b6eed2..0a94e5b860 100644 --- a/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.h +++ b/Modules/DiffusionImaging/FiberTracking/SignalModels/mitkTensorModel.h @@ -1,67 +1,64 @@ /*=================================================================== 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_TensorModel_H #define _MITK_TensorModel_H #include #include namespace mitk { /** * \brief Generates diffusion measurement employing a second rank tensor model: e^(-bg^TDg) * */ template< class ScalarType > class TensorModel : public DiffusionSignalModel< ScalarType > { public: TensorModel(); ~TensorModel(); typedef typename DiffusionSignalModel< ScalarType >::PixelType PixelType; typedef itk::DiffusionTensor3D< float > ItkTensorType; typedef typename DiffusionSignalModel< ScalarType >::GradientType GradientType; /** Actual signal generation **/ PixelType SimulateMeasurement(); - void SetKernelDirection(GradientType kernelDirection){ m_KernelDirection = kernelDirection; } - void SetKernelTensor(ItkTensorType& tensor); - void SetKernelFA(float FA); - void SetKernelADC(float ADC); void SetBvalue(float bValue) { m_BValue = bValue; } + void SetDiffusivity1(ScalarType d1){ m_KernelTensorMatrix[0][0] = d1; } + void SetDiffusivity2(ScalarType d2){ m_KernelTensorMatrix[1][1] = d2; } + void SetDiffusivity3(ScalarType d3){ m_KernelTensorMatrix[2][2] = d3; } protected: /** Calculates tensor matrix from FA and ADC **/ void UpdateKernelTensor(); - GradientType m_KernelDirection; ///< Direction of the kernel tensors principal eigenvector - vnl_matrix_fixed m_KernelTensorMatrix; ///< 3x3 matrix containing the kernel tensor values - float m_KernelFA; ///< FA of the kernel tensor - float m_KernelADC; ///< ADC of the kernel tensor - float m_BValue; ///< b-value used to generate the artificial signal + GradientType m_KernelDirection; ///< Direction of the kernel tensors principal eigenvector + vnl_matrix_fixed m_KernelTensorMatrix; ///< 3x3 matrix containing the kernel tensor values + float m_BValue; ///< b-value used to generate the artificial signal }; } #include "mitkTensorModel.cpp" #endif diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/files.cmake b/Plugins/org.mitk.gui.qt.diffusionimaging/files.cmake index 815b4ac00f..11da03d696 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/files.cmake +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/files.cmake @@ -1,148 +1,166 @@ set(SRC_CPP_FILES QmitkODFDetailsWidget.cpp QmitkODFRenderWidget.cpp QmitkPartialVolumeAnalysisWidget.cpp QmitkIVIMWidget.cpp QmitkTbssRoiAnalysisWidget.cpp QmitkResidualAnalysisWidget.cpp QmitkResidualViewWidget.cpp + QmitkTensorModelParametersWidget.cpp + QmitkZeppelinModelParametersWidget.cpp + QmitkStickModelParametersWidget.cpp + QmitkDotModelParametersWidget.cpp + QmitkBallModelParametersWidget.cpp + QmitkAstrosticksModelParametersWidget.cpp ) set(INTERNAL_CPP_FILES mitkPluginActivator.cpp QmitkQBallReconstructionView.cpp QmitkPreprocessingView.cpp QmitkDiffusionDicomImportView.cpp QmitkDiffusionQuantificationView.cpp QmitkTensorReconstructionView.cpp QmitkDiffusionImagingPublicPerspective.cpp QmitkControlVisualizationPropertiesView.cpp QmitkODFDetailsView.cpp QmitkGibbsTrackingView.cpp QmitkStochasticFiberTrackingView.cpp QmitkStreamlineTrackingView.cpp QmitkFiberProcessingView.cpp QmitkFiberBundleDeveloperView.cpp QmitkPartialVolumeAnalysisView.cpp QmitkIVIMView.cpp QmitkTractbasedSpatialStatisticsView.cpp QmitkTbssTableModel.cpp QmitkTbssMetaTableModel.cpp QmitkTbssSkeletonizationView.cpp Connectomics/QmitkConnectomicsDataView.cpp Connectomics/QmitkConnectomicsNetworkOperationsView.cpp Connectomics/QmitkConnectomicsStatisticsView.cpp Connectomics/QmitkNetworkHistogramCanvas.cpp QmitkDwiSoftwarePhantomView.cpp QmitkOdfMaximaExtractionView.cpp QmitkFiberfoxView.cpp ) set(UI_FILES src/internal/QmitkQBallReconstructionViewControls.ui src/internal/QmitkPreprocessingViewControls.ui src/internal/QmitkDiffusionDicomImportViewControls.ui src/internal/QmitkDiffusionQuantificationViewControls.ui src/internal/QmitkTensorReconstructionViewControls.ui src/internal/QmitkControlVisualizationPropertiesViewControls.ui src/internal/QmitkODFDetailsViewControls.ui src/internal/QmitkGibbsTrackingViewControls.ui src/internal/QmitkStochasticFiberTrackingViewControls.ui src/internal/QmitkStreamlineTrackingViewControls.ui src/internal/QmitkFiberProcessingViewControls.ui src/internal/QmitkFiberBundleDeveloperViewControls.ui src/internal/QmitkPartialVolumeAnalysisViewControls.ui src/internal/QmitkIVIMViewControls.ui src/internal/QmitkTractbasedSpatialStatisticsViewControls.ui src/internal/QmitkTbssSkeletonizationViewControls.ui src/internal/Connectomics/QmitkConnectomicsDataViewControls.ui src/internal/Connectomics/QmitkConnectomicsNetworkOperationsViewControls.ui src/internal/Connectomics/QmitkConnectomicsStatisticsViewControls.ui src/internal/QmitkDwiSoftwarePhantomViewControls.ui src/internal/QmitkOdfMaximaExtractionViewControls.ui src/internal/QmitkFiberfoxViewControls.ui + src/QmitkTensorModelParametersWidgetControls.ui + src/QmitkZeppelinModelParametersWidgetControls.ui + src/QmitkStickModelParametersWidgetControls.ui + src/QmitkDotModelParametersWidgetControls.ui + src/QmitkBallModelParametersWidgetControls.ui + src/QmitkAstrosticksModelParametersWidgetControls.ui ) set(MOC_H_FILES src/internal/mitkPluginActivator.h src/internal/QmitkQBallReconstructionView.h src/internal/QmitkPreprocessingView.h src/internal/QmitkDiffusionDicomImportView.h src/internal/QmitkDiffusionImagingPublicPerspective.h src/internal/QmitkDiffusionQuantificationView.h src/internal/QmitkTensorReconstructionView.h src/internal/QmitkControlVisualizationPropertiesView.h src/internal/QmitkODFDetailsView.h src/QmitkODFRenderWidget.h src/QmitkODFDetailsWidget.h src/internal/QmitkGibbsTrackingView.h src/internal/QmitkStochasticFiberTrackingView.h src/internal/QmitkStreamlineTrackingView.h src/internal/QmitkFiberProcessingView.h src/internal/QmitkFiberBundleDeveloperView.h src/internal/QmitkPartialVolumeAnalysisView.h src/QmitkPartialVolumeAnalysisWidget.h src/internal/QmitkIVIMView.h src/internal/QmitkTractbasedSpatialStatisticsView.h src/internal/QmitkTbssSkeletonizationView.h src/QmitkTbssRoiAnalysisWidget.h src/QmitkResidualAnalysisWidget.h src/QmitkResidualViewWidget.h src/internal/Connectomics/QmitkConnectomicsDataView.h src/internal/Connectomics/QmitkConnectomicsNetworkOperationsView.h src/internal/Connectomics/QmitkConnectomicsStatisticsView.h src/internal/Connectomics/QmitkNetworkHistogramCanvas.h src/internal/QmitkDwiSoftwarePhantomView.h src/internal/QmitkOdfMaximaExtractionView.h src/internal/QmitkFiberfoxView.h + src/QmitkTensorModelParametersWidget.h + src/QmitkZeppelinModelParametersWidget.h + src/QmitkStickModelParametersWidget.h + src/QmitkDotModelParametersWidget.h + src/QmitkBallModelParametersWidget.h + src/QmitkAstrosticksModelParametersWidget.h ) set(CACHED_RESOURCE_FILES # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench plugin.xml resources/preprocessing.png resources/dwiimport.png resources/quantification.png resources/reconodf.png resources/recontensor.png resources/vizControls.png resources/OdfDetails.png resources/GibbsTracking.png resources/FiberBundleOperations.png resources/PartialVolumeAnalysis_24.png resources/IVIM_48.png resources/stochFB.png resources/tbss.png resources/connectomics/QmitkConnectomicsDataViewIcon_48.png resources/connectomics/QmitkConnectomicsNetworkOperationsViewIcon_48.png resources/connectomics/QmitkConnectomicsStatisticsViewIcon_48.png resources/arrow.png resources/qball_peaks.png resources/phantom.png resources/tensor.png resources/qball.png resources/StreamlineTracking.png resources/dwi2.png resources/refresh.xpm ) set(QRC_FILES # uncomment the following line if you want to use Qt resources resources/QmitkDiffusionImaging.qrc #resources/QmitkTractbasedSpatialStatisticsView.qrc ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidget.cpp new file mode 100644 index 0000000000..7eb05e2ad6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidget.cpp @@ -0,0 +1,42 @@ +/*=================================================================== + +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. + +===================================================================*/ + +//Qmitk headers +#include "QmitkAstrosticksModelParametersWidget.h" +#include + +const std::string QmitkAstrosticksModelParametersWidget::VIEW_ID = "org.mitk.views.AstrosticksModelParametersWidget"; + +QmitkAstrosticksModelParametersWidget::QmitkAstrosticksModelParametersWidget( QWidget * parent, Qt::WindowFlags f ) + : QWidget(parent) +{ + m_Controls = NULL; + this->CreateQtPartControl(this); +} + +QmitkAstrosticksModelParametersWidget::~QmitkAstrosticksModelParametersWidget() +{ +} + +void QmitkAstrosticksModelParametersWidget::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkAstrosticksModelParametersWidgetControls; + m_Controls->setupUi(parent); + } +} diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidget.h new file mode 100644 index 0000000000..c3190454ff --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidget.h @@ -0,0 +1,58 @@ +/*=================================================================== + +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 _QMITKAstrosticksModelParametersWidget_H_INCLUDED +#define _QMITKAstrosticksModelParametersWidget_H_INCLUDED + +//QT headers +#include +#include +#include "ui_QmitkAstrosticksModelParametersWidgetControls.h" +#include + +class QmitkStdMultiWidget; + +/** @brief + */ +class DIFFUSIONIMAGING_EXPORT QmitkAstrosticksModelParametersWidget : public QWidget +{ + //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; + + QmitkAstrosticksModelParametersWidget (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkAstrosticksModelParametersWidget(); + + virtual void CreateQtPartControl(QWidget *parent); + + double GetD(){ return m_Controls->m_D1box->value(); } + unsigned int GetT2(){ return m_Controls->m_T2box->value(); } + bool GetRandomizeSticks(){ return m_Controls->m_RandomCheck->isChecked(); } + +public slots: + +protected: + // member variables + Ui::QmitkAstrosticksModelParametersWidgetControls* m_Controls; + +private: + +}; + +#endif // _QMITKAstrosticksModelParametersWidget_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidgetControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidgetControls.ui new file mode 100644 index 0000000000..da5dcae8c8 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkAstrosticksModelParametersWidgetControls.ui @@ -0,0 +1,106 @@ + + + QmitkAstrosticksModelParametersWidgetControls + + + + 0 + 0 + 410 + 106 + + + + + 0 + 0 + + + + Form + + + + 0 + + + + + Use random number and orientation of sticks. + + + Randomize Sticks + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + + + <html><head/><body><p>T2 - Relaxation:</p></body></html> + + + + + + + T2 relaxation time of this compartment (in milliseconds). + + + 10000 + + + 100 + + + + + + + <html><head/><body><p>d:</p></body></html> + + + + + + + Diffusivity along sticks. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.001000000000000 + + + + + + + + + + m_T2box + m_D1box + m_RandomCheck + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidget.cpp new file mode 100644 index 0000000000..0fa9b4a09e --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidget.cpp @@ -0,0 +1,42 @@ +/*=================================================================== + +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. + +===================================================================*/ + +//Qmitk headers +#include "QmitkBallModelParametersWidget.h" +#include + +const std::string QmitkBallModelParametersWidget::VIEW_ID = "org.mitk.views.BallModelParametersWidget"; + +QmitkBallModelParametersWidget::QmitkBallModelParametersWidget( QWidget * parent, Qt::WindowFlags f ) + : QWidget(parent) +{ + m_Controls = NULL; + this->CreateQtPartControl(this); +} + +QmitkBallModelParametersWidget::~QmitkBallModelParametersWidget() +{ +} + +void QmitkBallModelParametersWidget::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkBallModelParametersWidgetControls; + m_Controls->setupUi(parent); + } +} diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidget.h new file mode 100644 index 0000000000..a7bdbfcd20 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidget.h @@ -0,0 +1,57 @@ +/*=================================================================== + +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 _QMITKBallModelParametersWidget_H_INCLUDED +#define _QMITKBallModelParametersWidget_H_INCLUDED + +//QT headers +#include +#include +#include "ui_QmitkBallModelParametersWidgetControls.h" +#include + +class QmitkStdMultiWidget; + +/** @brief + */ +class DIFFUSIONIMAGING_EXPORT QmitkBallModelParametersWidget : public QWidget +{ + //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; + + QmitkBallModelParametersWidget (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkBallModelParametersWidget(); + + virtual void CreateQtPartControl(QWidget *parent); + + double GetD(){ return m_Controls->m_D1box->value(); } + unsigned int GetT2(){ return m_Controls->m_T2box->value(); } + +public slots: + +protected: + // member variables + Ui::QmitkBallModelParametersWidgetControls* m_Controls; + +private: + +}; + +#endif // _QMITKBallModelParametersWidget_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidgetControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidgetControls.ui new file mode 100644 index 0000000000..401fc293ea --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkBallModelParametersWidgetControls.ui @@ -0,0 +1,80 @@ + + + QmitkBallModelParametersWidgetControls + + + + 0 + 0 + 410 + 78 + + + + + 0 + 0 + + + + Form + + + + 0 + + + + + <html><head/><body><p>d:</p></body></html> + + + + + + + <html><head/><body><p>T2 - Relaxation:</p></body></html> + + + + + + + T2 relaxation time of this compartment (in milliseconds). + + + 10000 + + + 100 + + + + + + + Diffusivity along stick. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.001000000000000 + + + + + + + m_T2box + m_D1box + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidget.cpp new file mode 100644 index 0000000000..76a1cfd69b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidget.cpp @@ -0,0 +1,42 @@ +/*=================================================================== + +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. + +===================================================================*/ + +//Qmitk headers +#include "QmitkDotModelParametersWidget.h" +#include + +const std::string QmitkDotModelParametersWidget::VIEW_ID = "org.mitk.views.DotModelParametersWidget"; + +QmitkDotModelParametersWidget::QmitkDotModelParametersWidget( QWidget * parent, Qt::WindowFlags f ) + : QWidget(parent) +{ + m_Controls = NULL; + this->CreateQtPartControl(this); +} + +QmitkDotModelParametersWidget::~QmitkDotModelParametersWidget() +{ +} + +void QmitkDotModelParametersWidget::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkDotModelParametersWidgetControls; + m_Controls->setupUi(parent); + } +} diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidget.h new file mode 100644 index 0000000000..af3d1a098b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidget.h @@ -0,0 +1,56 @@ +/*=================================================================== + +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 _QMITKDotModelParametersWidget_H_INCLUDED +#define _QMITKDotModelParametersWidget_H_INCLUDED + +//QT headers +#include +#include +#include "ui_QmitkDotModelParametersWidgetControls.h" +#include + +class QmitkStdMultiWidget; + +/** @brief + */ +class DIFFUSIONIMAGING_EXPORT QmitkDotModelParametersWidget : public QWidget +{ + //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; + + QmitkDotModelParametersWidget (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkDotModelParametersWidget(); + + virtual void CreateQtPartControl(QWidget *parent); + + unsigned int GetT2(){ return m_Controls->m_T2box->value(); } + +public slots: + +protected: + // member variables + Ui::QmitkDotModelParametersWidgetControls* m_Controls; + +private: + +}; + +#endif // _QMITKDotModelParametersWidget_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidgetControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidgetControls.ui new file mode 100644 index 0000000000..ac2efa7b57 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkDotModelParametersWidgetControls.ui @@ -0,0 +1,50 @@ + + + QmitkDotModelParametersWidgetControls + + + + 0 + 0 + 410 + 45 + + + + + 0 + 0 + + + + Form + + + + 0 + + + + + <html><head/><body><p>T2 - Relaxation:</p></body></html> + + + + + + + T2 relaxation time of this compartment (in milliseconds). + + + 10000 + + + 100 + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidget.cpp new file mode 100644 index 0000000000..852bf79f5a --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidget.cpp @@ -0,0 +1,42 @@ +/*=================================================================== + +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. + +===================================================================*/ + +//Qmitk headers +#include "QmitkStickModelParametersWidget.h" +#include + +const std::string QmitkStickModelParametersWidget::VIEW_ID = "org.mitk.views.StickModelParametersWidget"; + +QmitkStickModelParametersWidget::QmitkStickModelParametersWidget( QWidget * parent, Qt::WindowFlags f ) + : QWidget(parent) +{ + m_Controls = NULL; + this->CreateQtPartControl(this); +} + +QmitkStickModelParametersWidget::~QmitkStickModelParametersWidget() +{ +} + +void QmitkStickModelParametersWidget::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkStickModelParametersWidgetControls; + m_Controls->setupUi(parent); + } +} diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidget.h new file mode 100644 index 0000000000..ead2f66299 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidget.h @@ -0,0 +1,57 @@ +/*=================================================================== + +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 _QMITKStickModelParametersWidget_H_INCLUDED +#define _QMITKStickModelParametersWidget_H_INCLUDED + +//QT headers +#include +#include +#include "ui_QmitkStickModelParametersWidgetControls.h" +#include + +class QmitkStdMultiWidget; + +/** @brief + */ +class DIFFUSIONIMAGING_EXPORT QmitkStickModelParametersWidget : public QWidget +{ + //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; + + QmitkStickModelParametersWidget (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkStickModelParametersWidget(); + + virtual void CreateQtPartControl(QWidget *parent); + + double GetD(){ return m_Controls->m_D1box->value(); } + unsigned int GetT2(){ return m_Controls->m_T2box->value(); } + +public slots: + +protected: + // member variables + Ui::QmitkStickModelParametersWidgetControls* m_Controls; + +private: + +}; + +#endif // _QMITKStickModelParametersWidget_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidgetControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidgetControls.ui new file mode 100644 index 0000000000..1e2d423943 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkStickModelParametersWidgetControls.ui @@ -0,0 +1,80 @@ + + + QmitkStickModelParametersWidgetControls + + + + 0 + 0 + 410 + 78 + + + + + 0 + 0 + + + + Form + + + + 0 + + + + + <html><head/><body><p>d:</p></body></html> + + + + + + + <html><head/><body><p>T2 - Relaxation:</p></body></html> + + + + + + + T2 relaxation time of this compartment (in milliseconds). + + + 10000 + + + 200 + + + + + + + Diffusivity along stick. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.001000000000000 + + + + + + + m_T2box + m_D1box + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidget.cpp new file mode 100644 index 0000000000..01eaed16b6 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidget.cpp @@ -0,0 +1,63 @@ +/*=================================================================== + +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. + +===================================================================*/ + +//Qmitk headers +#include "QmitkTensorModelParametersWidget.h" +#include + +const std::string QmitkTensorModelParametersWidget::VIEW_ID = "org.mitk.views.tensormodelparameterswidget"; + +QmitkTensorModelParametersWidget::QmitkTensorModelParametersWidget( QWidget * parent, Qt::WindowFlags f ) + : QWidget(parent) +{ + m_Controls = NULL; + this->CreateQtPartControl(this); +} + +QmitkTensorModelParametersWidget::~QmitkTensorModelParametersWidget() +{ +} + +void QmitkTensorModelParametersWidget::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkTensorModelParametersWidgetControls; + m_Controls->setupUi(parent); + + connect((QObject*) m_Controls->m_D1box, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(DChanged(double))); + connect((QObject*) m_Controls->m_D2box, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(DChanged(double))); + connect((QObject*) m_Controls->m_D3box, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(DChanged(double))); + + UpdateUi(); + } +} + +void QmitkTensorModelParametersWidget::UpdateUi() +{ + itk::DiffusionTensor3D tensor; + tensor.Fill(0); + tensor.SetElement(0,m_Controls->m_D1box->value()); + tensor.SetElement(3,m_Controls->m_D2box->value()); + tensor.SetElement(5,m_Controls->m_D3box->value()); + m_Controls->m_FaLabel->setText(QString::number(tensor.GetFractionalAnisotropy())); +} + +void QmitkTensorModelParametersWidget::DChanged( double value ) +{ + UpdateUi(); +} diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidget.h new file mode 100644 index 0000000000..f09273c18c --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidget.h @@ -0,0 +1,62 @@ +/*=================================================================== + +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 _QMITKTensorModelParametersWidget_H_INCLUDED +#define _QMITKTensorModelParametersWidget_H_INCLUDED + +//QT headers +#include +#include +#include "ui_QmitkTensorModelParametersWidgetControls.h" +#include + +class QmitkStdMultiWidget; + +/** @brief + */ +class DIFFUSIONIMAGING_EXPORT QmitkTensorModelParametersWidget : public QWidget +{ + //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; + + QmitkTensorModelParametersWidget (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkTensorModelParametersWidget(); + + virtual void CreateQtPartControl(QWidget *parent); + + double GetD1(){ return m_Controls->m_D1box->value(); } + double GetD2(){ return m_Controls->m_D2box->value(); } + double GetD3(){ return m_Controls->m_D3box->value(); } + unsigned int GetT2(){ return m_Controls->m_T2box->value(); } + +public slots: + + void DChanged( double value ); + +protected: + // member variables + Ui::QmitkTensorModelParametersWidgetControls* m_Controls; + void UpdateUi(); + +private: + +}; + +#endif // _QMITKTensorModelParametersWidget_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidgetControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidgetControls.ui new file mode 100644 index 0000000000..339b92b810 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkTensorModelParametersWidgetControls.ui @@ -0,0 +1,151 @@ + + + QmitkTensorModelParametersWidgetControls + + + + 0 + 0 + 410 + 167 + + + + + 0 + 0 + + + + Form + + + + 0 + + + + + <html><head/><body><p>FA:</p></body></html> + + + + + + + <html><head/><body><p>d<span style=" vertical-align:sub;">⟂1</span>:</p></body></html> + + + + + + + Diffusivity along second eigenvector. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.000250000000000 + + + + + + + <html><head/><body><p>d<span style=" vertical-align:sub;">||</span>:</p></body></html> + + + + + + + Diffusivity along largest eigenvector. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.001000000000000 + + + + + + + Diffusivity along third eigenvector. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.000250000000000 + + + + + + + <html><head/><body><p>d<span style=" vertical-align:sub;">⟂2</span>:</p></body></html> + + + + + + + Fractional anisotropy of resulting tensor. + + + <html><head/><body><p>-</p></body></html> + + + + + + + <html><head/><body><p>T2 - Relaxation:</p></body></html> + + + + + + + T2 relaxation time of this compartment (in milliseconds). + + + 10000 + + + 100 + + + + + + + m_T2box + m_D1box + m_D2box + m_D3box + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidget.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidget.cpp new file mode 100644 index 0000000000..e40f787825 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidget.cpp @@ -0,0 +1,62 @@ +/*=================================================================== + +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. + +===================================================================*/ + +//Qmitk headers +#include "QmitkZeppelinModelParametersWidget.h" +#include + +const std::string QmitkZeppelinModelParametersWidget::VIEW_ID = "org.mitk.views.ZeppelinModelParameterswidget"; + +QmitkZeppelinModelParametersWidget::QmitkZeppelinModelParametersWidget( QWidget * parent, Qt::WindowFlags f ) + : QWidget(parent) +{ + m_Controls = NULL; + this->CreateQtPartControl(this); +} + +QmitkZeppelinModelParametersWidget::~QmitkZeppelinModelParametersWidget() +{ +} + +void QmitkZeppelinModelParametersWidget::CreateQtPartControl(QWidget *parent) +{ + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkZeppelinModelParametersWidgetControls; + m_Controls->setupUi(parent); + + connect((QObject*) m_Controls->m_D1box, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(DChanged(double))); + connect((QObject*) m_Controls->m_D2box, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(DChanged(double))); + + UpdateUi(); + } +} + +void QmitkZeppelinModelParametersWidget::UpdateUi() +{ + itk::DiffusionTensor3D tensor; + tensor.Fill(0); + tensor.SetElement(0,m_Controls->m_D1box->value()); + tensor.SetElement(3,m_Controls->m_D2box->value()); + tensor.SetElement(5,m_Controls->m_D2box->value()); + m_Controls->m_FaLabel->setText(QString::number(tensor.GetFractionalAnisotropy())); +} + +void QmitkZeppelinModelParametersWidget::DChanged( double value ) +{ + UpdateUi(); +} diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidget.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidget.h new file mode 100644 index 0000000000..583cf21c80 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidget.h @@ -0,0 +1,61 @@ +/*=================================================================== + +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 _QMITKZeppelinModelParametersWidget_H_INCLUDED +#define _QMITKZeppelinModelParametersWidget_H_INCLUDED + +//QT headers +#include +#include +#include "ui_QmitkZeppelinModelParametersWidgetControls.h" +#include + +class QmitkStdMultiWidget; + +/** @brief + */ +class DIFFUSIONIMAGING_EXPORT QmitkZeppelinModelParametersWidget : public QWidget +{ + //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; + + QmitkZeppelinModelParametersWidget (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~QmitkZeppelinModelParametersWidget(); + + virtual void CreateQtPartControl(QWidget *parent); + + double GetD1(){ return m_Controls->m_D1box->value(); } + double GetD2(){ return m_Controls->m_D2box->value(); } + unsigned int GetT2(){ return m_Controls->m_T2box->value(); } + +public slots: + + void DChanged( double value ); + +protected: + // member variables + Ui::QmitkZeppelinModelParametersWidgetControls* m_Controls; + void UpdateUi(); + +private: + +}; + +#endif // _QMITKZeppelinModelParametersWidget_H_INCLUDED + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidgetControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidgetControls.ui new file mode 100644 index 0000000000..68e19318b7 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/QmitkZeppelinModelParametersWidgetControls.ui @@ -0,0 +1,124 @@ + + + QmitkZeppelinModelParametersWidgetControls + + + + 0 + 0 + 410 + 167 + + + + + 0 + 0 + + + + Form + + + + 0 + + + + + Fractional anisotropy of resulting tensor. + + + <html><head/><body><p>-</p></body></html> + + + + + + + Diffusivity along second and third eigenvector. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.000250000000000 + + + + + + + T2 relaxation time of this compartment (in milliseconds). + + + 10000 + + + 100 + + + + + + + Diffusivity along largest eigenvector. + + + 5 + + + 1.000000000000000 + + + 0.000100000000000 + + + 0.001000000000000 + + + + + + + <html><head/><body><p>d<span style=" vertical-align:sub;">⟂</span>:</p></body></html> + + + + + + + <html><head/><body><p>d<span style=" vertical-align:sub;">||</span>:</p></body></html> + + + + + + + <html><head/><body><p>T2 - Relaxation:</p></body></html> + + + + + + + <html><head/><body><p>FA:</p></body></html> + + + + + + + m_T2box + m_D1box + m_D2box + + + + diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.cpp index 05d414b4d1..d1b25735d7 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.cpp @@ -1,1437 +1,1514 @@ /*=================================================================== 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. ===================================================================*/ //misc #define _USE_MATH_DEFINES #include // Blueberry #include #include // Qmitk #include "QmitkFiberfoxView.h" // MITK #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define _USE_MATH_DEFINES #include const std::string QmitkFiberfoxView::VIEW_ID = "org.mitk.views.fiberfoxview"; QmitkFiberfoxView::QmitkFiberfoxView() : QmitkAbstractView() , m_Controls( 0 ) , m_SelectedImage( NULL ) , m_SelectedBundle( NULL ) { } // Destructor QmitkFiberfoxView::~QmitkFiberfoxView() { } void QmitkFiberfoxView::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::QmitkFiberfoxViewControls; m_Controls->setupUi( parent ); - m_Controls->m_VarianceBox->setVisible(false); - m_Controls->m_GeometryMessage->setVisible(false); + m_Controls->m_StickWidget1->setVisible(true); + m_Controls->m_StickWidget2->setVisible(false); + m_Controls->m_ZeppelinWidget1->setVisible(false); + m_Controls->m_ZeppelinWidget2->setVisible(false); + m_Controls->m_TensorWidget1->setVisible(false); + m_Controls->m_TensorWidget2->setVisible(false); + + m_Controls->m_BallWidget1->setVisible(true); + m_Controls->m_BallWidget2->setVisible(false); + m_Controls->m_AstrosticksWidget1->setVisible(false); + m_Controls->m_AstrosticksWidget2->setVisible(false); + m_Controls->m_DotWidget1->setVisible(false); + m_Controls->m_DotWidget2->setVisible(false); + + m_Controls->m_Comp4FractionFrame->setVisible(false); m_Controls->m_DiffusionPropsMessage->setVisible(false); - m_Controls->m_T2bluringParamFrame->setVisible(false); - m_Controls->m_KspaceParamFrame->setVisible(false); - m_Controls->m_DiffusivityModelFrameComp1->setVisible(false); - m_Controls->m_AdvancedFiberOptionsFrame->setVisible(false); + m_Controls->m_GeometryMessage->setVisible(false); m_Controls->m_AdvancedSignalOptionsFrame->setVisible(false); - m_Controls->m_DiffusivityModelFrameComp3->setVisible(false); - m_Controls->m_GeneralFrameComp3->setVisible(false); - m_Controls->m_RandomizeAstroComp2->setVisible(false); - m_Controls->m_RandomizeAstroComp3->setVisible(false); - connect((QObject*) m_Controls->m_GenerateImageButton, SIGNAL(clicked()), (QObject*) this, SLOT(GenerateImage())); connect((QObject*) m_Controls->m_GenerateFibersButton, SIGNAL(clicked()), (QObject*) this, SLOT(GenerateFibers())); connect((QObject*) m_Controls->m_CircleButton, SIGNAL(clicked()), (QObject*) this, SLOT(OnDrawROI())); connect((QObject*) m_Controls->m_FlipButton, SIGNAL(clicked()), (QObject*) this, SLOT(OnFlipButton())); connect((QObject*) m_Controls->m_JoinBundlesButton, SIGNAL(clicked()), (QObject*) this, SLOT(JoinBundles())); connect((QObject*) m_Controls->m_VarianceBox, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(OnVarianceChanged(double))); connect((QObject*) m_Controls->m_DistributionBox, SIGNAL(currentIndexChanged(int)), (QObject*) this, SLOT(OnDistributionChanged(int))); connect((QObject*) m_Controls->m_FiberDensityBox, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(OnFiberDensityChanged(int))); connect((QObject*) m_Controls->m_FiberSamplingBox, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(OnFiberSamplingChanged(int))); connect((QObject*) m_Controls->m_TensionBox, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(OnTensionChanged(double))); connect((QObject*) m_Controls->m_ContinuityBox, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(OnContinuityChanged(double))); connect((QObject*) m_Controls->m_BiasBox, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(OnBiasChanged(double))); connect((QObject*) m_Controls->m_AddGibbsRinging, SIGNAL(stateChanged(int)), (QObject*) this, SLOT(OnAddGibbsRinging(int))); connect((QObject*) m_Controls->m_ConstantRadiusBox, SIGNAL(stateChanged(int)), (QObject*) this, SLOT(OnConstantRadius(int))); connect((QObject*) m_Controls->m_CopyBundlesButton, SIGNAL(clicked()), (QObject*) this, SLOT(CopyBundles())); connect((QObject*) m_Controls->m_TransformBundlesButton, SIGNAL(clicked()), (QObject*) this, SLOT(ApplyTransform())); connect((QObject*) m_Controls->m_AlignOnGrid, SIGNAL(clicked()), (QObject*) this, SLOT(AlignOnGrid())); connect((QObject*) m_Controls->m_Compartment1Box, SIGNAL(currentIndexChanged(int)), (QObject*) this, SLOT(Comp1ModelFrameVisibility(int))); connect((QObject*) m_Controls->m_Compartment2Box, SIGNAL(currentIndexChanged(int)), (QObject*) this, SLOT(Comp2ModelFrameVisibility(int))); connect((QObject*) m_Controls->m_Compartment3Box, SIGNAL(currentIndexChanged(int)), (QObject*) this, SLOT(Comp3ModelFrameVisibility(int))); + connect((QObject*) m_Controls->m_Compartment4Box, SIGNAL(currentIndexChanged(int)), (QObject*) this, SLOT(Comp4ModelFrameVisibility(int))); connect((QObject*) m_Controls->m_AdvancedOptionsBox, SIGNAL( stateChanged(int)), (QObject*) this, SLOT(ShowAdvancedOptions(int))); connect((QObject*) m_Controls->m_AdvancedOptionsBox_2, SIGNAL( stateChanged(int)), (QObject*) this, SLOT(ShowAdvancedOptions(int))); } } void QmitkFiberfoxView::ShowAdvancedOptions(int state) { if (state) { m_Controls->m_AdvancedFiberOptionsFrame->setVisible(true); m_Controls->m_AdvancedSignalOptionsFrame->setVisible(true); + m_Controls->m_AdvancedOptionsBox->setChecked(true); + m_Controls->m_AdvancedOptionsBox_2->setChecked(true); } else { m_Controls->m_AdvancedFiberOptionsFrame->setVisible(false); m_Controls->m_AdvancedSignalOptionsFrame->setVisible(false); + m_Controls->m_AdvancedOptionsBox->setChecked(false); + m_Controls->m_AdvancedOptionsBox_2->setChecked(false); } } void QmitkFiberfoxView::Comp1ModelFrameVisibility(int index) { - m_Controls->m_TensorModelFrame->setVisible(false); - m_Controls->m_DiffusivityModelFrameComp1->setVisible(false); + m_Controls->m_StickWidget1->setVisible(false); + m_Controls->m_ZeppelinWidget1->setVisible(false); + m_Controls->m_TensorWidget1->setVisible(false); + switch (index) { case 0: - m_Controls->m_TensorModelFrame->setVisible(true); + m_Controls->m_StickWidget1->setVisible(true); break; case 1: - m_Controls->m_DiffusivityModelFrameComp1->setVisible(true); + m_Controls->m_ZeppelinWidget1->setVisible(true); + break; + case 2: + m_Controls->m_TensorWidget1->setVisible(true); break; } } void QmitkFiberfoxView::Comp2ModelFrameVisibility(int index) { - m_Controls->m_DiffusivityModelFrameComp2->setVisible(false); - m_Controls->m_RandomizeAstroComp3->setVisible(false); + m_Controls->m_StickWidget2->setVisible(false); + m_Controls->m_ZeppelinWidget2->setVisible(false); + m_Controls->m_TensorWidget2->setVisible(false); + switch (index) { case 0: - m_Controls->m_DiffusivityModelFrameComp2->setVisible(true); break; case 1: - m_Controls->m_DiffusivityModelFrameComp2->setVisible(true); - m_Controls->m_DiffusivityModelFrameComp3->setVisible(true); + m_Controls->m_StickWidget2->setVisible(true); break; case 2: + m_Controls->m_ZeppelinWidget2->setVisible(true); + break; + case 3: + m_Controls->m_TensorWidget2->setVisible(true); break; } } void QmitkFiberfoxView::Comp3ModelFrameVisibility(int index) { - m_Controls->m_DiffusivityModelFrameComp3->setVisible(false); - m_Controls->m_GeneralFrameComp3->setVisible(false); - m_Controls->m_RandomizeAstroComp3->setVisible(false); + m_Controls->m_BallWidget1->setVisible(false); + m_Controls->m_AstrosticksWidget1->setVisible(false); + m_Controls->m_DotWidget1->setVisible(false); + switch (index) { case 0: + m_Controls->m_BallWidget1->setVisible(true); break; case 1: - m_Controls->m_DiffusivityModelFrameComp3->setVisible(true); - m_Controls->m_GeneralFrameComp3->setVisible(true); + m_Controls->m_AstrosticksWidget1->setVisible(true); break; case 2: - m_Controls->m_RandomizeAstroComp3->setVisible(true); - m_Controls->m_DiffusivityModelFrameComp3->setVisible(true); - m_Controls->m_GeneralFrameComp3->setVisible(true); + m_Controls->m_DotWidget1->setVisible(true); + break; + } +} + +void QmitkFiberfoxView::Comp4ModelFrameVisibility(int index) +{ + m_Controls->m_BallWidget2->setVisible(false); + m_Controls->m_AstrosticksWidget2->setVisible(false); + m_Controls->m_DotWidget2->setVisible(false); + m_Controls->m_Comp4FractionFrame->setVisible(false); + + switch (index) + { + case 0: + break; + case 1: + m_Controls->m_BallWidget2->setVisible(true); + m_Controls->m_Comp4FractionFrame->setVisible(true); + break; + case 2: + m_Controls->m_AstrosticksWidget2->setVisible(true); + m_Controls->m_Comp4FractionFrame->setVisible(true); break; case 3: - m_Controls->m_GeneralFrameComp3->setVisible(true); + m_Controls->m_DotWidget2->setVisible(true); + m_Controls->m_Comp4FractionFrame->setVisible(true); break; } } void QmitkFiberfoxView::OnConstantRadius(int value) { if (value>0 && m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnAddGibbsRinging(int value) { if (value>0) m_Controls->m_KspaceParamFrame->setVisible(true); else m_Controls->m_KspaceParamFrame->setVisible(false); } void QmitkFiberfoxView::OnDistributionChanged(int value) { if (value==1) m_Controls->m_VarianceBox->setVisible(true); else m_Controls->m_VarianceBox->setVisible(false); if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnVarianceChanged(double value) { if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnFiberDensityChanged(int value) { if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnFiberSamplingChanged(int value) { if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnTensionChanged(double value) { if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnContinuityChanged(double value) { if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnBiasChanged(double value) { if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::AlignOnGrid() { for (int i=0; i(m_SelectedFiducials.at(i)->GetData()); mitk::Point3D wc0 = pe->GetWorldControlPoint(0); mitk::DataStorage::SetOfObjects::ConstPointer parentFibs = GetDataStorage()->GetSources(m_SelectedFiducials.at(i)); for( mitk::DataStorage::SetOfObjects::const_iterator it = parentFibs->begin(); it != parentFibs->end(); ++it ) { mitk::DataNode::Pointer pFibNode = *it; if ( pFibNode.IsNotNull() && dynamic_cast(pFibNode->GetData()) ) { mitk::DataStorage::SetOfObjects::ConstPointer parentImgs = GetDataStorage()->GetSources(pFibNode); for( mitk::DataStorage::SetOfObjects::const_iterator it2 = parentImgs->begin(); it2 != parentImgs->end(); ++it2 ) { mitk::DataNode::Pointer pImgNode = *it2; if ( pImgNode.IsNotNull() && dynamic_cast(pImgNode->GetData()) ) { mitk::Image::Pointer img = dynamic_cast(pImgNode->GetData()); mitk::Geometry3D::Pointer geom = img->GetGeometry(); itk::Index<3> idx; geom->WorldToIndex(wc0, idx); mitk::Point3D cIdx; cIdx[0]=idx[0]; cIdx[1]=idx[1]; cIdx[2]=idx[2]; mitk::Point3D world; geom->IndexToWorld(cIdx,world); mitk::Vector3D trans = world - wc0; pe->GetGeometry()->Translate(trans); break; } } break; } } } for( int i=0; iGetSources(fibNode); for( mitk::DataStorage::SetOfObjects::const_iterator it = sources->begin(); it != sources->end(); ++it ) { mitk::DataNode::Pointer imgNode = *it; if ( imgNode.IsNotNull() && dynamic_cast(imgNode->GetData()) ) { mitk::DataStorage::SetOfObjects::ConstPointer derivations = GetDataStorage()->GetDerivations(fibNode); for( mitk::DataStorage::SetOfObjects::const_iterator it2 = derivations->begin(); it2 != derivations->end(); ++it2 ) { mitk::DataNode::Pointer fiducialNode = *it2; if ( fiducialNode.IsNotNull() && dynamic_cast(fiducialNode->GetData()) ) { mitk::PlanarEllipse::Pointer pe = dynamic_cast(fiducialNode->GetData()); mitk::Point3D wc0 = pe->GetWorldControlPoint(0); mitk::Image::Pointer img = dynamic_cast(imgNode->GetData()); mitk::Geometry3D::Pointer geom = img->GetGeometry(); itk::Index<3> idx; geom->WorldToIndex(wc0, idx); mitk::Point3D cIdx; cIdx[0]=idx[0]; cIdx[1]=idx[1]; cIdx[2]=idx[2]; mitk::Point3D world; geom->IndexToWorld(cIdx,world); mitk::Vector3D trans = world - wc0; pe->GetGeometry()->Translate(trans); } } break; } } } for( int i=0; i(m_SelectedImages.at(i)->GetData()); mitk::DataStorage::SetOfObjects::ConstPointer derivations = GetDataStorage()->GetDerivations(m_SelectedImages.at(i)); for( mitk::DataStorage::SetOfObjects::const_iterator it = derivations->begin(); it != derivations->end(); ++it ) { mitk::DataNode::Pointer fibNode = *it; if ( fibNode.IsNotNull() && dynamic_cast(fibNode->GetData()) ) { mitk::DataStorage::SetOfObjects::ConstPointer derivations2 = GetDataStorage()->GetDerivations(fibNode); for( mitk::DataStorage::SetOfObjects::const_iterator it2 = derivations2->begin(); it2 != derivations2->end(); ++it2 ) { mitk::DataNode::Pointer fiducialNode = *it2; if ( fiducialNode.IsNotNull() && dynamic_cast(fiducialNode->GetData()) ) { mitk::PlanarEllipse::Pointer pe = dynamic_cast(fiducialNode->GetData()); mitk::Point3D wc0 = pe->GetWorldControlPoint(0); mitk::Geometry3D::Pointer geom = img->GetGeometry(); itk::Index<3> idx; geom->WorldToIndex(wc0, idx); mitk::Point3D cIdx; cIdx[0]=idx[0]; cIdx[1]=idx[1]; cIdx[2]=idx[2]; mitk::Point3D world; geom->IndexToWorld(cIdx,world); mitk::Vector3D trans = world - wc0; pe->GetGeometry()->Translate(trans); } } } } } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::OnFlipButton() { if (m_SelectedFiducial.IsNull()) return; std::map::iterator it = m_DataNodeToPlanarFigureData.find(m_SelectedFiducial.GetPointer()); if( it != m_DataNodeToPlanarFigureData.end() ) { QmitkPlanarFigureData& data = it->second; data.m_Flipped += 1; data.m_Flipped %= 2; } if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } QmitkFiberfoxView::GradientListType QmitkFiberfoxView::GenerateHalfShell(int NPoints) { NPoints *= 2; GradientListType pointshell; int numB0 = NPoints/10; if (numB0==0) numB0=1; GradientType g; g.Fill(0.0); for (int i=0; i theta; theta.set_size(NPoints); vnl_vector phi; phi.set_size(NPoints); double C = sqrt(4*M_PI); phi(0) = 0.0; phi(NPoints-1) = 0.0; for(int i=0; i0 && i std::vector > QmitkFiberfoxView::MakeGradientList() { std::vector > retval; vnl_matrix_fixed* U = itk::PointShell >::DistributePointShell(); // Add 0 vector for B0 int numB0 = ndirs/10; if (numB0==0) numB0=1; itk::Vector v; v.Fill(0.0); for (int i=0; i v; v[0] = U->get(0,i); v[1] = U->get(1,i); v[2] = U->get(2,i); retval.push_back(v); } return retval; } void QmitkFiberfoxView::OnAddBundle() { if (m_SelectedImage.IsNull()) return; mitk::DataStorage::SetOfObjects::ConstPointer children = GetDataStorage()->GetDerivations(m_SelectedImage); mitk::FiberBundleX::Pointer bundle = mitk::FiberBundleX::New(); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData( bundle ); QString name = QString("Bundle_%1").arg(children->size()); node->SetName(name.toStdString()); m_SelectedBundle = node; m_SelectedBundles.push_back(node); UpdateGui(); GetDataStorage()->Add(node, m_SelectedImage); } void QmitkFiberfoxView::OnDrawROI() { if (m_SelectedBundle.IsNull()) OnAddBundle(); if (m_SelectedBundle.IsNull()) return; mitk::DataStorage::SetOfObjects::ConstPointer children = GetDataStorage()->GetDerivations(m_SelectedBundle); mitk::PlanarEllipse::Pointer figure = mitk::PlanarEllipse::New(); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData( figure ); QList nodes = this->GetDataManagerSelection(); for( int i=0; iSetSelected(false); m_SelectedFiducial = node; QString name = QString("Fiducial_%1").arg(children->size()); node->SetName(name.toStdString()); node->SetSelected(true); GetDataStorage()->Add(node, m_SelectedBundle); this->DisableCrosshairNavigation(); mitk::PlanarFigureInteractor::Pointer figureInteractor = dynamic_cast(node->GetInteractor()); if(figureInteractor.IsNull()) figureInteractor = mitk::PlanarFigureInteractor::New("PlanarFigureInteractor", node); mitk::GlobalInteraction::GetInstance()->AddInteractor(figureInteractor); UpdateGui(); } bool CompareLayer(mitk::DataNode::Pointer i,mitk::DataNode::Pointer j) { int li = -1; i->GetPropertyValue("layer", li); int lj = -1; j->GetPropertyValue("layer", lj); return liGetSources(m_SelectedFiducial); for( mitk::DataStorage::SetOfObjects::const_iterator it = parents->begin(); it != parents->end(); ++it ) if(dynamic_cast((*it)->GetData())) m_SelectedBundles.push_back(*it); if (m_SelectedBundles.empty()) return; } vector< vector< mitk::PlanarEllipse::Pointer > > fiducials; vector< vector< unsigned int > > fliplist; for (int i=0; iGetDerivations(m_SelectedBundles.at(i)); std::vector< mitk::DataNode::Pointer > childVector; for( mitk::DataStorage::SetOfObjects::const_iterator it = children->begin(); it != children->end(); ++it ) childVector.push_back(*it); sort(childVector.begin(), childVector.end(), CompareLayer); vector< mitk::PlanarEllipse::Pointer > fib; vector< unsigned int > flip; float radius = 1; int count = 0; for( std::vector< mitk::DataNode::Pointer >::const_iterator it = childVector.begin(); it != childVector.end(); ++it ) { mitk::DataNode::Pointer node = *it; if ( node.IsNotNull() && dynamic_cast(node->GetData()) ) { mitk::PlanarEllipse* ellipse = dynamic_cast(node->GetData()); if (m_Controls->m_ConstantRadiusBox->isChecked()) { ellipse->SetTreatAsCircle(true); mitk::Point2D c = ellipse->GetControlPoint(0); mitk::Point2D p = ellipse->GetControlPoint(1); mitk::Vector2D v = p-c; if (count==0) { radius = v.GetVnlVector().magnitude(); ellipse->SetControlPoint(1, p); } else { v.Normalize(); v *= radius; ellipse->SetControlPoint(1, c+v); } } fib.push_back(ellipse); std::map::iterator it = m_DataNodeToPlanarFigureData.find(node.GetPointer()); if( it != m_DataNodeToPlanarFigureData.end() ) { QmitkPlanarFigureData& data = it->second; flip.push_back(data.m_Flipped); } else flip.push_back(0); } count++; } if (fib.size()>1) { fiducials.push_back(fib); fliplist.push_back(flip); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); if (fib.size()<3) return; } itk::FibersFromPlanarFiguresFilter::Pointer filter = itk::FibersFromPlanarFiguresFilter::New(); filter->SetFiducials(fiducials); filter->SetFlipList(fliplist); switch(m_Controls->m_DistributionBox->currentIndex()){ case 0: filter->SetFiberDistribution(itk::FibersFromPlanarFiguresFilter::DISTRIBUTE_UNIFORM); break; case 1: filter->SetFiberDistribution(itk::FibersFromPlanarFiguresFilter::DISTRIBUTE_GAUSSIAN); filter->SetVariance(m_Controls->m_VarianceBox->value()); break; } filter->SetDensity(m_Controls->m_FiberDensityBox->value()); filter->SetTension(m_Controls->m_TensionBox->value()); filter->SetContinuity(m_Controls->m_ContinuityBox->value()); filter->SetBias(m_Controls->m_BiasBox->value()); filter->SetFiberSampling(m_Controls->m_FiberSamplingBox->value()); filter->Update(); vector< mitk::FiberBundleX::Pointer > fiberBundles = filter->GetFiberBundles(); for (int i=0; iSetData( fiberBundles.at(i) ); if (fiberBundles.at(i)->GetNumFibers()>50000) m_SelectedBundles.at(i)->SetVisibility(false); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberfoxView::GenerateImage() { itk::ImageRegion<3> imageRegion; imageRegion.SetSize(0, m_Controls->m_SizeX->value()); imageRegion.SetSize(1, m_Controls->m_SizeY->value()); imageRegion.SetSize(2, m_Controls->m_SizeZ->value()); mitk::Vector3D spacing; spacing[0] = m_Controls->m_SpacingX->value(); spacing[1] = m_Controls->m_SpacingY->value(); spacing[2] = m_Controls->m_SpacingZ->value(); mitk::Point3D origin; origin[0] = spacing[0]/2; origin[1] = spacing[1]/2; origin[2] = spacing[2]/2; itk::Matrix directionMatrix; directionMatrix.SetIdentity(); if (m_SelectedBundle.IsNull()) { mitk::Image::Pointer image = mitk::ImageGenerator::GenerateGradientImage( m_Controls->m_SizeX->value(), m_Controls->m_SizeY->value(), m_Controls->m_SizeZ->value(), m_Controls->m_SpacingX->value(), m_Controls->m_SpacingY->value(), m_Controls->m_SpacingZ->value()); mitk::Geometry3D* geom = image->GetGeometry(); geom->SetOrigin(origin); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData( image ); node->SetName("Dummy"); GetDataStorage()->Add(node); m_SelectedImage = node; mitk::BaseData::Pointer basedata = node->GetData(); if (basedata.IsNotNull()) { mitk::RenderingManager::GetInstance()->InitializeViews( basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } UpdateGui(); return; } DiffusionSignalModel::GradientListType gradientList; double bVal = 1000; if (m_SelectedDWI.IsNull()) { gradientList = GenerateHalfShell(m_Controls->m_NumGradientsBox->value());; bVal = m_Controls->m_BvalueBox->value(); } else { mitk::DiffusionImage::Pointer dwi = dynamic_cast*>(m_SelectedDWI->GetData()); imageRegion = dwi->GetVectorImage()->GetLargestPossibleRegion(); spacing = dwi->GetVectorImage()->GetSpacing(); origin = dwi->GetVectorImage()->GetOrigin(); directionMatrix = dwi->GetVectorImage()->GetDirection(); bVal = dwi->GetB_Value(); mitk::DiffusionImage::GradientDirectionContainerType::Pointer dirs = dwi->GetDirections(); for (int i=0; iSize(); i++) { DiffusionSignalModel::GradientType g; g[0] = dirs->at(i)[0]; g[1] = dirs->at(i)[1]; g[2] = dirs->at(i)[2]; gradientList.push_back(g); } } for (int i=0; i ballModel; - mitk::AstroStickModel astrosticksModel; - mitk::DotModel dotModel; + double comp3Weight = 1; + double comp4Weight = 0; + if (m_Controls->m_Compartment4Box->currentIndex()>0) + { + comp4Weight = m_Controls->m_Comp4FractionBox->value(); + comp3Weight -= comp4Weight; + } + + mitk::StickModel stickModel1; + mitk::StickModel stickModel2; + mitk::TensorModel zeppelinModel1; + mitk::TensorModel zeppelinModel2; + mitk::TensorModel tensorModel1; + mitk::TensorModel tensorModel2; + mitk::BallModel ballModel1; mitk::BallModel ballModel2; + mitk::AstroStickModel astrosticksModel1; mitk::AstroStickModel astrosticksModel2; + mitk::DotModel dotModel1; mitk::DotModel dotModel2; - if (m_Controls->m_Compartment3Box->currentIndex()>0) + // compartment 1 + switch (m_Controls->m_Compartment1Box->currentIndex()) { - comp3Weight = m_Controls->m_Comp3Fraction->value(); - ballModel.SetWeight(1-comp3Weight); - astrosticksModel.SetWeight(1-comp3Weight); - dotModel.SetWeight(1-comp3Weight); - ballModel2.SetWeight(comp3Weight); - astrosticksModel2.SetWeight(comp3Weight); - dotModel2.SetWeight(comp3Weight); + case 0: + MITK_INFO << "Using stick model"; + stickModel1.SetGradientList(gradientList); + stickModel1.SetDiffusivity(m_Controls->m_StickWidget1->GetD()); + stickModel1.SetT2(m_Controls->m_StickWidget1->GetT2()); + fiberModelList.push_back(&stickModel1); + signalModelString += "Stick"; +// resultNode->AddProperty("Fiberfox.Stick.Diffusivity", DoubleProperty::New(m_Controls->m_StickWidget1->GetD())); +// resultNode->AddProperty("Fiberfox.Stick.T2", DoubleProperty::New(stickModel1.GetT2())); + break; + case 1: + MITK_INFO << "Using zeppelin model"; + zeppelinModel1.SetGradientList(gradientList); + zeppelinModel1.SetBvalue(bVal); + zeppelinModel1.SetDiffusivity1(m_Controls->m_ZeppelinWidget1->GetD1()); + zeppelinModel1.SetDiffusivity2(m_Controls->m_ZeppelinWidget1->GetD2()); + zeppelinModel1.SetDiffusivity3(m_Controls->m_ZeppelinWidget1->GetD2()); + zeppelinModel1.SetT2(m_Controls->m_ZeppelinWidget1->GetT2()); + fiberModelList.push_back(&zeppelinModel1); + signalModelString += "Zeppelin"; + break; + case 2: + MITK_INFO << "Using tensor model"; + tensorModel1.SetGradientList(gradientList); + tensorModel1.SetBvalue(bVal); + tensorModel1.SetDiffusivity1(m_Controls->m_TensorWidget1->GetD1()); + tensorModel1.SetDiffusivity2(m_Controls->m_TensorWidget1->GetD2()); + tensorModel1.SetDiffusivity3(m_Controls->m_TensorWidget1->GetD3()); + tensorModel1.SetT2(m_Controls->m_TensorWidget1->GetT2()); + fiberModelList.push_back(&tensorModel1); + signalModelString += "Tensor"; + break; } - QString signalModelString(""); - itk::TractsToDWIImageFilter::DiffusionModelList fiberModelList, nonFiberModelList; - mitk::TensorModel tensorModel; - mitk::StickModel stickModel; - - // free diffusion compartment + // compartment 2 switch (m_Controls->m_Compartment2Box->currentIndex()) { case 0: - MITK_INFO << "Using ball model"; - ballModel.SetGradientList(gradientList); - ballModel.SetBvalue(bVal); - ballModel.SetDiffusivity(m_Controls->m_DiffusivityBoxComp2->value()); - ballModel.SetT2(m_Controls->m_T2BoxComp2->value()); - nonFiberModelList.push_back(&ballModel); - signalModelString += "Ball"; - resultNode->AddProperty("Fiberfox.Ball.Diffusivity", DoubleProperty::New(m_Controls->m_DiffusivityBoxComp2->value())); - resultNode->AddProperty("Fiberfox.Ball.T2", DoubleProperty::New(m_Controls->m_T2BoxComp2->value())); break; case 1: - MITK_INFO << "Using astrosticks model"; - astrosticksModel.SetGradientList(gradientList); - astrosticksModel.SetBvalue(bVal); - astrosticksModel.SetDiffusivity(m_Controls->m_DiffusivityBoxComp2->value()); - astrosticksModel.SetT2(m_Controls->m_T2BoxComp2->value()); - astrosticksModel.SetRandomizeSticks(m_Controls->m_RandomizeAstroComp2->isChecked()); - nonFiberModelList.push_back(&astrosticksModel); - signalModelString += "Astrosticks"; - resultNode->AddProperty("Fiberfox.Astrosticks.Diffusivity", DoubleProperty::New(m_Controls->m_DiffusivityBoxComp2->value())); - resultNode->AddProperty("Fiberfox.Astrosticks.T2", DoubleProperty::New(m_Controls->m_T2BoxComp2->value())); + stickModel2.SetGradientList(gradientList); + stickModel2.SetDiffusivity(m_Controls->m_StickWidget2->GetD()); + stickModel2.SetT2(m_Controls->m_StickWidget2->GetT2()); + fiberModelList.push_back(&stickModel2); + signalModelString += "Stick"; break; case 2: - MITK_INFO << "Using dot model"; - dotModel.SetGradientList(gradientList); - dotModel.SetT2(m_Controls->m_T2BoxComp2->value()); - nonFiberModelList.push_back(&dotModel); - signalModelString += "Dot"; - resultNode->AddProperty("Fiberfox.Dot.T2", DoubleProperty::New(m_Controls->m_T2BoxComp2->value())); + zeppelinModel2.SetGradientList(gradientList); + zeppelinModel2.SetBvalue(bVal); + zeppelinModel2.SetDiffusivity1(m_Controls->m_ZeppelinWidget2->GetD1()); + zeppelinModel2.SetDiffusivity2(m_Controls->m_ZeppelinWidget2->GetD2()); + zeppelinModel2.SetDiffusivity3(m_Controls->m_ZeppelinWidget2->GetD2()); + zeppelinModel2.SetT2(m_Controls->m_ZeppelinWidget2->GetT2()); + fiberModelList.push_back(&zeppelinModel2); + signalModelString += "Zeppelin"; + break; + case 3: + tensorModel2.SetGradientList(gradientList); + tensorModel2.SetBvalue(bVal); + tensorModel2.SetDiffusivity1(m_Controls->m_TensorWidget2->GetD1()); + tensorModel2.SetDiffusivity2(m_Controls->m_TensorWidget2->GetD2()); + tensorModel2.SetDiffusivity3(m_Controls->m_TensorWidget2->GetD3()); + tensorModel2.SetT2(m_Controls->m_TensorWidget2->GetT2()); + fiberModelList.push_back(&tensorModel2); + signalModelString += "Tensor"; break; } - // intra-axonal diffusion - switch (m_Controls->m_Compartment1Box->currentIndex()) + // compartment 3 + switch (m_Controls->m_Compartment3Box->currentIndex()) { case 0: - MITK_INFO << "Using zeppelin model"; - tensorModel.SetGradientList(gradientList); - tensorModel.SetBvalue(bVal); - tensorModel.SetKernelFA(m_Controls->m_TensorFaBox->value()); - tensorModel.SetT2(m_Controls->m_T2BoxComp1->value()); - fiberModelList.push_back(&tensorModel); - signalModelString += "Zeppelin"; - resultNode->AddProperty("Fiberfox.Zeppelin.FA", DoubleProperty::New(m_Controls->m_TensorFaBox->value())); - resultNode->AddProperty("Fiberfox.Zeppelin.T2", DoubleProperty::New(m_Controls->m_T2BoxComp1->value())); + ballModel1.SetGradientList(gradientList); + ballModel1.SetBvalue(bVal); + ballModel1.SetDiffusivity(m_Controls->m_BallWidget1->GetD()); + ballModel1.SetT2(m_Controls->m_BallWidget1->GetT2()); + ballModel1.SetWeight(comp3Weight); + nonFiberModelList.push_back(&ballModel1); + signalModelString += "Ball"; break; case 1: - MITK_INFO << "Using stick model"; - stickModel.SetGradientList(gradientList); - stickModel.SetDiffusivity(m_Controls->m_DiffusivityBoxComp1->value()); - stickModel.SetT2(m_Controls->m_T2BoxComp1->value()); - fiberModelList.push_back(&stickModel); - signalModelString += "Stick"; - resultNode->AddProperty("Fiberfox.Stick.Diffusivity", DoubleProperty::New(m_Controls->m_DiffusivityBoxComp1->value())); - resultNode->AddProperty("Fiberfox.Stick.T2", DoubleProperty::New(m_Controls->m_T2BoxComp1->value())); + astrosticksModel1.SetGradientList(gradientList); + astrosticksModel1.SetBvalue(bVal); + astrosticksModel1.SetDiffusivity(m_Controls->m_AstrosticksWidget1->GetD()); + astrosticksModel1.SetT2(m_Controls->m_AstrosticksWidget1->GetT2()); + astrosticksModel1.SetRandomizeSticks(m_Controls->m_AstrosticksWidget1->GetRandomizeSticks()); + astrosticksModel1.SetWeight(comp3Weight); + nonFiberModelList.push_back(&astrosticksModel1); + signalModelString += "Astrosticks"; + break; + case 2: + dotModel1.SetGradientList(gradientList); + dotModel1.SetT2(m_Controls->m_DotWidget1->GetT2()); + dotModel1.SetWeight(comp3Weight); + nonFiberModelList.push_back(&dotModel1); + signalModelString += "Dot"; break; } - // third compartment - switch (m_Controls->m_Compartment3Box->currentIndex()) + // compartment 4 + switch (m_Controls->m_Compartment4Box->currentIndex()) { + case 0: + break; case 1: - MITK_INFO << "Using ball model"; ballModel2.SetGradientList(gradientList); ballModel2.SetBvalue(bVal); - ballModel2.SetDiffusivity(m_Controls->m_DiffusivityBoxComp2->value()); - ballModel2.SetT2(m_Controls->m_T2BoxComp2->value()); + ballModel2.SetDiffusivity(m_Controls->m_BallWidget2->GetD()); + ballModel2.SetT2(m_Controls->m_BallWidget2->GetT2()); + ballModel2.SetWeight(comp4Weight); nonFiberModelList.push_back(&ballModel2); signalModelString += "Ball"; - resultNode->AddProperty("Fiberfox.Ball.Diffusivity", DoubleProperty::New(m_Controls->m_DiffusivityBoxComp2->value())); - resultNode->AddProperty("Fiberfox.Ball.T2", DoubleProperty::New(m_Controls->m_T2BoxComp2->value())); break; case 2: - MITK_INFO << "Using astrosticks model"; astrosticksModel2.SetGradientList(gradientList); astrosticksModel2.SetBvalue(bVal); - astrosticksModel2.SetDiffusivity(m_Controls->m_DiffusivityBoxComp2->value()); - astrosticksModel2.SetT2(m_Controls->m_T2BoxComp2->value()); - astrosticksModel2.SetRandomizeSticks(m_Controls->m_RandomizeAstroComp3->isChecked()); + astrosticksModel2.SetDiffusivity(m_Controls->m_AstrosticksWidget2->GetD()); + astrosticksModel2.SetT2(m_Controls->m_AstrosticksWidget2->GetT2()); + astrosticksModel2.SetRandomizeSticks(m_Controls->m_AstrosticksWidget2->GetRandomizeSticks()); + astrosticksModel2.SetWeight(comp4Weight); nonFiberModelList.push_back(&astrosticksModel2); signalModelString += "Astrosticks"; - resultNode->AddProperty("Fiberfox.Astrosticks.Diffusivity", DoubleProperty::New(m_Controls->m_DiffusivityBoxComp2->value())); - resultNode->AddProperty("Fiberfox.Astrosticks.T2", DoubleProperty::New(m_Controls->m_T2BoxComp2->value())); break; case 3: - MITK_INFO << "Using dot model"; dotModel2.SetGradientList(gradientList); - dotModel2.SetT2(m_Controls->m_T2BoxComp2->value()); + dotModel2.SetT2(m_Controls->m_DotWidget2->GetT2()); + dotModel2.SetWeight(comp4Weight); nonFiberModelList.push_back(&dotModel2); signalModelString += "Dot"; - resultNode->AddProperty("Fiberfox.Dot.T2", DoubleProperty::New(m_Controls->m_T2BoxComp2->value())); break; } itk::TractsToDWIImageFilter::KspaceArtifactList artifactList; // noise model double noiseVariance = m_Controls->m_NoiseLevel->value(); mitk::RicianNoiseModel noiseModel; noiseModel.SetNoiseVariance(noiseVariance); // artifact models QString artifactModelString(""); mitk::GibbsRingingArtifact gibbsModel; if (m_Controls->m_AddGibbsRinging->isChecked()) { artifactModelString += "_Gibbs-ringing"; resultNode->AddProperty("Fiberfox.k-Space-Undersampling", IntProperty::New(m_Controls->m_KspaceUndersamplingBox->currentText().toInt())); gibbsModel.SetKspaceCropping((double)m_Controls->m_KspaceUndersamplingBox->currentText().toInt()); artifactList.push_back(&gibbsModel); } mitk::T2SmearingArtifact contrastModel; contrastModel.SetT2star(this->m_Controls->m_T2starBox->value()); contrastModel.SetTE(this->m_Controls->m_TEbox->value()); contrastModel.SetTline(m_Controls->m_LineReadoutTimeBox->value()); artifactList.push_back(&contrastModel); mitk::FiberBundleX::Pointer fiberBundle = dynamic_cast(m_SelectedBundles.at(i)->GetData()); if (fiberBundle->GetNumFibers()<=0) continue; itk::TractsToDWIImageFilter::Pointer filter = itk::TractsToDWIImageFilter::New(); filter->SetImageRegion(imageRegion); filter->SetSpacing(spacing); filter->SetOrigin(origin); filter->SetDirectionMatrix(directionMatrix); filter->SetFiberBundle(fiberBundle); filter->SetFiberModels(fiberModelList); filter->SetNonFiberModels(nonFiberModelList); filter->SetNoiseModel(&noiseModel); filter->SetKspaceArtifacts(artifactList); filter->SetNumberOfRepetitions(m_Controls->m_RepetitionsBox->value()); filter->SetEnforcePureFiberVoxels(m_Controls->m_EnforcePureFiberVoxelsBox->isChecked()); filter->SetInterpolationShrink(m_Controls->m_InterpolationShrink->value()); filter->SetFiberRadius(m_Controls->m_FiberRadius->value()); filter->SetSignalScale(m_Controls->m_SignalScaleBox->value()); if (m_TissueMask.IsNotNull()) { ItkUcharImgType::Pointer mask = ItkUcharImgType::New(); mitk::CastToItkImage(m_TissueMask, mask); filter->SetTissueMask(mask); } filter->Update(); mitk::DiffusionImage::Pointer image = mitk::DiffusionImage::New(); image->SetVectorImage( filter->GetOutput() ); image->SetB_Value(bVal); image->SetDirections(gradientList); image->InitializeFromVectorImage(); resultNode->SetData( image ); resultNode->SetName(m_SelectedBundles.at(i)->GetName() +"_D"+QString::number(imageRegion.GetSize(0)).toStdString() +"-"+QString::number(imageRegion.GetSize(1)).toStdString() +"-"+QString::number(imageRegion.GetSize(2)).toStdString() +"_S"+QString::number(spacing[0]).toStdString() +"-"+QString::number(spacing[1]).toStdString() +"-"+QString::number(spacing[2]).toStdString() +"_b"+QString::number(bVal).toStdString() +"_NOISE"+QString::number(noiseVariance).toStdString() +"_"+signalModelString.toStdString() +artifactModelString.toStdString()); GetDataStorage()->Add(resultNode, m_SelectedBundles.at(i)); resultNode->AddProperty("Fiberfox.Noise-Variance", DoubleProperty::New(noiseVariance)); resultNode->AddProperty("Fiberfox.Repetitions", IntProperty::New(m_Controls->m_RepetitionsBox->value())); resultNode->AddProperty("Fiberfox.b-value", DoubleProperty::New(bVal)); resultNode->AddProperty("Fiberfox.Model", StringProperty::New(signalModelString.toStdString())); if (m_Controls->m_KspaceImageBox->isChecked()) { itk::Image::Pointer kspace = filter->GetKspaceImage(); mitk::Image::Pointer image = mitk::Image::New(); image->InitializeByItk(kspace.GetPointer()); image->SetVolume(kspace->GetBufferPointer()); mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData( image ); node->SetName(m_SelectedBundles.at(i)->GetName()+"_k-space"); GetDataStorage()->Add(node, m_SelectedBundles.at(i)); } mitk::BaseData::Pointer basedata = resultNode->GetData(); if (basedata.IsNotNull()) { mitk::RenderingManager::GetInstance()->InitializeViews( basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } } } void QmitkFiberfoxView::ApplyTransform() { vector< mitk::DataNode::Pointer > selectedBundles; for( int i=0; iGetDerivations(m_SelectedImages.at(i)); for( mitk::DataStorage::SetOfObjects::const_iterator it = derivations->begin(); it != derivations->end(); ++it ) { mitk::DataNode::Pointer fibNode = *it; if ( fibNode.IsNotNull() && dynamic_cast(fibNode->GetData()) ) selectedBundles.push_back(fibNode); } } if (selectedBundles.empty()) selectedBundles = m_SelectedBundles2; if (!selectedBundles.empty()) { std::vector::const_iterator it = selectedBundles.begin(); for (it; it!=selectedBundles.end(); ++it) { mitk::FiberBundleX::Pointer fib = dynamic_cast((*it)->GetData()); fib->RotateAroundAxis(m_Controls->m_XrotBox->value(), m_Controls->m_YrotBox->value(), m_Controls->m_ZrotBox->value()); fib->TranslateFibers(m_Controls->m_XtransBox->value(), m_Controls->m_YtransBox->value(), m_Controls->m_ZtransBox->value()); fib->ScaleFibers(m_Controls->m_XscaleBox->value(), m_Controls->m_YscaleBox->value(), m_Controls->m_ZscaleBox->value()); // handle child fiducials if (m_Controls->m_IncludeFiducials->isChecked()) { mitk::DataStorage::SetOfObjects::ConstPointer derivations = GetDataStorage()->GetDerivations(*it); for( mitk::DataStorage::SetOfObjects::const_iterator it2 = derivations->begin(); it2 != derivations->end(); ++it2 ) { mitk::DataNode::Pointer fiducialNode = *it2; if ( fiducialNode.IsNotNull() && dynamic_cast(fiducialNode->GetData()) ) { mitk::PlanarEllipse* pe = dynamic_cast(fiducialNode->GetData()); mitk::Geometry3D* geom = pe->GetGeometry(); // translate mitk::Vector3D world; world[0] = m_Controls->m_XtransBox->value(); world[1] = m_Controls->m_YtransBox->value(); world[2] = m_Controls->m_ZtransBox->value(); geom->Translate(world); // calculate rotation matrix double x = m_Controls->m_XrotBox->value()*M_PI/180; double y = m_Controls->m_YrotBox->value()*M_PI/180; double z = m_Controls->m_ZrotBox->value()*M_PI/180; itk::Matrix< float, 3, 3 > rotX; rotX.SetIdentity(); rotX[1][1] = cos(x); rotX[2][2] = rotX[1][1]; rotX[1][2] = -sin(x); rotX[2][1] = -rotX[1][2]; itk::Matrix< float, 3, 3 > rotY; rotY.SetIdentity(); rotY[0][0] = cos(y); rotY[2][2] = rotY[0][0]; rotY[0][2] = sin(y); rotY[2][0] = -rotY[0][2]; itk::Matrix< float, 3, 3 > rotZ; rotZ.SetIdentity(); rotZ[0][0] = cos(z); rotZ[1][1] = rotZ[0][0]; rotZ[0][1] = -sin(z); rotZ[1][0] = -rotZ[0][1]; itk::Matrix< float, 3, 3 > rot = rotZ*rotY*rotX; // transform control point coordinate into geometry translation geom->SetOrigin(pe->GetWorldControlPoint(0)); mitk::Point2D cp; cp.Fill(0.0); pe->SetControlPoint(0, cp); // rotate fiducial geom->GetIndexToWorldTransform()->SetMatrix(rot*geom->GetIndexToWorldTransform()->GetMatrix()); // implicit translation mitk::Vector3D trans; trans[0] = geom->GetOrigin()[0]-fib->GetGeometry()->GetCenter()[0]; trans[1] = geom->GetOrigin()[1]-fib->GetGeometry()->GetCenter()[1]; trans[2] = geom->GetOrigin()[2]-fib->GetGeometry()->GetCenter()[2]; mitk::Vector3D newWc = rot*trans; newWc = newWc-trans; geom->Translate(newWc); } } } } } else { for (int i=0; i(m_SelectedFiducials.at(i)->GetData()); mitk::Geometry3D* geom = pe->GetGeometry(); // translate mitk::Vector3D world; world[0] = m_Controls->m_XtransBox->value(); world[1] = m_Controls->m_YtransBox->value(); world[2] = m_Controls->m_ZtransBox->value(); geom->Translate(world); // calculate rotation matrix double x = m_Controls->m_XrotBox->value()*M_PI/180; double y = m_Controls->m_YrotBox->value()*M_PI/180; double z = m_Controls->m_ZrotBox->value()*M_PI/180; itk::Matrix< float, 3, 3 > rotX; rotX.SetIdentity(); rotX[1][1] = cos(x); rotX[2][2] = rotX[1][1]; rotX[1][2] = -sin(x); rotX[2][1] = -rotX[1][2]; itk::Matrix< float, 3, 3 > rotY; rotY.SetIdentity(); rotY[0][0] = cos(y); rotY[2][2] = rotY[0][0]; rotY[0][2] = sin(y); rotY[2][0] = -rotY[0][2]; itk::Matrix< float, 3, 3 > rotZ; rotZ.SetIdentity(); rotZ[0][0] = cos(z); rotZ[1][1] = rotZ[0][0]; rotZ[0][1] = -sin(z); rotZ[1][0] = -rotZ[0][1]; itk::Matrix< float, 3, 3 > rot = rotZ*rotY*rotX; // transform control point coordinate into geometry translation geom->SetOrigin(pe->GetWorldControlPoint(0)); mitk::Point2D cp; cp.Fill(0.0); pe->SetControlPoint(0, cp); // rotate fiducial geom->GetIndexToWorldTransform()->SetMatrix(rot*geom->GetIndexToWorldTransform()->GetMatrix()); } if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberfoxView::CopyBundles() { if ( m_SelectedBundles.size()<1 ){ QMessageBox::information( NULL, "Warning", "Select at least one fiber bundle!"); MITK_WARN("QmitkFiberProcessingView") << "Select at least one fiber bundle!"; return; } std::vector::const_iterator it = m_SelectedBundles.begin(); for (it; it!=m_SelectedBundles.end(); ++it) { // find parent image mitk::DataNode::Pointer parentNode; mitk::DataStorage::SetOfObjects::ConstPointer parentImgs = GetDataStorage()->GetSources(*it); for( mitk::DataStorage::SetOfObjects::const_iterator it2 = parentImgs->begin(); it2 != parentImgs->end(); ++it2 ) { mitk::DataNode::Pointer pImgNode = *it2; if ( pImgNode.IsNotNull() && dynamic_cast(pImgNode->GetData()) ) { parentNode = pImgNode; break; } } mitk::FiberBundleX::Pointer fib = dynamic_cast((*it)->GetData()); mitk::FiberBundleX::Pointer newBundle = fib->GetDeepCopy(); QString name((*it)->GetName().c_str()); name += "_copy"; mitk::DataNode::Pointer fbNode = mitk::DataNode::New(); fbNode->SetData(newBundle); fbNode->SetName(name.toStdString()); fbNode->SetVisibility(true); if (parentNode.IsNotNull()) GetDataStorage()->Add(fbNode, parentNode); else GetDataStorage()->Add(fbNode); // copy child fiducials if (m_Controls->m_IncludeFiducials->isChecked()) { mitk::DataStorage::SetOfObjects::ConstPointer derivations = GetDataStorage()->GetDerivations(*it); for( mitk::DataStorage::SetOfObjects::const_iterator it2 = derivations->begin(); it2 != derivations->end(); ++it2 ) { mitk::DataNode::Pointer fiducialNode = *it2; if ( fiducialNode.IsNotNull() && dynamic_cast(fiducialNode->GetData()) ) { mitk::PlanarEllipse::Pointer pe = mitk::PlanarEllipse::New(); pe->DeepCopy(dynamic_cast(fiducialNode->GetData())); mitk::DataNode::Pointer newNode = mitk::DataNode::New(); newNode->SetData(pe); newNode->SetName(fiducialNode->GetName()); GetDataStorage()->Add(newNode, fbNode); } } } } mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberfoxView::JoinBundles() { if ( m_SelectedBundles.size()<2 ){ QMessageBox::information( NULL, "Warning", "Select at least two fiber bundles!"); MITK_WARN("QmitkFiberProcessingView") << "Select at least two fiber bundles!"; return; } std::vector::const_iterator it = m_SelectedBundles.begin(); mitk::FiberBundleX::Pointer newBundle = dynamic_cast((*it)->GetData()); QString name(""); name += QString((*it)->GetName().c_str()); ++it; for (it; it!=m_SelectedBundles.end(); ++it) { newBundle = newBundle->AddBundle(dynamic_cast((*it)->GetData())); name += "+"+QString((*it)->GetName().c_str()); } mitk::DataNode::Pointer fbNode = mitk::DataNode::New(); fbNode->SetData(newBundle); fbNode->SetName(name.toStdString()); fbNode->SetVisibility(true); GetDataStorage()->Add(fbNode); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkFiberfoxView::UpdateGui() { m_Controls->m_FiberBundleLabel->setText("mandatory"); m_Controls->m_GeometryFrame->setEnabled(true); m_Controls->m_GeometryMessage->setVisible(false); m_Controls->m_DiffusionPropsMessage->setVisible(false); m_Controls->m_FiberGenMessage->setVisible(true); m_Controls->m_TransformBundlesButton->setEnabled(false); m_Controls->m_CopyBundlesButton->setEnabled(false); m_Controls->m_GenerateFibersButton->setEnabled(false); m_Controls->m_FlipButton->setEnabled(false); m_Controls->m_CircleButton->setEnabled(false); m_Controls->m_BvalueBox->setEnabled(true); m_Controls->m_NumGradientsBox->setEnabled(true); m_Controls->m_JoinBundlesButton->setEnabled(false); m_Controls->m_AlignOnGrid->setEnabled(false); if (m_SelectedFiducial.IsNotNull()) { m_Controls->m_TransformBundlesButton->setEnabled(true); m_Controls->m_FlipButton->setEnabled(true); m_Controls->m_AlignOnGrid->setEnabled(true); } if (m_SelectedImage.IsNotNull() || m_SelectedBundle.IsNotNull()) { m_Controls->m_TransformBundlesButton->setEnabled(true); m_Controls->m_CircleButton->setEnabled(true); m_Controls->m_FiberGenMessage->setVisible(false); m_Controls->m_AlignOnGrid->setEnabled(true); } if (m_TissueMask.IsNotNull()) { m_Controls->m_GeometryMessage->setVisible(true); m_Controls->m_GeometryFrame->setEnabled(false); } if (m_SelectedDWI.IsNotNull()) { m_Controls->m_DiffusionPropsMessage->setVisible(true); m_Controls->m_BvalueBox->setEnabled(false); m_Controls->m_NumGradientsBox->setEnabled(false); m_Controls->m_GeometryMessage->setVisible(true); m_Controls->m_GeometryFrame->setEnabled(false); } if (m_SelectedBundle.IsNotNull()) { m_Controls->m_CopyBundlesButton->setEnabled(true); m_Controls->m_GenerateFibersButton->setEnabled(true); m_Controls->m_FiberBundleLabel->setText(m_SelectedBundle->GetName().c_str()); if (m_SelectedBundles.size()>1) m_Controls->m_JoinBundlesButton->setEnabled(true); } } void QmitkFiberfoxView::OnSelectionChanged( berry::IWorkbenchPart::Pointer, const QList& nodes ) { m_SelectedBundles2.clear(); m_SelectedImages.clear(); m_SelectedFiducials.clear(); m_SelectedFiducial = NULL; m_TissueMask = NULL; m_SelectedBundles.clear(); m_SelectedBundle = NULL; m_SelectedImage = NULL; m_SelectedDWI = NULL; m_Controls->m_TissueMaskLabel->setText("optional"); // iterate all selected objects, adjust warning visibility for( int i=0; i*>(node->GetData()) ) { m_SelectedDWI = node; m_SelectedImage = node; m_SelectedImages.push_back(node); } else if( node.IsNotNull() && dynamic_cast(node->GetData()) ) { m_SelectedImages.push_back(node); m_SelectedImage = node; bool isBinary = false; node->GetPropertyValue("binary", isBinary); if (isBinary) { m_TissueMask = dynamic_cast(node->GetData()); m_Controls->m_TissueMaskLabel->setText(node->GetName().c_str()); } } else if ( node.IsNotNull() && dynamic_cast(node->GetData()) ) { m_SelectedBundles2.push_back(node); if (m_Controls->m_RealTimeFibers->isChecked() && node!=m_SelectedBundle) { m_SelectedBundle = node; m_SelectedBundles.push_back(node); mitk::FiberBundleX::Pointer newFib = dynamic_cast(node->GetData()); if (newFib->GetNumFibers()!=m_Controls->m_FiberDensityBox->value()) GenerateFibers(); } else { m_SelectedBundle = node; m_SelectedBundles.push_back(node); } } else if ( node.IsNotNull() && dynamic_cast(node->GetData()) ) { m_SelectedFiducials.push_back(node); m_SelectedFiducial = node; m_SelectedBundles.clear(); mitk::DataStorage::SetOfObjects::ConstPointer parents = GetDataStorage()->GetSources(node); for( mitk::DataStorage::SetOfObjects::const_iterator it = parents->begin(); it != parents->end(); ++it ) { mitk::DataNode::Pointer pNode = *it; if ( pNode.IsNotNull() && dynamic_cast(pNode->GetData()) ) { m_SelectedBundle = pNode; m_SelectedBundles.push_back(pNode); } } } } UpdateGui(); } void QmitkFiberfoxView::EnableCrosshairNavigation() { MITK_DEBUG << "EnableCrosshairNavigation"; // enable the crosshair navigation if (mitk::ILinkedRenderWindowPart* linkedRenderWindow = dynamic_cast(this->GetRenderWindowPart())) { MITK_DEBUG << "enabling linked navigation"; linkedRenderWindow->EnableLinkedNavigation(true); // linkedRenderWindow->EnableSlicingPlanes(true); } if (m_Controls->m_RealTimeFibers->isChecked()) GenerateFibers(); } void QmitkFiberfoxView::DisableCrosshairNavigation() { MITK_DEBUG << "DisableCrosshairNavigation"; // disable the crosshair navigation during the drawing if (mitk::ILinkedRenderWindowPart* linkedRenderWindow = dynamic_cast(this->GetRenderWindowPart())) { MITK_DEBUG << "disabling linked navigation"; linkedRenderWindow->EnableLinkedNavigation(false); // linkedRenderWindow->EnableSlicingPlanes(false); } } void QmitkFiberfoxView::NodeRemoved(const mitk::DataNode* node) { if (node == m_SelectedImage) m_SelectedImage = NULL; if (node == m_SelectedBundle) m_SelectedBundle = NULL; mitk::DataNode* nonConstNode = const_cast(node); std::map::iterator it = m_DataNodeToPlanarFigureData.find(nonConstNode); if( it != m_DataNodeToPlanarFigureData.end() ) { QmitkPlanarFigureData& data = it->second; // remove observers data.m_Figure->RemoveObserver( data.m_EndPlacementObserverTag ); data.m_Figure->RemoveObserver( data.m_SelectObserverTag ); data.m_Figure->RemoveObserver( data.m_StartInteractionObserverTag ); data.m_Figure->RemoveObserver( data.m_EndInteractionObserverTag ); m_DataNodeToPlanarFigureData.erase( it ); } } void QmitkFiberfoxView::NodeAdded( const mitk::DataNode* node ) { // add observer for selection in renderwindow mitk::PlanarFigure* figure = dynamic_cast(node->GetData()); bool isPositionMarker (false); node->GetBoolProperty("isContourMarker", isPositionMarker); if( figure && !isPositionMarker ) { MITK_DEBUG << "figure added. will add interactor if needed."; mitk::PlanarFigureInteractor::Pointer figureInteractor = dynamic_cast(node->GetInteractor()); mitk::DataNode* nonConstNode = const_cast( node ); if(figureInteractor.IsNull()) { figureInteractor = mitk::PlanarFigureInteractor::New("PlanarFigureInteractor", nonConstNode); } else { // just to be sure that the interactor is not added twice mitk::GlobalInteraction::GetInstance()->RemoveInteractor(figureInteractor); } MITK_DEBUG << "adding interactor to globalinteraction"; mitk::GlobalInteraction::GetInstance()->AddInteractor(figureInteractor); MITK_DEBUG << "will now add observers for planarfigure"; QmitkPlanarFigureData data; data.m_Figure = figure; // // add observer for event when figure has been placed typedef itk::SimpleMemberCommand< QmitkFiberfoxView > SimpleCommandType; // SimpleCommandType::Pointer initializationCommand = SimpleCommandType::New(); // initializationCommand->SetCallbackFunction( this, &QmitkFiberfoxView::PlanarFigureInitialized ); // data.m_EndPlacementObserverTag = figure->AddObserver( mitk::EndPlacementPlanarFigureEvent(), initializationCommand ); // add observer for event when figure is picked (selected) typedef itk::MemberCommand< QmitkFiberfoxView > MemberCommandType; MemberCommandType::Pointer selectCommand = MemberCommandType::New(); selectCommand->SetCallbackFunction( this, &QmitkFiberfoxView::PlanarFigureSelected ); data.m_SelectObserverTag = figure->AddObserver( mitk::SelectPlanarFigureEvent(), selectCommand ); // add observer for event when interaction with figure starts SimpleCommandType::Pointer startInteractionCommand = SimpleCommandType::New(); startInteractionCommand->SetCallbackFunction( this, &QmitkFiberfoxView::DisableCrosshairNavigation); data.m_StartInteractionObserverTag = figure->AddObserver( mitk::StartInteractionPlanarFigureEvent(), startInteractionCommand ); // add observer for event when interaction with figure starts SimpleCommandType::Pointer endInteractionCommand = SimpleCommandType::New(); endInteractionCommand->SetCallbackFunction( this, &QmitkFiberfoxView::EnableCrosshairNavigation); data.m_EndInteractionObserverTag = figure->AddObserver( mitk::EndInteractionPlanarFigureEvent(), endInteractionCommand ); m_DataNodeToPlanarFigureData[nonConstNode] = data; } } void QmitkFiberfoxView::PlanarFigureSelected( itk::Object* object, const itk::EventObject& ) { mitk::TNodePredicateDataType::Pointer isPf = mitk::TNodePredicateDataType::New(); mitk::DataStorage::SetOfObjects::ConstPointer allPfs = this->GetDataStorage()->GetSubset( isPf ); for ( mitk::DataStorage::SetOfObjects::const_iterator it = allPfs->begin(); it!=allPfs->end(); ++it) { mitk::DataNode* node = *it; if( node->GetData() == object ) { node->SetSelected(true); m_SelectedFiducial = node; } else node->SetSelected(false); } UpdateGui(); this->RequestRenderWindowUpdate(); } void QmitkFiberfoxView::SetFocus() { m_Controls->m_CircleButton->setFocus(); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.h index 04bd1a9bd2..eb1d890e72 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.h +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxView.h @@ -1,137 +1,138 @@ /*=================================================================== 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 #include #include #include "ui_QmitkFiberfoxViewControls.h" #include #include #include #include #include /*! \brief View for fiber based diffusion software phantoms (Fiberfox). \sa QmitkFunctionality \ingroup Functionalities */ // Forward Qt class declarations using namespace std; class QmitkFiberfoxView : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const string VIEW_ID; QmitkFiberfoxView(); virtual ~QmitkFiberfoxView(); virtual void CreateQtPartControl(QWidget *parent); void SetFocus(); typedef itk::Image ItkUcharImgType; typedef itk::Vector GradientType; typedef vector GradientListType; template vector > MakeGradientList() ; protected slots: void OnDrawROI(); ///< adds new ROI, handles interactors etc. void OnAddBundle(); ///< adds new fiber bundle to datastorage void OnFlipButton(); ///< negate one coordinate of the fiber waypoints in the selcted planar figure. needed in case of unresolvable twists void GenerateFibers(); ///< generate fibers from the selected ROIs void GenerateImage(); ///< generate artificial image from the selected fiber bundle void JoinBundles(); ///< merges selcted fiber bundles into one void CopyBundles(); ///< add copy of the selected bundle to the datamanager void ApplyTransform(); ///< rotate and shift selected bundles void AlignOnGrid(); ///< shift selected fiducials to nearest voxel center void Comp1ModelFrameVisibility(int index);///< only show parameters of selected fiber model type void Comp2ModelFrameVisibility(int index);///< only show parameters of selected non-fiber model type void Comp3ModelFrameVisibility(int index);///< only show parameters of selected non-fiber model type + void Comp4ModelFrameVisibility(int index);///< only show parameters of selected non-fiber model type void ShowAdvancedOptions(int state); /** update fibers if any parameter changes */ void OnFiberDensityChanged(int value); void OnFiberSamplingChanged(int value); void OnTensionChanged(double value); void OnContinuityChanged(double value); void OnBiasChanged(double value); void OnVarianceChanged(double value); void OnDistributionChanged(int value); void OnAddGibbsRinging(int value); void OnConstantRadius(int value); protected: /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer, const QList&); GradientListType GenerateHalfShell(int NPoints); ///< generate vectors distributed over the halfsphere Ui::QmitkFiberfoxViewControls* m_Controls; void UpdateGui(); ///< enable/disbale buttons etc. according to current datamanager selection void PlanarFigureSelected( itk::Object* object, const itk::EventObject& ); void EnableCrosshairNavigation(); ///< enable crosshair navigation if planar figure interaction ends void DisableCrosshairNavigation(); ///< disable crosshair navigation if planar figure interaction starts void NodeAdded( const mitk::DataNode* node ); ///< add observers void NodeRemoved(const mitk::DataNode* node); ///< remove observers /** structure to keep track of planar figures and observers */ struct QmitkPlanarFigureData { QmitkPlanarFigureData() : m_Figure(0) , m_EndPlacementObserverTag(0) , m_SelectObserverTag(0) , m_StartInteractionObserverTag(0) , m_EndInteractionObserverTag(0) , m_Flipped(0) { } mitk::PlanarFigure* m_Figure; unsigned int m_EndPlacementObserverTag; unsigned int m_SelectObserverTag; unsigned int m_StartInteractionObserverTag; unsigned int m_EndInteractionObserverTag; unsigned int m_Flipped; }; std::map m_DataNodeToPlanarFigureData; ///< map each planar figure uniquely to a QmitkPlanarFigureData mitk::Image::Pointer m_TissueMask; ///< mask defining which regions of the image should contain signal and which are containing only noise mitk::DataNode::Pointer m_SelectedFiducial; ///< selected planar ellipse mitk::DataNode::Pointer m_SelectedImage; mitk::DataNode::Pointer m_SelectedBundle; mitk::DataNode::Pointer m_SelectedDWI; vector< mitk::DataNode::Pointer > m_SelectedBundles; vector< mitk::DataNode::Pointer > m_SelectedBundles2; vector< mitk::DataNode::Pointer > m_SelectedFiducials; vector< mitk::DataNode::Pointer > m_SelectedImages; }; diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxViewControls.ui b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxViewControls.ui index 2f76c8d693..813300bbbf 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxViewControls.ui +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberfoxViewControls.ui @@ -1,2267 +1,2033 @@ QmitkFiberfoxViewControls 0 0 493 - 1349 + 1438 Form 0 Fiber Definition Qt::Vertical 20 40 color: rgb(255, 0, 0); Please select an image or an existing fiber bundle to draw the fiber fiducials. If you can't provide a suitable image, generate one using the "Signal Generation" tab. Qt::AutoText Qt::AlignJustify|Qt::AlignVCenter true Fiducial Options All fiducials are treated as circles with the same radius as the first fiducial. Use Constant Fiducial Radius false false Align selected fiducials with voxel grid. Shifts selected fiducials to nearest voxel center. Align With Grid Operations false Copy Bundles false Transform Selection QFrame::NoFrame QFrame::Raised 0 Y false Rotation angle (in degree) around x-axis. -360.000000000000000 360.000000000000000 0.100000000000000 Axis: false Rotation angle (in degree) around y-axis. -360.000000000000000 360.000000000000000 0.100000000000000 Translation: false Translation (in mm) in direction of the z-axis. -1000.000000000000000 1000.000000000000000 0.100000000000000 Translation (in mm) in direction of the y-axis. -1000.000000000000000 1000.000000000000000 0.100000000000000 X false Rotation: false Z false Rotation angle (in degree) around z-axis. -360.000000000000000 360.000000000000000 0.100000000000000 Translation (in mm) in direction of the x-axis. -1000.000000000000000 1000.000000000000000 0.100000000000000 Scaling: false Scaling factor for selected fiber bundle along the x-axis. 0.010000000000000 10.000000000000000 0.010000000000000 1.000000000000000 Scaling factor for selected fiber bundle along the y-axis. 0.010000000000000 10.000000000000000 0.010000000000000 1.000000000000000 Scaling factor for selected fiber bundle along the z-axis. 0.010000000000000 10.000000000000000 0.010000000000000 1.000000000000000 false Join Bundles If checked, the fiducials belonging to the modified bundle are also modified. Include Fiducials true Fiber Options QFrame::NoFrame QFrame::Raised 0 QFrame::NoFrame QFrame::Raised 0 Tension: false Fiber Sampling: false 3 -1.000000000000000 1.000000000000000 0.100000000000000 0.000000000000000 Fiber sampling points (per cm) 1 100 1 10 3 -1.000000000000000 1.000000000000000 0.100000000000000 0.000000000000000 Bias: false Continuity: false 3 -1.000000000000000 1.000000000000000 0.100000000000000 0.000000000000000 QFrame::NoFrame QFrame::Raised 0 6 #Fibers: false Specify number of fibers to generate for the selected bundle. 1 1000000 100 100 false Generate Fibers QFrame::NoFrame QFrame::Raised 0 Select fiber distribution inside of the fiducials. Uniform Gaussian Fiber Distribution: false Variance of the gaussian 3 0.001000000000000 10.000000000000000 0.010000000000000 0.100000000000000 QFrame::NoFrame QFrame::Raised 0 Disable to only generate fibers if "Generate Fibers" button is pressed. Real Time Fibers true Disable to only generate fibers if "Generate Fibers" button is pressed. Advanced Options false QFrame::NoFrame QFrame::Raised 0 false 30 30 Draw elliptical fiducial. :/QmitkDiffusionImaging/circle.png:/QmitkDiffusionImaging/circle.png 32 32 false true false 30 30 Flip fiber waypoints of selcted fiducial around one axis. :/QmitkDiffusionImaging/refresh.xpm:/QmitkDiffusionImaging/refresh.xpm 32 32 false true Qt::Horizontal 40 20 Signal Generation + + + + Intra-axonal Compartment + + + + + + Select signal model for intra-axonal compartment. + + + + Stick Model + + + + + Zeppelin Model + + + + + Tensor Model + + + + + + + + + + + + + + + + Data Fiber Bundle: false <html><head/><body><p><span style=" color:#ff0000;">mandatory</span></p></body></html> true Tissue Mask: false <html><head/><body><p><span style=" color:#969696;">optional</span></p></body></html> true - + - Noise and Artifacts + Extra-axonal Compartments - - - - - true - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - 0 - - - - - - - - - - - - - - k-Space Undersampling: - - - false - - - - - - - Image is upsampled using this factor, afterwards fourier transformed, cropped to the original size and then inverse fourier transformed. - - - 0 - - - - 2 - - - - - 4 - - - - - 8 - - - - - 16 - - - - - 32 - - - - - 64 - - - - - 128 - - - - - 256 - - - - - - - - - - - true - - - QFrame::NoFrame - - - QFrame::Raised + + + + + Select signal model for extra-axonal compartment. - - - QFormLayout::AllNonFixedFieldsGrow - - - 0 + + + Ball Model - - 0 + + + + Astrosticks Model - - 0 + + + + Dot Model - + - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - - - Variance: - - - - - - - Variance of Rician noise model. - - - 4 - - - 0.000000000000000 - - - 100000.000000000000000 - - - 0.001000000000000 - - - 25.000000000000000 - - - - - + + - - - - Add Gibbs Ringing - - - false - - + + - - - - - - - true - - - Start DWI generation from selected fiebr bundle. If no fiber bundle is selected, a grayscale image containing a simple gradient is generated. - - - Generate Image - - - - - - - Intra-axonal Compartment - - - false - - - false - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - - - Determins anisotropy of kernel tensor (zeppelin-model). - - - 0.010000000000000 - - - 1.000000000000000 - - - 0.100000000000000 - - - 0.700000000000000 - - - - - - - Fractional Anisotropy: - - - - - + + - - + + + + + - Select signal model for intra-axonal compartment. + Select signal model for extra-axonal compartment. - Zeppelin Model + -- - Stick Model + Ball Model + + + + + Astrosticks Model + + + + + Dot Model - - - - QFrame::NoFrame - - - QFrame::Raised + + + + Qt::Horizontal - - - 0 - - - - - - - - - - - - - - T2 Relaxation: - - - false - - - - - - - T2 of intra axonal compartment (in milliseconds). - - - 1 - - - 10000 - - - 1 - - - 90 - - - - - - + + + + + QFrame::NoFrame QFrame::Raised - + 0 - + - Diffusivity parameter of the stick-model. - - - 4 - - - 0.000100000000000 + Weighting factor between the two extra-axonal compartments. 1.000000000000000 - 0.000500000000000 + 0.100000000000000 - 0.005000000000000 + 0.300000000000000 - + - Diffusivity: + Compartment Fraction: + + + + + + + true + + + Start DWI generation from selected fiebr bundle. If no fiber bundle is selected, a grayscale image containing a simple gradient is generated. + + + Generate Image + + + Image Settings - + QFrame::NoFrame QFrame::Raised 0 6 Fiber Radius: Output k-Space Image false Treat voxel content as fiber-only if at least one fiber is present. Enforce Pure Fiber Voxels false Repetitions: Number of signal averages. Increase to reduce noise. 1 100 1 1 T2* Relaxation: false Scaling factor for signal. 0 10000 1 200 Large values shrink (towards nearest neighbour interpolation), small values strech interpolation function (towards linear interpolation). 1 10000 10 Fiber radius used to calculate volume fractions (in µm). Set to 0 for automatic radius estimation. 0 1000 0 T2* relaxation time (in milliseconds). 1 10000 1 50 Interpolation Shrink: TE in milliseconds 1 10000 1 100 Signal Scale: false Echo Time TE: false Line Readout Time: false T2* relaxation time (in milliseconds). 100.000000000000000 0.100000000000000 1.000000000000000 color: rgb(255, 0, 0); Using mask image geometry! - - - - QFrame::NoFrame + + + + color: rgb(255, 0, 0); - - QFrame::Raised + + Using gradients of selected DWI! - - - 0 - - - 6 - - - - - Gradient Directions: - - - - - - - Number of gradient directions distributed over the half sphere. - - - 0 - - - 10000 - - - 1 - - - 30 - - - - - - - - - - - - - - - - b-Value: - - - false - - - - - - - b-value in mm/s² - - - 0 - - - 10000 - - - 100 - - - 1000 - - - - QFrame::NoFrame QFrame::Raised 0 3 0.100000000000000 50.000000000000000 0.100000000000000 2.500000000000000 Image Spacing: 3 0.100000000000000 50.000000000000000 0.100000000000000 2.500000000000000 3 0.100000000000000 50.000000000000000 0.100000000000000 2.500000000000000 Image Dimensions: Fiber sampling factor which determines the accuracy of the calculated fiber and non-fiber volume fractions. 1 1000 1 32 Fiber sampling factor which determines the accuracy of the calculated fiber and non-fiber volume fractions. 1 100 1 32 Fiber sampling factor which determines the accuracy of the calculated fiber and non-fiber volume fractions. 1 100 1 - - 5 - - - - - - - - - - color: rgb(255, 0, 0); - - - Using gradients of selected DWI! - - - - - - - Advanced Options - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Extra-axonal Compartments - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - - - Diffusivity parameter of the ball-model. - - - 4 - - - 0.000100000000000 - - - 1.000000000000000 - - - 0.000500000000000 - - - 0.001000000000000 - - - - - - - Diffusivity: - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - - - - - - - - - - - - T2 Relaxation: - - - false - - - - - - - T2 of extra axonal compartment (in milliseconds). - - - 1 - - - 10000 - - - 1 - - - 100 - - - - - - - - - - Select signal model for extra-axonal compartment. - - - - -- - - - - - Ball Model - - - - - Astrosticks Model - - - - - Dot Model - - + + 5 + + + + - - + + QFrame::NoFrame QFrame::Raised - + 0 + + 6 + + + + + Gradient Directions: + + + - + - T2 of extra axonal compartment (in milliseconds). + Number of gradient directions distributed over the half sphere. - 1 + 0 10000 1 - 100 + 30 - - + + - T2 Relaxation: + b-Value: false - - + + + + b-value in mm/s² + + + 0 + + + 10000 + + + 100 + + + 1000 + + + + + + + + + + Advanced Options + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Noise and Artifacts + + + + + + true + + + QFrame::NoFrame + + + QFrame::Raised + + + + 6 + + + 0 + + + - Compartment Fraction: + k-Space Undersampling: false - - - - 3 - - - 1.000000000000000 - - - 0.100000000000000 + + + + Image is upsampled using this factor, afterwards fourier transformed, cropped to the original size and then inverse fourier transformed. - - 0.300000000000000 + + 0 + + + 2 + + + + + 4 + + + + + 8 + + + + + 16 + + + + + 32 + + + + + 64 + + + + + 128 + + + + + 256 + + - - - - Use random number (20-60) and distribution for astrosticks/cylinders. + + + + true - - Randomize Astrosticks + + QFrame::NoFrame + + QFrame::Raised + + + + QFormLayout::AllNonFixedFieldsGrow + + + 0 + + + 0 + + + 0 + + - - + + QFrame::NoFrame QFrame::Raised - + 0 + + + + Variance: + + + - + - Diffusivity parameter of the ball-model. + Variance of Rician noise model. 4 - 0.000100000000000 + 0.000000000000000 - 1.000000000000000 + 100000.000000000000000 - 0.000500000000000 - - 0.001000000000000 - - - - - - Diffusivity: + + 25.000000000000000 + + + + Add Gibbs Ringing + + + false + + + + + + + + + + Inter-axonal Compartment + + + + + + + + - Select signal model for extra-axonal compartment. + Select signal model for intra-axonal compartment. - Ball Model + -- - Astrosticks Model + Stick Model - Dot Model + Zeppelin Model + + + + + Tensor Model - - - - Use random number (20-60) and distribution for astrosticks/cylinders. - - - Randomize Astrosticks - - + + + + + QmitkTensorModelParametersWidget + QWidget +
QmitkTensorModelParametersWidget.h
+ 1 +
+ + QmitkStickModelParametersWidget + QWidget +
QmitkStickModelParametersWidget.h
+ 1 +
+ + QmitkZeppelinModelParametersWidget + QWidget +
QmitkZeppelinModelParametersWidget.h
+ 1 +
+ + QmitkBallModelParametersWidget + QWidget +
QmitkBallModelParametersWidget.h
+ 1 +
+ + QmitkAstrosticksModelParametersWidget + QWidget +
QmitkAstrosticksModelParametersWidget.h
+ 1 +
+ + QmitkDotModelParametersWidget + QWidget +
QmitkDotModelParametersWidget.h
+ 1 +
+
tabWidget m_CircleButton m_FlipButton m_RealTimeFibers - m_AdvancedOptionsBox m_DistributionBox + m_AdvancedOptionsBox m_VarianceBox m_FiberDensityBox m_FiberSamplingBox m_TensionBox m_ContinuityBox m_BiasBox m_GenerateFibersButton m_ConstantRadiusBox m_AlignOnGrid m_XrotBox m_YrotBox m_ZrotBox m_XtransBox m_YtransBox m_ZtransBox m_XscaleBox m_YscaleBox m_ZscaleBox m_TransformBundlesButton m_CopyBundlesButton m_JoinBundlesButton m_IncludeFiducials m_GenerateImageButton m_SizeX m_SizeY m_SizeZ m_SpacingX m_SpacingY m_SpacingZ m_NumGradientsBox m_BvalueBox + m_AdvancedOptionsBox_2 m_RepetitionsBox m_SignalScaleBox m_TEbox m_LineReadoutTimeBox m_T2starBox m_FiberRadius m_InterpolationShrink m_EnforcePureFiberVoxelsBox m_KspaceImageBox - m_AdvancedOptionsBox_2 m_Compartment1Box - m_TensorFaBox - m_DiffusivityBoxComp1 - m_T2BoxComp1 m_Compartment2Box - m_DiffusivityBoxComp2 + m_Compartment3Box + m_Compartment4Box + m_Comp4FractionBox m_NoiseLevel - m_KspaceUndersamplingBox m_AddGibbsRinging + m_KspaceUndersamplingBox