NifTK
16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
|
Provides the MIDAS general purpose, Irregular Volume Editor functionality originally developed at the Dementia Research Centre UCL (http://dementia.ion.ucl.ac.uk/). More...
Public Member Functions | |
GeneralSegmentorController (IBaseView *view) | |
virtual | ~GeneralSegmentorController () |
virtual void | SetupGUI (QWidget *parent) override |
Sets up the GUI. This function has to be called from the CreateQtPartControl function of the view. More... | |
virtual bool | SelectSeedTool () override |
Select the seed tool, where in MIDAS this is the S key. More... | |
virtual bool | SelectDrawTool () override |
Select the draw tool, where in MIDAS this is the D key. More... | |
virtual bool | UnselectTools () override |
Unselect all tools, where in MIDAS is equivalent to selecting the Posn tool, which is Space or N. More... | |
virtual bool | SelectPolyTool () override |
Select the poly tool, where in MIDAS this is the Y key. More... | |
virtual bool | SelectViewMode () override |
Select the view mode, where in MIDAS this is the V key. More... | |
virtual bool | CleanSlice () override |
Clean the slice, where in MIDAS this is the C key. More... | |
virtual void | ExecuteOperation (mitk::Operation *operation) override |
Method to enable this class to interact with the Undo/Redo framework. More... | |
Public Member Functions inherited from niftk::BaseSegmentorController | |
BaseSegmentorController (IBaseView *view) | |
virtual | ~BaseSegmentorController () |
mitk::ToolManager * | GetToolManager () const |
Returns the segmentation tool manager used by the segmentor. More... | |
template<class ToolType > | |
ToolType * | GetToolByType () |
virtual bool | EventFilter (const mitk::StateEvent *stateEvent) const override |
Returns true if the event should be filtered, i.e. not processed, otherwise false. More... | |
virtual bool | EventFilter (mitk::InteractionEvent *event) const override |
Returns true if the event should be filtered, i.e. not processed, otherwise false. More... | |
const QColor & | GetDefaultSegmentationColour () const |
Default colour to be displayed in the new segmentation dialog box. More... | |
void | SetDefaultSegmentationColour (const QColor &defaultSegmentationColour) |
Default colour to be displayed in the new segmentation dialog box. More... | |
virtual void | OnViewGetsActivated () override |
Called when the BlueBerry view that hosts the GUI for this controller gets activated. More... | |
Public Member Functions inherited from niftk::BaseController | |
BaseController (IBaseView *view) | |
Constructs a BaseController object. More... | |
virtual | ~BaseController () |
Destructs the BaseController object. More... | |
ImageOrientation | GetOrientation () const |
Returns the orientation of the selected render window. Returns IMAGE_ORIENTATION_UNKNOWN if no window is selected or the selected window is a 3D window. More... | |
int | GetSliceIndex () const |
Returns the index of the displayed slice in the currently selected window. Returns -1 if no window is selected or the selected window is a 3D window. More... | |
mitk::Point3D | GetSelectedPosition () const |
Returns the selected position in the current editor (render window part). The selected position is the voxel at the intersection of the crosshair planes. More... | |
virtual void | OnViewGetsDeactivated () |
Called when the BlueBerry view that hosts the GUI for this controller gets deactivated. More... | |
Public Member Functions inherited from niftk::StateMachineEventFilter | |
mitkClassMacroNoParent (StateMachineEventFilter) StateMachineEventFilter() | |
virtual | ~StateMachineEventFilter () |
Public Member Functions inherited from niftk::ToolKeyPressResponder | |
ToolKeyPressResponder () | |
virtual | ~ToolKeyPressResponder () |
Protected Slots | |
virtual void | OnNewSegmentationButtonClicked () override |
Qt slot called when the user hits the button "New segmentation", creating new working data such as a region growing image, contour objects to store contour lines that we are drawing, and seeds for region growing. More... | |
void | OnSeePriorCheckBoxToggled (bool checked) |
Qt slot called from "see prior" checkbox to show the contour from the previous slice. More... | |
void | OnSeeNextCheckBoxToggled (bool checked) |
Qt slot called from "see next" checkbox to show the contour from the next slice. More... | |
void | OnCleanButtonClicked () |
Qt slot called when the Clean button is pressed, indicating the current contours on the current slice should be cleaned, see additional spec, currently at: https://cmiclab.cs.ucl.ac.uk/CMIC/NifTK/issues/1096. More... | |
void | OnWipeButtonClicked () |
Qt slot called when the Wipe button is pressed and will erase the current slice and seeds on the current slice. More... | |
void | OnWipePlusButtonClicked () |
Qt slot called when the Wipe+ button is pressed and will erase the whole region Anterior/Superior/Right from the current slice, including seeds. More... | |
void | OnWipeMinusButtonClicked () |
Qt slot called when the Wipe- button is pressed and will erase the whole region Posterior/Inferior/Left from the current slice, including seeds. More... | |
void | OnPropagateUpButtonClicked () |
Qt slot called when the Propagate Up button is pressed to take the current seeds and threshold values, and propagate Anterior/Superior/Right. More... | |
void | OnPropagateDownButtonClicked () |
Qt slot called when the Propagate Down button is pressed to take the current seeds and threshold values, and propagate Posterior/Inferor/Left. More... | |
void | OnPropagate3DButtonClicked () |
Qt slot called when the Propagate 3D button is pressed that is effectively equivalent to calling OnPropagateUpButtonPressed and OnPropagateDownButtonPressed. More... | |
void | OnThresholdApplyButtonClicked () |
Qt slot called when the Apply button is pressed and used to accept the current region growing segmentation, and recalculates seed positions as per MIDAS spec described in this class intro. More... | |
void | OnThresholdingCheckBoxToggled (bool checked) |
Qt slot called when the "threshold" checkbox is checked, and toggles the thresholding widget section on and calls GeneralSegmentorController::UpdateRegionGrowing. More... | |
void | OnThresholdValueChanged () |
Qt slot called when the lower or upper threshold slider is moved, calls GeneralSegmentorController::UpdateRegionGrowing as thresholds have changed. More... | |
void | OnAnyButtonClicked () |
Qt slot called when the any button is pressed on this widget. More... | |
void | OnOKButtonClicked () |
Qt slot called when the OK button is pressed and accepts the current segmentation, destroying the working data (seeds, contours, region growing image), leaving you with a finished segmentation. More... | |
void | OnResetButtonClicked () |
Qt slot called when the Reset button is pressed and resets to the start of the segmentation, so wipes the current segmentation (no undo), but leaves the reference data so you can continue segmenting. More... | |
void | OnCancelButtonClicked () |
Qt slot called when the Cancel button is pressed and destroys all working data (seeds, contours, region growing image), and also destroys the current segmentation if it was created by this volume editor. Otherwise, it restores the original segmentation. More... | |
void | OnRestartButtonClicked () |
Qt slot called when the Restart button is pressed and restores the initial state of the segmentation. More... | |
Protected Slots inherited from niftk::BaseSegmentorController | |
virtual void | OnNewSegmentationButtonClicked ()=0 |
Called from niftkSegmentationSelectorWidget when the 'Start/restart segmentation' button is clicked. More... | |
Protected Member Functions | |
virtual bool | IsASegmentationImage (const mitk::DataNode::Pointer node) override |
For Irregular Volume Editing, a Segmentation image should have a grey scale parent, and several children as described in the class introduction. More... | |
virtual std::vector < mitk::DataNode * > | GetWorkingDataFromSegmentationNode (const mitk::DataNode::Pointer node) override |
Assumes input is a valid segmentation node, then searches for the derived children of the node, looking for the seeds and contours as described in the class introduction. More... | |
virtual bool | CanStartSegmentationForBinaryNode (const mitk::DataNode::Pointer node) override |
We return true if the segmentation can be "re-started", i.e. you switch between binary images in the DataManager, and if the binary image has the correct hidden child nodes, then this returns true, indicating that it's a valid "in-progress" segmentation. More... | |
virtual BaseGUI * | CreateGUI (QWidget *parent) override |
Creates the general segmentor widget that holds the GUI components of the view. More... | |
virtual void | OnNodeVisibilityChanged (const mitk::DataNode *node, const mitk::BaseRenderer *renderer) override |
Called when the visibility of a data node in the data storage has changed. The renderer is nullptr if the global visibility has changed. Empty implementation. Derived classes can override it. More... | |
virtual void | OnSelectedSliceChanged (ImageOrientation orientation, int sliceIndex) override |
Called when the different slice gets selected in the viewer. This happens when a different renderer is selected or when the selected slice changes in the focused renderer either by interaction (e.g. scrolling by mouse wheel) or by API call. When the orientation changes, this function makes sure ITK pipelines know about that. Changing the selected slice in MIDAS terms means automatically accepting the currently segmented slice and moving to the next one, see class intro. More... | |
Protected Member Functions inherited from niftk::BaseSegmentorController | |
virtual void | OnActiveToolChanged () |
Called from niftkToolSelectorWidget when a tool changes. More... | |
std::vector< mitk::DataNode * > | GetWorkingData () |
Gets a vector of the working data nodes registered with the tool manager. The data nodes normally hold image, but could be surfaces etc. Empty list is returned if this can't be found. More... | |
mitk::Image * | GetWorkingImage (int index) |
Gets a single binary image registered with the ToolManager. Returns nullptr if it can't be found or is not an image. More... | |
mitk::DataNode * | GetReferenceNode () |
Gets the reference node from the tool manager or nullptr if it can't be found. More... | |
mitk::Image * | GetReferenceImage () |
Gets the reference image from the tool manager, or nullptr if this doesn't yet exist or is not an image. Assumes that a reference (grey scale) image is always registered with the tool manager. More... | |
mitk::DataNode * | FindReferenceNodeFromSegmentationNode (const mitk::DataNode::Pointer segmentationNode) |
Gets the reference node that the segmentation node belongs to. Assumes that the reference (grey scale) node is always the direct parent of the segmentation (binary) node, so we simply search for a non binary parent. More... | |
void | SetReferenceImageSelected () |
Makes sure the reference image is the selected one. More... | |
virtual bool | IsAReferenceImage (const mitk::DataNode::Pointer node) |
Returns true if node represent an image that is non binary, and false otherwise. More... | |
virtual bool | IsAWorkingImage (const mitk::DataNode::Pointer node) |
Returns true if node represents an image that is binary, and false otherwise. More... | |
virtual mitk::DataNode * | GetSegmentationNodeFromWorkingData (const mitk::DataNode::Pointer node) |
Assumes that a Working Node == a Segmentation Node, so simply returns the input node. More... | |
virtual void | ApplyDisplayOptions (mitk::DataNode *node) |
Decorates a DataNode according to the user preference settings, or requirements for binary images. More... | |
int | GetReferenceImageSliceAxis () |
Returns which image coordinate corresponds to the currently selected orientation. Retrieves the currently active QmitkRenderWindow, and the reference image registered with the ToolManager, and returns the Image axis that the current view is looking along, or -1 if it can not be worked out. More... | |
int | GetReferenceImageSliceAxis (ImageOrientation orientation) |
Returns which image coordinate corresponds to the given orientation. Looks up the ReferenceImage registered with ToolManager and returns the axis [0,1,2] that corresponds to the given orientation, or -1 if it can't be found. More... | |
int | GetReferenceImageSliceIndex () |
Returns the slice index in the reference image that corresponds to the currently displayed slice. This might be different to the slice displayed in the viewer, depending on the up direction. More... | |
int | GetReferenceImageSliceUpDirection () |
Returns the "Up" direction which is the anterior, superior or right direction depending on which orientation you are interested in. More... | |
virtual mitk::DataNode * | CreateNewSegmentation () |
Creates from derived classes when the the user hits the "New segmentation", producing a dialog box, and on successful completion of the dialog box, will create a new segmentation image. More... | |
BaseSegmentorGUI * | GetSegmentorGUI () const |
Gets the segmentor widget that holds the GUI components of the view. More... | |
bool | HasInitialisedWorkingData () |
Utility method to check that we have initialised all the working data such as contours, region growing images etc. More... | |
virtual void | OnDataManagerSelectionChanged (const QList< mitk::DataNode::Pointer > &nodes) |
Called when the selection changes in the data manager. More... | |
Protected Member Functions inherited from niftk::BaseController | |
mitk::DataStorage * | GetDataStorage () const |
void | RequestRenderWindowUpdate () const |
QList< mitk::DataNode::Pointer > | GetDataManagerSelection () const |
mitk::SliceNavigationController * | GetSliceNavigationController () const |
BaseGUI * | GetGUI () const |
Gets the widget that holds the GUI components of the view. More... | |
IBaseView * | GetView () const |
Gets the segmentor BlueBerry view. More... | |
virtual void | OnFocusChanged () |
Called when the window focus changes, and tracks the current mitk::BaseRenderer*. More... | |
virtual mitk::BaseRenderer * | GetFocused2DRenderer () const |
Returns the currently focused renderer, as this class is tracking the focus changes. More... | |
virtual void | OnNodeAdded (const mitk::DataNode *node) |
Called when a data node is added to the data storage. Empty implementation. Derived classes can override it. More... | |
virtual void | OnNodeDeleted (const mitk::DataNode *node) |
Called when a data node has been deleted that has previously been in the data storage. Empty implementation. Derived classes can override it. More... | |
void | WaitCursorOn () |
Convenient method to set and reset a wait cursor ("hourglass") More... | |
void | WaitCursorOff () |
Convenient method to restore the standard cursor. More... | |
void | BusyCursorOn () |
Convenient method to set and reset a busy cursor. More... | |
void | BusyCursorOff () |
Convenient method to restore the standard cursor. More... | |
Provides the MIDAS general purpose, Irregular Volume Editor functionality originally developed at the Dementia Research Centre UCL (http://dementia.ion.ucl.ac.uk/).
This class uses the mitk::ToolManager and associated framework described in this paper on the MITK Segmentation framework.
The mitk::ToolManager has the following data sets registered in this order.
0. mitk::Image = the image being segmented, i.e. The Output. 1. mitk::PointSet = the seeds for region growing, noting that the seeds are in 3D, spreading throughout the volume. 2. mitk::ContourModelSet = a set of contours for the current slice being edited - representing the current segmentation, i.e. green lines in MIDAS, but drawn here in orange. 3. mitk::ContourModelSet = a set of contours specifically for the draw tool, i.e. also green lines in MIDAS, and also drawn here in orange. 4. mitk::ContourModelSet = a set of contours for the prior slice, i.e. whiteish lines in MIDAS. 5. mitk::ContourModelSet = a set of contours for the next slice, i.e. turquoise blue lines in MIDAS. 6. mitk::Image = binary image, same size as item 0, to represent the current region growing, i.e. blue lines in MIDAS.
Useful notes towards helping the understanding of this class
Additionally, significant bits of functionality include:
The number of seeds for a slice often needs re-computing. This is often because a slice has been automatically propagated, and hence we need new seeds for each slice because as you scroll through slices, regions without a seed would be wiped. For a given slice, the seeds are set so that each disjoint (i.e. not 4-connected) region will have its own seed at the largest minimum distance from the edge, scanning only in a vertical or horizontal direction. In other words, for an image containing a single region:
Find the first voxel in the image, best voxel location = current voxel location, and best distance = maximum number of voxels along an image slice axis. For each voxel Scan +x, -x, +y, -y and measure the minimum distance to the boundary If minimum distance > best distance best voxel location = current voxel location best distance = minimum distance
The result is the largest minimum distance, or the largest minimum distance to an edge, noting that we are not scanning diagonally.
Propagate runs a 3D region propagation from and including the current slice up/down, writing the output to the current segmentation volume, overwriting anything already there. The current slice is always affected. So, you can leave the threshold tick box either on or off. For each subsequent slice in the up/down direction, the number of seeds is recomputed (as above). 3D propagation is exactly equivalent to clicking "prop up" followed by "prop down". Here, note that in 3D, you would normally do region growing in a 6-connected neighbourhood. Here, we are doing a 5D connected neighbourhood, as you always propagate forwards in one direction. i.e. in a coronal slice, and selecting "propagate up", which means propagate anterior, then you cannot do region growing in the posterior direction. So its a 5D region growing.
The threshold "apply" button is only enabled when the threshold check-box is enabled, and disabled otherwise. The current segmentation, draw tool contours and poly tool contours (eg. WorkingData items 2 and 3, plus temporary data in the PolyTool) all limit the region growing.
When we hit "apply":
1. Takes the current region growing image, and writes it to the current image. 2. Recalculate the number of seeds for that slice, 1 per disjoint region, as above. 3. Turn off thresholding, leaving sliders at current value.
All three pieces of functionality appear similar, wiping the whole slice, whole anterior region, or whole posterior region, including all segmentation and seeds. The threshold controls are not changed. So, if it was on before, it will be on afterwards.
The "retain marks" functionality only has an impact if we change slices. When the "retain marks" checkbox is ticked, and we change slices we:
1. Check if the new slice is empty. 2. If not empty we warn. 3. If the user elects to overwrite the new slice, we simply copy all seeds and all image data to the new slice.
niftk::GeneralSegmentorController::GeneralSegmentorController | ( | IBaseView * | view | ) |
|
virtual |
|
overrideprotectedvirtual |
We return true if the segmentation can be "re-started", i.e. you switch between binary images in the DataManager, and if the binary image has the correct hidden child nodes, then this returns true, indicating that it's a valid "in-progress" segmentation.
Implements niftk::BaseSegmentorController.
|
overridevirtual |
Clean the slice, where in MIDAS this is the C key.
Note: see comment in SelectSeedTool().
Implements niftk::ToolKeyPressResponder.
|
overrideprotectedvirtual |
Creates the general segmentor widget that holds the GUI components of the view.
Implements niftk::BaseController.
|
overridevirtual |
Method to enable this class to interact with the Undo/Redo framework.
|
overrideprotectedvirtual |
Assumes input is a valid segmentation node, then searches for the derived children of the node, looking for the seeds and contours as described in the class introduction.
Reimplemented from niftk::BaseSegmentorController.
|
overrideprotectedvirtual |
For Irregular Volume Editing, a Segmentation image should have a grey scale parent, and several children as described in the class introduction.
Reimplemented from niftk::BaseSegmentorController.
|
protectedslot |
Qt slot called when the any button is pressed on this widget.
It transfers the focus back to the main window so that the key interactions keep working.
Set the focus back to the main window. This is needed so that the keyboard shortcuts (like 'a' and 'z' for changing slice) keep on working.
|
protectedslot |
Qt slot called when the Cancel button is pressed and destroys all working data (seeds, contours, region growing image), and also destroys the current segmentation if it was created by this volume editor. Otherwise, it restores the original segmentation.
|
protectedslot |
Qt slot called when the Clean button is pressed, indicating the current contours on the current slice should be cleaned, see additional spec, currently at: https://cmiclab.cs.ucl.ac.uk/CMIC/NifTK/issues/1096.
|
overrideprotectedvirtualslot |
Qt slot called when the user hits the button "New segmentation", creating new working data such as a region growing image, contour objects to store contour lines that we are drawing, and seeds for region growing.
Note: The 'new segmentation' button is enabled only when a reference image is selected. A reference image gets selected when the selection in the data manager changes to a valid reference image or a segmentation that was created by this segmentor. Hence, we can assume that we have a valid tool manager, paintbrush tool and reference image.
Create the new segmentation, either using a previously selected one, or create a new volume.
TODO We should not refer to mitk::RenderingManager::GetInstance() because the DnD display uses its own rendering manager, not this one, like the MITK display.
|
overrideprotectedvirtual |
Called when the visibility of a data node in the data storage has changed. The renderer is nullptr if the global visibility has changed. Empty implementation. Derived classes can override it.
Reimplemented from niftk::BaseController.
|
protectedslot |
Qt slot called when the OK button is pressed and accepts the current segmentation, destroying the working data (seeds, contours, region growing image), leaving you with a finished segmentation.
Apply the thresholds if we are thresholding, and chunk out the contour segments that do not close any region with seed.
|
protectedslot |
Qt slot called when the Propagate 3D button is pressed that is effectively equivalent to calling OnPropagateUpButtonPressed and OnPropagateDownButtonPressed.
|
protectedslot |
Qt slot called when the Propagate Down button is pressed to take the current seeds and threshold values, and propagate Posterior/Inferor/Left.
|
protectedslot |
Qt slot called when the Propagate Up button is pressed to take the current seeds and threshold values, and propagate Anterior/Superior/Right.
|
protectedslot |
Qt slot called when the Reset button is pressed and resets to the start of the segmentation, so wipes the current segmentation (no undo), but leaves the reference data so you can continue segmenting.
|
protectedslot |
Qt slot called when the Restart button is pressed and restores the initial state of the segmentation.
|
protectedslot |
Qt slot called from "see next" checkbox to show the contour from the next slice.
|
protectedslot |
Qt slot called from "see prior" checkbox to show the contour from the previous slice.
|
overrideprotectedvirtual |
Called when the different slice gets selected in the viewer. This happens when a different renderer is selected or when the selected slice changes in the focused renderer either by interaction (e.g. scrolling by mouse wheel) or by API call. When the orientation changes, this function makes sure ITK pipelines know about that. Changing the selected slice in MIDAS terms means automatically accepting the currently segmented slice and moving to the next one, see class intro.
orientation | the orientation of the selected slice It might not equal to the axis of the slice in the reference image. This depends on the permutation of the axes. |
sliceIndex | the index of the slice in the renderer (world space) It might not equal to the index of the slice in the reference image. This depends on the 'up direction' of the axis. |
This makes the poly tool save its result to the working data nodes and stay it open.
Reimplemented from niftk::BaseController.
|
protectedslot |
Qt slot called when the Apply button is pressed and used to accept the current region growing segmentation, and recalculates seed positions as per MIDAS spec described in this class intro.
|
protectedslot |
Qt slot called when the "threshold" checkbox is checked, and toggles the thresholding widget section on and calls GeneralSegmentorController::UpdateRegionGrowing.
|
protectedslot |
Qt slot called when the lower or upper threshold slider is moved, calls GeneralSegmentorController::UpdateRegionGrowing as thresholds have changed.
|
protectedslot |
Qt slot called when the Wipe button is pressed and will erase the current slice and seeds on the current slice.
|
protectedslot |
Qt slot called when the Wipe- button is pressed and will erase the whole region Posterior/Inferior/Left from the current slice, including seeds.
|
protectedslot |
Qt slot called when the Wipe+ button is pressed and will erase the whole region Anterior/Superior/Right from the current slice, including seeds.
|
overridevirtual |
Select the draw tool, where in MIDAS this is the D key.
Note: see comment in SelectSeedTool().
Implements niftk::ToolKeyPressResponder.
|
overridevirtual |
Select the poly tool, where in MIDAS this is the Y key.
Note: see comment in SelectSeedTool().
Implements niftk::ToolKeyPressResponder.
|
overridevirtual |
Select the seed tool, where in MIDAS this is the S key.
Note: If the tool selection box is disabled then the tools are not registered to the tool manager ( RegisterClient() ). Then if you activate a tool and another tool was already active, then its interaction event observer service tries to be unregistered. But since the tools was not registered into the tool manager, the observer service is still null, and the attempt to unregister it causes crash.
Consequence: We should not do anything with the tools until they are registered to the tool manager.
Implements niftk::ToolKeyPressResponder.
|
overridevirtual |
Select the view mode, where in MIDAS this is the V key.
Note: see comment in SelectSeedTool().
Implements niftk::ToolKeyPressResponder.
|
overridevirtual |
Sets up the GUI. This function has to be called from the CreateQtPartControl function of the view.
Transfer the focus back to the main window if any button is pressed. This is needed so that the key interactions (like 'a'/'z' for changing slice) keep working.
Reimplemented from niftk::BaseSegmentorController.
|
overridevirtual |
Unselect all tools, where in MIDAS is equivalent to selecting the Posn tool, which is Space or N.
Implements niftk::ToolKeyPressResponder.