void QmitkImageStatisticsCalculationThread::Initialize( mitk::Image::Pointer image, mitk::Image::Pointer binaryImage, mitk::PlanarFigure::Pointer planarFig ) { // reset old values if( this->m_StatisticsImage.IsNotNull() ) this->m_StatisticsImage = 0; if( this->m_BinaryMask.IsNotNull() ) this->m_BinaryMask = 0; if( this->m_PlanarFigureMask.IsNotNull()) this->m_PlanarFigureMask = 0; // set new values if passed in if(image.IsNotNull()) this->m_StatisticsImage = image->Clone(); if(binaryImage.IsNotNull()) this->m_BinaryMask = binaryImage->Clone(); if(planarFig.IsNotNull()) this->m_PlanarFigureMask = dynamic_cast<mitk::PlanarFigure*>(planarFig.GetPointer()); // once clone methods for planar figures are implemented, copy the data here! }
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); }
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); }
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); }