Image Viewer¶
GUI Image Viewer
This file contains a collection of functions relevant to defining the image and visualization properties of the GUI.
- Attributes:
- cross (np.array): Array defining the shape of the kernel for the cross brush dot (np.array): Array defining the shape of the kernel for the dot brush rubber (np.array): Array defining the shape of the kernel for the rubber
- Usage:
To use this module, import it and instantiate is as you wish:
from Paint4Brains.GUI.ImageViewer import ImageViewer
window = ImageViewer(parameters)
-
class
Paint4Brains.GUI.ImageViewer.ImageViewer(brain, parent=None)¶ ImageViewer class for Paint4Brains.
This class contains the implementation of a series of functions required for the GUI of the Paint4Brains project.
- Args:
- brain (class): BrainData class for Paint4Brains parent (class): Base or parent class
-
bonus_brush()¶ Allows the user to design their own brush
This opens a window in which the user can design a brush by using the pen and rubber.
-
disable_drawing()¶ Deactivates drawing mode
It does this by deactivating the drawing kernel and setting the value of the drawing parameter in the modified view box to False.
Sets the drawing mode to DOT
This is basically a square of one voxel in size with value one. For all the editing buttons the matrix used to edit is defined at the top of the file
Sets the drawing mode to RUBBER
This is basically a square of one voxel in size with value one. For all the editing buttons the matrix used to edit is defined at the top of the file Removes the label from voxels.
Sets the drawing mode to BRUSH (or cross)
This sets the paintbrush to a cross of 3x3 voxels in size. For all the editing buttons the matrix used to edit is defined at the top of the file
-
enable_drawing()¶ Activates drawing mode
The default pen is a voxel in size.
-
mouseReleaseEvent(ev)¶ Mouse event tracker
This function keeps track of the actions performed by the mouse, while taking the selcted mode into account. If when select_mode is activated, the left button is released on a previously labeled area, then the pen is set to that label. Otherwise, everything should work as normal (the default) Now when you release the left button it assumes an edit has been made and stores it into the BrainData.
- Args:
- ev: signal emitted when user releases a mouse button.
-
new_brush()¶ Sets the drawing mode to the user designed BRUSH (or bonus_brush)
This sets the paintbrush to a user defined brush.
-
next_label()¶ Label forward scroll
Brings the next label in the list to be edited Lets you iterate through all existing labels
-
previous_label()¶ Label backward scroll
Brings the previous label in the list to be edited Lets you iterate through all existing labels
-
recenter()¶ Brain Recenter
Recenter the brain into the middle of the image viewer. The implementation may seem weird, but this is a predefined action by PyQt5.
-
redo_previous_edit()¶ Redo function
This function re-does a previously reverted actions.
-
refresh_image()¶ Image Refresher
Sets the images displayed by the Image viewer to the current data slices. It will only show all the labels if the self.see_all_labels parameters is True.
-
select_label()¶ Select label of interest
Allows the user to select the location of the label to be edited next. Will only have effect if there are multiple labels from which to select The bulk of the implementation for this method is in the modified mouseReleasEevent method
-
undo_previous_edit()¶ Undo function
This function reverts the previous user action and refreshes the image.
-
update_colormap()¶ Label Colormap Update
Updates the colormap to account for the current number of distinct labels. There are only 12 distinct colours (not including the “invisible” colour)
-
view_back_labels()¶ Toggle all/single label.
Switch that determines whether all segmented areas are visible or just one. If see_all_labels was False, it makes all labels visible. If it was True it makes all labels except the one the user is currently editing invisible.
-
wheelEvent(ev)¶ Overwriting the wheel functionality.
If you scroll it will move along slices. If you scroll while holding the Ctrl button, it will zoom in and out
- Args:
- ev: signal emitted when user releases scrolls the wheel.