void Init() { im1 = mitk::ImageGenerator::GenerateRandomImage<double>(2,2,2,1,2,2,2,1,0); im2 = mitk::ImageGenerator::GenerateRandomImage<double>(3,3,3,1,3,3,3,3,2); im3 = mitk::ImageGenerator::GenerateRandomImage<double>(4,4,4,1,4,4,4,5,4); im4 = mitk::ImageGenerator::GenerateRandomImage<double>(5,5,5,1,5,5,5,7,6); dataCol1 = mitk::DataCollection::New(); dataCol2 = mitk::DataCollection::New(); dataCol1->AddData(im1.GetPointer(),"T1"); dataCol1->AddData(im2.GetPointer(),"T2"); dataCol2->AddData(im3.GetPointer(),"T1"); dataCol2->AddData(im4.GetPointer(),"T2"); col1 = mitk::DataCollection::New(); col1->SetName("GnaBla"); col1->AddData(dataCol1.GetPointer(), "0001"); col1->AddData(dataCol2.GetPointer(), "0002"); m_Collection = mitk::DataCollection::New(); m_Collection->SetName("DummyCollection"); m_Collection->AddData(col1.GetPointer(), "C1"); }
void mitk::SurfaceInterpolationController::SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage) { if (currentSegmentationImage.GetPointer() == m_SelectedSegmentation) return; if (currentSegmentationImage.IsNull()) { m_SelectedSegmentation = nullptr; return; } m_SelectedSegmentation = currentSegmentationImage.GetPointer(); auto it = m_ListOfInterpolationSessions.find(currentSegmentationImage.GetPointer()); // If the session does not exist yet create a new ContourPositionPairList otherwise reinitialize the interpolation pipeline if (it == m_ListOfInterpolationSessions.end()) { ContourPositionInformationVec2D newList; m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionInformationVec2D>(m_SelectedSegmentation, newList)); m_InterpolationResult = nullptr; m_CurrentNumberOfReducedContours = 0; itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New(); command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted); m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( m_SelectedSegmentation, m_SelectedSegmentation->AddObserver( itk::DeleteEvent(), command ) ) ); } this->ReinitializeInterpolation(); }
void GetImageStatisticsWithImageAndMaskNotConnected() { //create rules connection + add statistics to dataStorage auto statisticsNode = mitk::CreateImageStatisticsNode(m_statisticsContainer, "testStatistics"); CreateNodeRelationImage(m_statisticsContainer.GetPointer(), m_image.GetPointer()); CreateNodeRelationMask(m_statisticsContainer.GetPointer(), m_mask.GetPointer()); auto standaloneDataStorage = mitk::StandaloneDataStorage::New(); standaloneDataStorage->Add(statisticsNode); //rule: (image-->statistics, mask-->statistics), 1 connected image --> test return nullptr mitk::ImageStatisticsContainer::ConstPointer statisticsWithImage; CPPUNIT_ASSERT_NO_THROW(statisticsWithImage = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImage.IsNull(), true); //rule: (image-->statistics, mask-->statistics), 1 unconnected image, 1 unconnected mask --> test return nullptr mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageNotConnectedAndMaskNotConnected; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageNotConnectedAndMaskNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_mask2.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageNotConnectedAndMaskNotConnected.IsNull(), true); //rule: (image-->statistics, mask-->statistics), 1 unconnected image, 1 connected mask --> test return nullptr mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAndMaskNotConnected; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndMaskNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_mask.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndMaskNotConnected.IsNull(), true); //rule: (image-->statistics, mask-->statistics), 1 connected image, 1 unconnected planarFigure --> test return nullptr mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAndPlanarFigureNotConnected; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndPlanarFigureNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_planarFigure.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndPlanarFigureNotConnected.IsNull(), true); //rule: (image-->statistics, mask-->statistics), 1 unconnected image, 1 unconnected planarFigure --> test return nullptr mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageNotConnectedAndPlanarFigureNotConnected; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndPlanarFigureNotConnected = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_planarFigure.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndPlanarFigureNotConnected.IsNull(), true); }
void mitk::SurfaceInterpolationController::SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage) { if (currentSegmentationImage.GetPointer() == m_SelectedSegmentation) return; m_ReduceFilter->Reset(); m_NormalsFilter->Reset(); m_InterpolateSurfaceFilter->Reset(); if (currentSegmentationImage.IsNull()) { m_SelectedSegmentation = 0; return; } ContourListMap::iterator it = m_ListOfInterpolationSessions.find(currentSegmentationImage.GetPointer()); m_SelectedSegmentation = currentSegmentationImage.GetPointer(); itk::ImageBase<3>::Pointer itkImage = itk::ImageBase<3>::New(); AccessFixedDimensionByItk_1( m_SelectedSegmentation, GetImageBase, 3, itkImage ); m_InterpolateSurfaceFilter->SetReferenceImage( itkImage.GetPointer() ); if (it == m_ListOfInterpolationSessions.end()) { ContourPositionPairList newList; m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionPairList>(m_SelectedSegmentation, newList)); m_InterpolationResult = 0; m_CurrentNumberOfReducedContours = 0; itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New(); command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted); m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( m_SelectedSegmentation, m_SelectedSegmentation->AddObserver( itk::DeleteEvent(), command ) ) ); } else { for (unsigned int i = 0; i < m_ListOfInterpolationSessions[m_SelectedSegmentation].size(); i++) { m_ReduceFilter->SetInput(i, m_ListOfInterpolationSessions[m_SelectedSegmentation].at(i).contour); } m_ReduceFilter->Update(); m_CurrentNumberOfReducedContours = m_ReduceFilter->GetNumberOfOutputs(); for (unsigned int i = 0; i < m_CurrentNumberOfReducedContours; i++) { m_NormalsFilter->SetInput(i, m_ReduceFilter->GetOutput(i)); m_InterpolateSurfaceFilter->SetInput(i, m_NormalsFilter->GetOutput(i)); } } Modified(); }
/** * @brief AddColouredOverlay - Overlays the rgbImage with an coloured overlay * * For all positions in overlayImage not zero, its value is multiplied the the colour value and added * to the rgbImage. * * @param rgbImage - input rgbImage to which the coloured overlay is added * @param overlayImage * @param color */ void AddColouredOverlay(mitk::Image::Pointer rgbImage, mitk::Image::Pointer overlayImage, mitk::Color color) { unsigned int *dim = rgbImage->GetDimensions(); itk::Image<PixelType,3>::Pointer itkOverlayImage = itk::Image<PixelType,3>::New(); mitk::CastToItkImage(overlayImage.GetPointer(), itkOverlayImage); mitk::ImagePixelWriteAccessor<RGBPixelType ,3> writeAcc(rgbImage); itk::Index<3> idx; itk::RGBPixel<PixelType> value; unsigned short overlayVal=0; // Fill rgb image with gray values for (idx[2] =0; (unsigned int)idx[2] < dim[2]; idx[2]++) { for (idx[1] =0; (unsigned int)idx[1] < dim[1]; idx[1]++) { for (idx[0] =0; (unsigned int)idx[0] < dim[0]; idx[0]++) { overlayVal = 255*itkOverlayImage->GetPixel(idx); value = writeAcc.GetPixelByIndex(idx); value[0] = std::min( (int)(value[0] + overlayVal * color[0]),254*255); value[1] = std::min((int)(value[1] + overlayVal * color[1]),254*255) ; value[2] = std::min((int)(value[2] + overlayVal * color[2]),254*255); writeAcc.SetPixelByIndex(idx, value); } } } }
void GetImageStatisticsWithImageConnected() { //create rules connection auto statisticsNode = mitk::CreateImageStatisticsNode(m_statisticsContainer, "testStatistics"); CreateNodeRelationImage(m_statisticsContainer.GetPointer(), m_image.GetPointer()); auto standaloneDataStorage = mitk::StandaloneDataStorage::New(); standaloneDataStorage->Add(statisticsNode); //rule: (image-->statistics), 1 connected image --> test return image statistics mitk::ImageStatisticsContainer::ConstPointer statisticsWithImage; CPPUNIT_ASSERT_NO_THROW(statisticsWithImage = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImage->GetUID(), m_statisticsContainer->GetUID()); //new rule: (image2-->statistics2 AND mask --> statistics2) CreateNodeRelationImage(m_statisticsContainer2.GetPointer(), m_image2.GetPointer()); CreateNodeRelationMask(m_statisticsContainer2.GetPointer(), m_mask.GetPointer()); auto statisticsNode2 = mitk::CreateImageStatisticsNode(m_statisticsContainer2, "testStatistics2"); standaloneDataStorage->Add(statisticsNode2); //--> test return (still) image statistics (!= statistics2) mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAgain; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAgain = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID(), m_statisticsContainer->GetUID()); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID() != m_statisticsContainer2->GetUID(), true); //--> test return image statistics 2 CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAgain = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image2.GetPointer(), m_mask.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID(), m_statisticsContainer2->GetUID()); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAgain->GetUID() != m_statisticsContainer->GetUID(), true); //add another newer statistic: should return this newer one auto statisticsContainerNew = mitk::ImageStatisticsContainer::New(); CreateNodeRelationImage(statisticsContainerNew.GetPointer(), m_image.GetPointer()); auto statisticsNodeNew = mitk::CreateImageStatisticsNode(statisticsContainerNew, "testStatisticsNew"); standaloneDataStorage->Add(statisticsNodeNew); statisticsContainerNew->Modified(); mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageNew; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageNew = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageNew->GetUID(), statisticsContainerNew->GetUID()); CPPUNIT_ASSERT_EQUAL(statisticsWithImageNew->GetUID() != m_statisticsContainer->GetUID(), true); }
void GetImageStatisticsWithImageAndMaskConnected() { //create rules connection + add statistics to dataStorage auto statisticsNode = mitk::CreateImageStatisticsNode(m_statisticsContainer, "testStatistics"); CreateNodeRelationImage(m_statisticsContainer.GetPointer(), m_image.GetPointer()); CreateNodeRelationMask(m_statisticsContainer.GetPointer(), m_mask.GetPointer()); auto standaloneDataStorage = mitk::StandaloneDataStorage::New(); standaloneDataStorage->Add(statisticsNode); //rule: (image-->statistics, mask-->statistics), 1 connected image, 1 connected mask --> test return statistics mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAndMask; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndMask = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_mask.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndMask.IsNull(), false); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndMask->GetUID(), m_statisticsContainer->GetUID()); //new rule: (image-->statistics2) --> returns statistic because statistic2 has no mask connection CreateNodeRelationImage(m_statisticsContainer2.GetPointer(), m_image.GetPointer()); auto statisticsNode2 = mitk::CreateImageStatisticsNode(m_statisticsContainer2, "testStatistics2"); standaloneDataStorage->Add(statisticsNode2); mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAndMaskAgain; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndMaskAgain = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_mask.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndMaskAgain->GetUID(), m_statisticsContainer->GetUID()); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndMaskAgain->GetUID() != m_statisticsContainer2->GetUID(), true); //add another newer statistic: should return this newer one auto statisticsContainerNew = mitk::ImageStatisticsContainer::New(); mitk::PropertyRelations::RuleResultVectorType rules4; CreateNodeRelationImage(statisticsContainerNew.GetPointer(), m_image.GetPointer()); CreateNodeRelationMask(statisticsContainerNew.GetPointer(), m_mask.GetPointer()); auto statisticsNodeNew = mitk::CreateImageStatisticsNode(statisticsContainerNew, "testStatisticsNew"); standaloneDataStorage->Add(statisticsNodeNew); mitk::ImageStatisticsContainer::ConstPointer statisticsWithImageAndMaskNew; CPPUNIT_ASSERT_NO_THROW(statisticsWithImageAndMaskNew = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_mask.GetPointer())); CPPUNIT_ASSERT_EQUAL(statisticsContainerNew->GetUID(), statisticsWithImageAndMaskNew->GetUID()); CPPUNIT_ASSERT_EQUAL(statisticsWithImageAndMaskNew->GetUID() != m_statisticsContainer->GetUID(), true); }
void GetImageStatisticsInvalid() { CreateNodeRelationImage(m_statisticsContainer.GetPointer(), m_image.GetPointer()); CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(nullptr, m_image.GetPointer()), mitk::Exception); auto standaloneDataStorage = mitk::StandaloneDataStorage::New(); CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), nullptr), mitk::Exception); CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), nullptr, m_mask.GetPointer()), mitk::Exception); CPPUNIT_ASSERT_THROW(mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), nullptr, m_planarFigure.GetPointer()), mitk::Exception); }
bool mitk::SurfaceInterpolationController::ReplaceInterpolationSession(mitk::Image::Pointer oldSession, mitk::Image::Pointer newSession) { if (oldSession.IsNull() || newSession.IsNull()) return false; if (oldSession.GetPointer() == newSession.GetPointer()) return false; if (!mitk::Equal(*(oldSession->GetGeometry()), *(newSession->GetGeometry()), mitk::eps, false)) return false; auto it = m_ListOfInterpolationSessions.find(oldSession.GetPointer()); if (it == m_ListOfInterpolationSessions.end()) return false; ContourPositionInformationVec2D oldList = (*it).second; m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionInformationVec2D>(newSession.GetPointer(), oldList)); itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New(); command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted); m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( newSession, newSession->AddObserver( itk::DeleteEvent(), command ) ) ); if (m_SelectedSegmentation == oldSession) m_SelectedSegmentation = newSession; mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New(); timeSelector->SetInput( m_SelectedSegmentation ); timeSelector->SetTimeNr( m_CurrentTimeStep ); timeSelector->SetChannelNr( 0 ); timeSelector->Update(); mitk::Image::Pointer refSegImage = timeSelector->GetOutput(); m_NormalsFilter->SetSegmentationBinaryImage(refSegImage); this->RemoveInterpolationSession(oldSession); return true; }
void mitk::RegistrationWrapper::ApplyTransformationToImage(mitk::Image::Pointer img, const mitk::RegistrationWrapper::RidgidTransformType &transformation,double* offset, mitk::Image* resampleReference, bool binary) { typedef mitk::DiffusionImage<short> DiffusionImageType; if (dynamic_cast<DiffusionImageType*> (img.GetPointer()) == NULL) { ItkImageType::Pointer itkImage = ItkImageType::New(); MITK_ERROR << "imgCopy 0 " << "/" << img->GetReferenceCount(); MITK_ERROR << "pixel type " << img->GetPixelType().GetComponentTypeAsString(); CastToItkImage(img, itkImage); typedef itk::Euler3DTransform< double > RigidTransformType; RigidTransformType::Pointer rtransform = RigidTransformType::New(); RigidTransformType::ParametersType parameters(RigidTransformType::ParametersDimension); for (int i = 0; i<6;++i) parameters[i] = transformation[i]; rtransform->SetParameters( parameters ); mitk::Point3D origin = itkImage->GetOrigin(); origin[0]-=offset[0]; origin[1]-=offset[1]; origin[2]-=offset[2]; mitk::Point3D newOrigin = rtransform->GetInverseTransform()->TransformPoint(origin); itk::Matrix<double,3,3> dir = itkImage->GetDirection(); itk::Matrix<double,3,3> transM ( vnl_inverse(rtransform->GetMatrix().GetVnlMatrix())); itk::Matrix<double,3,3> newDirection = transM * dir; itkImage->SetOrigin(newOrigin); itkImage->SetDirection(newDirection); // Perform Resampling if reference image is provided if (resampleReference != NULL) { typedef itk::ResampleImageFilter<ItkImageType, ItkImageType> ResampleFilterType; ItkImageType::Pointer itkReference = ItkImageType::New(); CastToItkImage(resampleReference,itkReference); typedef itk::WindowedSincInterpolateImageFunction< ItkImageType, 3> WindowedSincInterpolatorType; WindowedSincInterpolatorType::Pointer sinc_interpolator = WindowedSincInterpolatorType::New(); typedef itk::NearestNeighborInterpolateImageFunction< ItkImageType, double > NearestNeighborInterpolatorType; NearestNeighborInterpolatorType::Pointer nn_interpolator = NearestNeighborInterpolatorType::New(); ResampleFilterType::Pointer resampler = ResampleFilterType::New(); resampler->SetInput(itkImage); resampler->SetReferenceImage( itkReference ); resampler->UseReferenceImageOn(); if (binary) resampler->SetInterpolator(nn_interpolator); else resampler->SetInterpolator(sinc_interpolator); resampler->Update(); GrabItkImageMemory(resampler->GetOutput(), img); } else { // !! CastToItk behaves very differently depending on the original data type // if the target type is the same as the original, only a pointer to the data is set // and an additional GrabItkImageMemory will cause a segfault when the image is destroyed // GrabItkImageMemory - is not necessary in this case since we worked on the original data // See Bug 17538. if (img->GetPixelType().GetComponentTypeAsString() != "double") img = GrabItkImageMemory(itkImage); } } else { DiffusionImageType::Pointer diffImages = dynamic_cast<DiffusionImageType*>(img.GetPointer()); typedef itk::Euler3DTransform< double > RigidTransformType; RigidTransformType::Pointer rtransform = RigidTransformType::New(); RigidTransformType::ParametersType parameters(RigidTransformType::ParametersDimension); for (int i = 0; i<6;++i) { parameters[i] = transformation[i]; } rtransform->SetParameters( parameters ); mitk::Point3D b0origin = diffImages->GetVectorImage()->GetOrigin(); b0origin[0]-=offset[0]; b0origin[1]-=offset[1]; b0origin[2]-=offset[2]; mitk::Point3D newOrigin = rtransform->GetInverseTransform()->TransformPoint(b0origin); itk::Matrix<double,3,3> dir = diffImages->GetVectorImage()->GetDirection(); itk::Matrix<double,3,3> transM ( vnl_inverse(rtransform->GetMatrix().GetVnlMatrix())); itk::Matrix<double,3,3> newDirection = transM * dir; diffImages->GetVectorImage()->SetOrigin(newOrigin); diffImages->GetVectorImage()->SetDirection(newDirection); diffImages->Modified(); mitk::DiffusionImageCorrectionFilter<short>::Pointer correctionFilter = mitk::DiffusionImageCorrectionFilter<short>::New(); // For Diff. Images: Need to rotate the gradients (works in-place) correctionFilter->SetImage(diffImages); correctionFilter->CorrectDirections(transM.GetVnlMatrix()); img = diffImages; } }
void KurtosisMapComputation( mitk::Image::Pointer input, std::string output_prefix , std::string output_type, std::string maskPath, bool omitBZero, double lower, double upper ) { DPH::ImageType::Pointer vectorImage = DPH::ImageType::New(); mitk::CastToItkImage( input, vectorImage ); typedef itk::DiffusionKurtosisReconstructionImageFilter< short, double > KurtosisFilterType; KurtosisFilterType::Pointer kurtosis_filter = KurtosisFilterType::New(); kurtosis_filter->SetInput( GetBlurredVectorImage( vectorImage, 1.5 ) ); kurtosis_filter->SetReferenceBValue( DPH::GetReferenceBValue( input.GetPointer() ) ); kurtosis_filter->SetGradientDirections( DPH::GetGradientContainer( input.GetPointer() ) ); // kurtosis_filter->SetNumberOfThreads(1); kurtosis_filter->SetOmitUnweightedValue(omitBZero); kurtosis_filter->SetBoundariesForKurtosis(-lower,upper); // kurtosis_filter->SetInitialSolution(const vnl_vector<double>& x0 ); if(maskPath != "") { mitk::Image::Pointer segmentation; segmentation = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(maskPath)[0].GetPointer()); typedef itk::Image< short , 3> MaskImageType; MaskImageType::Pointer vectorSeg = MaskImageType::New() ; mitk::CastToItkImage( segmentation, vectorSeg ); kurtosis_filter->SetImageMask(vectorSeg) ; } try { kurtosis_filter->Update(); } catch( const itk::ExceptionObject& e) { mitkThrow() << "Kurtosis fit failed with an ITK Exception: " << e.what(); } mitk::Image::Pointer d_image = mitk::Image::New(); d_image->InitializeByItk( kurtosis_filter->GetOutput(0) ); d_image->SetVolume( kurtosis_filter->GetOutput(0)->GetBufferPointer() ); mitk::Image::Pointer k_image = mitk::Image::New(); k_image->InitializeByItk( kurtosis_filter->GetOutput(1) ); k_image->SetVolume( kurtosis_filter->GetOutput(1)->GetBufferPointer() ); std::string outputD_FileName = output_prefix + "_ADC_map." + output_type; std::string outputK_FileName = output_prefix + "_AKC_map." + output_type; try { mitk::IOUtil::Save( d_image, outputD_FileName ); mitk::IOUtil::Save( k_image, outputK_FileName ); } catch( const itk::ExceptionObject& e) { mitkThrow() << "Failed to save the KurtosisFit Results due to exception: " << e.what(); } }
void GetImageStatisticsNoRules() { auto statisticsNode = mitk::CreateImageStatisticsNode(m_statisticsContainer, "testStatistics"); auto standaloneDataStorage = mitk::StandaloneDataStorage::New(); standaloneDataStorage->Add(statisticsNode); //no rules + 1 image --> test return nullptr mitk::ImageStatisticsContainer::ConstPointer emptyStatistic; CPPUNIT_ASSERT_NO_THROW(emptyStatistic = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer())); CPPUNIT_ASSERT_EQUAL(emptyStatistic.IsNull(), true); //no rules + 1 image + 1 mask --> test return nullptr CPPUNIT_ASSERT_NO_THROW(emptyStatistic = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_mask.GetPointer())); CPPUNIT_ASSERT_EQUAL(emptyStatistic.IsNull(), true); //no rules + 1 image + 1 planarFigure --> test return nullptr CPPUNIT_ASSERT_NO_THROW(emptyStatistic = mitk::ImageStatisticsContainerManager::GetImageStatistics(standaloneDataStorage.GetPointer(), m_image.GetPointer(), m_planarFigure.GetPointer())); CPPUNIT_ASSERT_EQUAL(emptyStatistic.IsNull(), true); }