Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
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 (const 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 *, const us::Module *interactorModule=nullptr)
 
 ~SegTool2D () override
 
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 (const std::vector< SliceInformation > &sliceList, bool writeSliceToVolume=true)
 
void WritePreviewOnWorkingImage (Image *targetSlice, Image *sourceSlice, Image *workingImage, int paintingPixelValue, int timestep)
 
void WriteSliceToVolume (const 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 *, const us::Module *interactorModule=nullptr)
 
 ~Tool () override
 
void Notify (InteractionEvent *interactionEvent, bool isHandled) override
 
bool FilterEvents (InteractionEvent *, DataNode *) override
 
- Protected Member Functions inherited from mitk::EventStateMachine
 EventStateMachine ()
 
 ~EventStateMachine () override
 
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 ()
 
 ~InteractionEventHandler () override
 
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 54 of file mitkSegTool2D.h.

Constructor & Destructor Documentation

◆ SegTool2D() [1/2]

mitk::SegTool2D::SegTool2D ( )
protected

◆ SegTool2D() [2/2]

mitk::SegTool2D::SegTool2D ( const char *  type,
const us::Module interactorModule = nullptr 
)
protected

Definition at line 59 of file mitkSegTool2D.cpp.

References mitk::Tool::m_EventConfig.

◆ ~SegTool2D()

mitk::SegTool2D::~SegTool2D ( )
overrideprotected

Definition at line 65 of file mitkSegTool2D.cpp.

Member Function Documentation

◆ AddContourmarker()

◆ DetermineAffectedImageSlice()

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 80 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().

◆ FilterEvents()

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 69 of file mitkSegTool2D.cpp.

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

◆ GetAffectedImageSliceAs2DImage() [1/2]

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 203 of file mitkSegTool2D.cpp.

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

Referenced by mitk::PaintbrushTool::CheckIfCurrentSliceHasChanged(), mitk::LiveWireTool2D::ConfirmSegmentation(), mitk::FastMarchingTool::ConfirmSegmentation(), GetAffectedReferenceSlice(), GetAffectedWorkingSlice(), mitk::SetRegionTool::OnMouseReleased(), mitk::ContourTool::OnMouseReleased(), mitk::CorrectorTool2D::OnMouseReleased(), and WriteSliceToVolume().

◆ GetAffectedImageSliceAs2DImage() [2/2]

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 216 of file mitkSegTool2D.cpp.

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

◆ GetAffectedReferenceSlice()

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
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, or just no reference image is selected.

Definition at line 265 of file mitkSegTool2D.cpp.

References GetAffectedImageSliceAs2DImage(), mitk::ToolManager::GetReferenceData(), and mitk::Tool::m_ToolManager.

Referenced by mitk::FastMarchingTool::BuildITKPipeline(), mitk::LiveWireTool2D::ClearSegmentation(), and mitk::RegionGrowingTool::OnMousePressed().

◆ GetAffectedWorkingSlice()

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
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, or just no working image is selected.

Definition at line 248 of file mitkSegTool2D.cpp.

References GetAffectedImageSliceAs2DImage(), mitk::ToolManager::GetWorkingData(), and mitk::Tool::m_ToolManager.

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

◆ InteractiveSegmentationBugMessage()

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

Definition at line 521 of file mitkSegTool2D.cpp.

References MITK_ERROR.

◆ mitkClassMacro()

mitk::SegTool2D::mitkClassMacro ( SegTool2D  ,
Tool   
)

◆ SetEnable3DInterpolation()

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 436 of file mitkSegTool2D.cpp.

Referenced by QmitkSurfaceBasedInterpolatorWidget::OnToggleWidgetActivation().

◆ SetShowMarkerNodes()

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

Definition at line 431 of file mitkSegTool2D.cpp.

◆ UpdateSurfaceInterpolation()

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 145 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(), and WriteBackSegmentationResult().

◆ WriteBackSegmentationResult() [1/3]

◆ WriteBackSegmentationResult() [2/3]

void mitk::SegTool2D::WriteBackSegmentationResult ( const PlaneGeometry planeGeometry,
Image slice,
unsigned int  timeStep 
)
protected

◆ WriteBackSegmentationResult() [3/3]

◆ WritePreviewOnWorkingImage()

void mitk::SegTool2D::WritePreviewOnWorkingImage ( Image targetSlice,
Image sourceSlice,
mitk::Image workingImage,
int  paintingPixelValue,
int  timestep 
)
protected

◆ WriteSliceToVolume()

Member Data Documentation

◆ m_LastEventSender

◆ m_LastEventSlice


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