Commit 1ff80ccd authored by davisb's avatar davisb
Browse files

ENH: add popup to EMSeg to warn against using images of differnt voxel types

git-svn-id: http://svn.slicer.org/Slicer4/trunk@6551 3bd1e089-480b-0410-8dfb-8563597acbee
parent 7295981f
......@@ -14,6 +14,7 @@
#include "vtkKWLoadSaveDialog.h"
#include "vtkKWMatrixWidget.h"
#include "vtkKWMatrixWidgetWithLabel.h"
#include "vtkKWMessageDialog.h"
#include "vtkKWPushButton.h"
#include "vtkKWWizardStep.h"
#include "vtkKWWizardWidget.h"
......@@ -787,6 +788,26 @@ void vtkEMSegmentRunSegmentationStep::MultiThreadingCallback(int state)
void vtkEMSegmentRunSegmentationStep::StartSegmentationCallback()
{
vtkEMSegmentLogic *logic = this->GetGUI()->GetLogic();
vtkEMSegmentMRMLManager* mrmlManager = this->GetGUI()->GetMRMLManager();
// make sure that data types are the same
if (!mrmlManager->DoTargetAndAtlasDataTypesMatch())
{
// popup an error message
std::string errorMessage =
"Scalar type mismatch for input images; all image scalar types must be "
"the same (including input channels and atlas images).";
vtkKWMessageDialog::PopupMessage(this->GetApplication(),
NULL,
"Input Image Error",
errorMessage.c_str(),
vtkKWMessageDialog::ErrorIcon |
vtkKWMessageDialog::InvokeAtPointer);
return;
}
// start the segmentation
logic->StartSegmentation();
}
......
......@@ -2013,6 +2013,58 @@ MoveTargetSelectedVolume(vtkIdType volumeID, int toIndex)
this->MoveNthTargetSelectedVolume(imageIndex, toIndex);
}
//----------------------------------------------------------------------------
bool
vtkEMSegmentMRMLManager::
DoTargetAndAtlasDataTypesMatch()
{
vtkMRMLEMSTargetNode* targetNode =
this->GetWorkingDataNode()->GetInputTargetNode();
vtkMRMLEMSAtlasNode* atlasNode =
this->GetWorkingDataNode()->GetInputAtlasNode();
if (targetNode == NULL || atlasNode == NULL)
{
std::cerr << "Target or atlas node is null!" << std::endl;
return false;
}
if (targetNode->GetNumberOfVolumes() == 0)
{
std::cerr << "Target node is empty!" << std::endl;
return (atlasNode->GetNumberOfVolumes() == 0);
}
int standardScalarDataType =
targetNode->GetNthVolumeNode(0)->GetImageData()->GetScalarType();
for (int i = 1; i < targetNode->GetNumberOfVolumes(); ++i)
{
int currentScalarDataType =
targetNode->GetNthVolumeNode(i)->GetImageData()->GetScalarType();
if (currentScalarDataType != standardScalarDataType)
{
std::cerr << "Target volume " << i << ": scalar type does not match!"
<< std::endl;
return false;
}
}
for (int i = 0; i < atlasNode->GetNumberOfVolumes(); ++i)
{
int currentScalarDataType =
atlasNode->GetNthVolumeNode(i)->GetImageData()->GetScalarType();
if (currentScalarDataType != standardScalarDataType)
{
std::cerr << "Atlas volume " << i << ": scalar type does not match!"
<< std::endl;
return false;
}
}
return true;
}
//----------------------------------------------------------------------------
void
vtkEMSegmentMRMLManager::
......
......@@ -312,6 +312,8 @@ public:
virtual void MoveTargetSelectedVolume(vtkIdType volumeID,
int toIndex);
virtual bool DoTargetAndAtlasDataTypesMatch();
//
// target volume normalization
virtual void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment