Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit

Abstract base class for segmentation tools. More...

#include <mitkSegTool2D.h>

Inheritance diagram for mitk::SegTool2D:
Collaboration diagram for mitk::SegTool2D:

Classes

struct  SliceInformation
 

Public Member Functions

 mitkClassMacro (SegTool2D, Tool)
 
void SetShowMarkerNodes (bool)
 
void SetEnable3DInterpolation (bool)
 Enables or disables the 3D interpolation after writing back the 2D segmentation result, and defaults to true. More...
 
- Public Member Functions inherited from mitk::Tool
 mitkClassMacro (Tool, EventStateMachine)
 
virtual const char ** GetXPM () const =0
 Returns an icon in the XPM format. More...
 
virtual std::string GetIconPath () const
 Returns the path of an icon. More...
 
virtual us::ModuleResource GetCursorIconResource () const
 Returns the path of a cursor icon. More...
 
virtual us::ModuleResource GetIconResource () const
 Returns the tool button icon of the tool wrapped by a usModuleResource. More...
 
virtual const char * GetName () const =0
 Returns the name of this tool. Make it short! More...
 
virtual const char * GetGroup () const
 Name of a group. More...
 
virtual void InitializeStateMachine ()
 
virtual itk::Object::Pointer GetGUI (const std::string &toolkitPrefix, const std::string &toolkitPostfix)
 Interface for GUI creation. More...
 
virtual NodePredicateBase::ConstPointer GetReferenceDataPreference () const
 
virtual NodePredicateBase::ConstPointer GetWorkingDataPreference () const
 
DataNode::Pointer CreateEmptySegmentationNode (Image *original, const std::string &organName, const mitk::Color &color)
 
DataNode::Pointer CreateSegmentationNode (Image *image, const std::string &organName, const mitk::Color &color)
 
virtual bool CanHandle (BaseData *referenceData) const
 
- Public Member Functions inherited from mitk::EventStateMachine
virtual std::vector< std::string > GetClassHierarchy () const override
 
virtual const char * GetClassName () const
 
bool LoadStateMachine (const std::string &filename, const us::Module *module=nullptr)
 Loads XML resource. More...
 
bool HandleEvent (InteractionEvent *event, DataNode *dataNode)
 
void EnableUndo (bool enable)
 Enables or disabled Undo. More...
 
void EnableInteraction (bool enable)
 Enables/disables the state machine. In un-enabled state it won't react to any events. More...
 
- Public Member Functions inherited from mitk::InteractionEventHandler
bool SetEventConfig (const std::string &filename, const us::Module *module=nullptr)
 Loads a configuration from an XML resource. More...
 
bool SetEventConfig (const EventConfig &config)
 Loads a configuration from an EventConfig object. More...
 
EventConfig GetEventConfig () const
 Returns the current configuration. More...
 
bool AddEventConfig (const std::string &filename, const us::Module *module=nullptr)
 This method extends the configuration. More...
 
bool AddEventConfig (const EventConfig &config)
 This method extends the configuration. The configuration from the EventConfig object is loaded and only the ones conflicting are replaced by the new one. This way several configurations can be combined. More...
 
- Public Member Functions inherited from mitk::InteractionEventObserver
 InteractionEventObserver ()
 
virtual ~InteractionEventObserver ()
 
void Disable ()
 
void Enable ()
 
bool IsEnabled () const
 

Static Public Member Functions

static bool DetermineAffectedImageSlice (const Image *image, const PlaneGeometry *plane, int &affectedDimension, int &affectedSlice)
 Calculates for a given Image and PlaneGeometry, which slice of the image (in index corrdinates) is meant by the plane. More...
 
static void UpdateSurfaceInterpolation (const Image *slice, const Image *workingImage, const PlaneGeometry *plane, bool detectIntersection)
 Updates the surface interpolation by extracting the contour form the given slice. More...
 
- Static Public Member Functions inherited from mitk::EventStateMachine
static const char * GetStaticNameOfClass ()
 
- Static Public Member Functions inherited from mitk::InteractionEventHandler
static const char * GetStaticNameOfClass ()
 

Protected Member Functions

 SegTool2D ()
 
 SegTool2D (const char *)
 
virtual ~SegTool2D ()
 
virtual bool FilterEvents (InteractionEvent *interactionEvent, DataNode *dataNode) override
 Filters events that cannot be handle by 2D segmentation tools. More...
 
Image::Pointer GetAffectedImageSliceAs2DImage (const InteractionPositionEvent *positionEvent, const Image *image, unsigned int component=0)
 Extract the slice of an image that the user just scribbles on. The given component denotes the vector component of a dwi-image. More...
 
Image::Pointer GetAffectedImageSliceAs2DImage (const PlaneGeometry *planeGeometry, const Image *image, unsigned int timeStep, unsigned int component=0)
 Extract the slice of an image cut by given plane. The given component denotes the vector component of a dwi-image. More...
 
Image::Pointer GetAffectedWorkingSlice (const InteractionPositionEvent *)
 Extract the slice of the currently selected working image that the user just scribbles on. More...
 
Image::Pointer GetAffectedReferenceSlice (const InteractionPositionEvent *)
 Extract the slice of the currently selected reference image that the user just scribbles on. More...
 
void WriteBackSegmentationResult (const InteractionPositionEvent *, Image *)
 
void WriteBackSegmentationResult (const PlaneGeometry *planeGeometry, Image *, unsigned int timeStep)
 
void WriteBackSegmentationResult (std::vector< SliceInformation > sliceList, bool writeSliceToVolume=true)
 
void WritePreviewOnWorkingImage (Image *targetSlice, Image *sourceSlice, Image *workingImage, int paintingPixelValue, int timestep)
 
void WriteSliceToVolume (SliceInformation sliceInfo)
 
int AddContourmarker ()
 Adds a new node called Contourmarker to the datastorage which holds a mitk::PlanarFigure. By selecting this node the slicestack will be reoriented according to the PlanarFigure's Geometry. More...
 
void InteractiveSegmentationBugMessage (const std::string &message)
 
- Protected Member Functions inherited from mitk::Tool
virtual void SetToolManager (ToolManager *)
 
void ConnectActionsAndFunctions () override
 
virtual void Activated ()
 Called when the tool gets activated. More...
 
virtual void Deactivated ()
 Called when the tool gets deactivated. More...
 
 Tool ()
 
 Tool (const char *)
 
virtual ~Tool ()
 
virtual void Notify (InteractionEvent *interactionEvent, bool isHandled) override
 
bool FilterEvents (InteractionEvent *, DataNode *) override
 
- Protected Member Functions inherited from mitk::EventStateMachine
 EventStateMachine ()
 
virtual ~EventStateMachine ()
 
void AddActionFunction (const std::string &action, TActionFunctor *functor)
 
void AddActionFunction (const std::string &action, const ActionFunctionDelegate &delegate)
 
void AddConditionFunction (const std::string &condition, const ConditionFunctionDelegate &delegate)
 
StateMachineStateGetCurrentState () const
 
void ResetToStartState ()
 ResetToStartState Reset state machine to it initial starting state. More...
 
virtual bool CheckCondition (const StateMachineCondition &condition, const InteractionEvent *interactionEvent)
 
virtual void ExecuteAction (StateMachineAction *action, InteractionEvent *interactionEvent)
 
void SetMouseCursor (const char *xpm[], int hotspotX, int hotspotY)
 Sets the specified mouse cursor. More...
 
void ResetMouseCursor ()
 Resets the mouse cursor (if modified by the SlicesCoordinator) to its original state. More...
 
StateMachineTransitionGetExecutableTransition (InteractionEvent *event)
 Returns the executable transition for the given event. More...
 
- Protected Member Functions inherited from mitk::InteractionEventHandler
 InteractionEventHandler ()
 
virtual ~InteractionEventHandler ()
 
PropertyList::Pointer GetAttributes () const
 
std::string MapToEventVariant (InteractionEvent *interactionEvent)
 
virtual void ConfigurationChanged ()
 

Protected Attributes

BaseRendererm_LastEventSender
 
unsigned int m_LastEventSlice
 
- Protected Attributes inherited from mitk::Tool
std::string m_EventConfig
 Let subclasses change their event configuration. More...
 
ToolManagerm_ToolManager
 
- Protected Attributes inherited from mitk::EventStateMachine
bool m_IsActive
 
UndoControllerm_UndoController
 
bool m_UndoEnabled
 

Additional Inherited Members

- Public Types inherited from mitk::Tool
typedef mitk::Label::PixelType DefaultSegmentationDataType
 
- Public Types inherited from mitk::EventStateMachine
typedef EventStateMachine Self
 
typedef InteractionEventHandler Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef std::map< std::string, TActionFunctor * > ActionFunctionsMapType
 
typedef itk::SmartPointer< StateMachineStateStateMachineStateType
 
- Public Types inherited from mitk::InteractionEventHandler
typedef InteractionEventHandler Self
 
typedef itk::Object Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
- Public Attributes inherited from mitk::Tool
Message GUIProcessEventsMessage
 To let GUI process new events (e.g. qApp->processEvents() ) More...
 
Message1< std::string > ErrorMessage
 To send error messages (to be shown by some GUI) More...
 
Message1< bool > CurrentlyBusy
 To send whether the tool is busy (to be shown by some GUI) More...
 
Message1< std::string > GeneralMessage
 To send general messages (to be shown by some GUI) More...
 
- Protected Types inherited from mitk::EventStateMachine
typedef MessageAbstractDelegate2< StateMachineAction *, InteractionEvent *, void > ActionFunctionDelegate
 
typedef MessageAbstractDelegate1< const InteractionEvent *, bool > ConditionFunctionDelegate
 

Detailed Description

Abstract base class for segmentation tools.

See also
Tool

Implements 2D segmentation specific helper methods, that might be of use to all kind of 2D segmentation tools. At the moment these are:

  • Determination of the slice where the user paints upon (DetermineAffectedImageSlice)
  • Projection of a 3D contour onto a 2D plane/slice

SegTool2D tries to structure the interaction a bit. If you pass "PressMoveRelease" as the interaction type of your derived tool, you might implement the methods OnMousePressed, OnMouseMoved, and OnMouseReleased. Yes, your guess about when they are called is correct.

Warning
Only to be instantiated by mitk::ToolManager.

$Author$

Definition at line 58 of file mitkSegTool2D.h.

Constructor & Destructor Documentation

mitk::SegTool2D::SegTool2D ( )
protected
mitk::SegTool2D::SegTool2D ( const char *  type)
protected

Definition at line 63 of file mitkSegTool2D.cpp.

References mitk::Tool::m_EventConfig.

mitk::SegTool2D::~SegTool2D ( )
protectedvirtual

Definition at line 69 of file mitkSegTool2D.cpp.

Member Function Documentation

int mitk::SegTool2D::AddContourmarker ( )
protected
bool mitk::SegTool2D::DetermineAffectedImageSlice ( const Image image,
const PlaneGeometry plane,
int &  affectedDimension,
int &  affectedSlice 
)
static

Calculates for a given Image and PlaneGeometry, which slice of the image (in index corrdinates) is meant by the plane.

Returns
false, if no slice direction seems right (e.g. rotated planes)
Parameters
affectedDimensionThe image dimension, which is constant for all points in the plane, e.g. Axial –> 2
affectedSliceThe index of the image slice

Definition at line 84 of file mitkSegTool2D.cpp.

References mitk::eps, mitk::BaseGeometry::GetAxisVector(), mitk::BaseGeometry::GetCenter(), mitk::Image::GetDimension(), mitk::BaseData::GetGeometry(), mitk::PlaneGeometry::GetNormal(), mitk::SlicedData::GetSlicedGeometry(), MITK_DEBUG, mitk::PlaneGeometry::Project(), ROUND, and mitk::BaseGeometry::WorldToIndex().

Referenced by QmitkSliceBasedInterpolatorWidget::AcceptAllInterpolations(), QmitkSlicesInterpolator::AcceptAllInterpolations(), QmitkSliceBasedInterpolatorWidget::Interpolate(), QmitkSlicesInterpolator::Interpolate(), and QmitkSliceBasedInterpolatorWidget::OnAcceptInterpolationClicked().

bool mitk::SegTool2D::FilterEvents ( InteractionEvent interactionEvent,
DataNode dataNode 
)
overrideprotectedvirtual

Filters events that cannot be handle by 2D segmentation tools.

Current an event is discarded if it was not sent by a 2D renderwindow and if it is not of type InteractionPositionEvent

Reimplemented from mitk::EventStateMachine.

Definition at line 73 of file mitkSegTool2D.cpp.

References mitk::BaseRenderer::GetMapperID(), mitk::InteractionEvent::GetSender(), and mitk::BaseRenderer::Standard2D.

mitk::Image::Pointer mitk::SegTool2D::GetAffectedImageSliceAs2DImage ( const InteractionPositionEvent positionEvent,
const Image image,
unsigned int  component = 0 
)
protected

Extract the slice of an image that the user just scribbles on. The given component denotes the vector component of a dwi-image.

Parameters
componentThe component to be extracted of a given multi-component image. -1 is the default parameter to denote an invalid component.
Returns
'nullptr' if SegTool2D is either unable to determine which slice was affected, or if there was some problem getting the image data at that position.

Definition at line 207 of file mitkSegTool2D.cpp.

References mitk::BaseRenderer::GetCurrentWorldPlaneGeometry(), mitk::InteractionEvent::GetSender(), and mitk::BaseRenderer::GetTimeStep().

Referenced by mitk::PaintbrushTool::CheckIfCurrentSliceHasChanged(), mitk::SetRegionTool::OnMouseReleased(), mitk::ContourTool::OnMouseReleased(), and mitk::CorrectorTool2D::OnMouseReleased().

mitk::Image::Pointer mitk::SegTool2D::GetAffectedImageSliceAs2DImage ( const PlaneGeometry planeGeometry,
const Image image,
unsigned int  timeStep,
unsigned int  component = 0 
)
protected

Extract the slice of an image cut by given plane. The given component denotes the vector component of a dwi-image.

Parameters
componentThe component to be extracted of a given multi-component image. -1 is the default parameter to denote an invalid component.
Returns
'nullptr' if SegTool2D is either unable to determine which slice was affected, or if there was some problem getting the image data at that position.

Definition at line 220 of file mitkSegTool2D.cpp.

References mitk::TimeGeometry::GetGeometryForTimeStep(), mitk::BaseData::GetTimeGeometry(), mitk::New(), and mitk::ExtractSliceFilter::New().

mitk::Image::Pointer mitk::SegTool2D::GetAffectedReferenceSlice ( const InteractionPositionEvent positionEvent)
protected

Extract the slice of the currently selected reference image that the user just scribbles on.

Returns
NULL if SegTool2D is either unable to determine which slice was affected, or if there was some problem getting the image data at that position, or just no reference image is selected.

Definition at line 269 of file mitkSegTool2D.cpp.

Referenced by mitk::RegionGrowingTool::OnMousePressed().

mitk::Image::Pointer mitk::SegTool2D::GetAffectedWorkingSlice ( const InteractionPositionEvent positionEvent)
protected

Extract the slice of the currently selected working image that the user just scribbles on.

Returns
NULL if SegTool2D is either unable to determine which slice was affected, or if there was some problem getting the image data at that position, or just no working image is selected.

Definition at line 252 of file mitkSegTool2D.cpp.

Referenced by mitk::SetRegionTool::OnMousePressed(), and mitk::RegionGrowingTool::OnMousePressed().

void mitk::SegTool2D::InteractiveSegmentationBugMessage ( const std::string &  message)
protected

Definition at line 525 of file mitkSegTool2D.cpp.

References MITK_ERROR.

mitk::SegTool2D::mitkClassMacro ( SegTool2D  ,
Tool   
)
void mitk::SegTool2D::SetEnable3DInterpolation ( bool  enabled)

Enables or disables the 3D interpolation after writing back the 2D segmentation result, and defaults to true.

Definition at line 440 of file mitkSegTool2D.cpp.

Referenced by QmitkSurfaceBasedInterpolatorWidget::OnToggleWidgetActivation().

void mitk::SegTool2D::SetShowMarkerNodes ( bool  status)

Definition at line 435 of file mitkSegTool2D.cpp.

void mitk::SegTool2D::UpdateSurfaceInterpolation ( const Image slice,
const Image workingImage,
const PlaneGeometry plane,
bool  detectIntersection 
)
static

Updates the surface interpolation by extracting the contour form the given slice.

Parameters
slicethe slice from which the contour should be extracted
workingImagethe segmentation image
planethe plane in which the slice lies
detectIntersectionif true the slice is eroded before contour extraction. If the slice is empty after the erosion it is most likely an intersecting contour an will not be added to the SurfaceInterpolationController

Definition at line 149 of file mitkSegTool2D.cpp.

References mitk::SurfaceInterpolationController::AddNewContour(), mitk::MorphologicalOperations::Ball, mitk::Image::Clone(), mitk::SurfaceInterpolationController::ContourPositionInformation::contourNormal, mitk::SurfaceInterpolationController::ContourPositionInformation::contourPoint, mitk::MorphologicalOperations::Erode(), mitk::SurfaceInterpolationController::GetInstance(), mitk::PlaneGeometry::GetNormal(), mitk::BaseGeometry::GetOrigin(), mitk::ImageTimeSelector::New(), mitk::ImageToContourFilter::New(), and mitk::SurfaceInterpolationController::RemoveContour().

Referenced by mitk::DiffSliceOperationApplier::ExecuteOperation().

void mitk::SegTool2D::WriteBackSegmentationResult ( const InteractionPositionEvent positionEvent,
Image slice 
)
protected
void mitk::SegTool2D::WriteBackSegmentationResult ( const PlaneGeometry planeGeometry,
Image slice,
unsigned int  timeStep 
)
protected
void mitk::SegTool2D::WritePreviewOnWorkingImage ( Image targetSlice,
Image sourceSlice,
mitk::Image workingImage,
int  paintingPixelValue,
int  timestep 
)
protected

Member Data Documentation

BaseRenderer* mitk::SegTool2D::m_LastEventSender
protected

Definition at line 183 of file mitkSegTool2D.h.

unsigned int mitk::SegTool2D::m_LastEventSlice
protected

Definition at line 184 of file mitkSegTool2D.h.


The documentation for this class was generated from the following files: