SlicerDevelopmentToolboxUtils package¶
Subpackages¶
SlicerDevelopmentToolboxUtils.buttons module¶
SlicerDevelopmentToolboxUtils.constants module¶
-
class
SlicerDevelopmentToolboxUtils.constants.
DICOMTAGS
¶ -
ACQUISITION_TIME
= '0008,0032'¶
-
INSTANCE_NUMBER
= '0020,0013'¶
-
PATIENT_BIRTH_DATE
= '0010,0030'¶
-
PATIENT_ID
= '0010,0020'¶
-
PATIENT_NAME
= '0010,0010'¶
-
SERIES_DESCRIPTION
= '0008,103E'¶
-
SERIES_NUMBER
= '0020,0011'¶
-
STUDY_DATE
= '0008,0020'¶
-
STUDY_ID
= '0020,0010'¶
-
STUDY_TIME
= '0008,0030'¶
-
-
class
SlicerDevelopmentToolboxUtils.constants.
FileExtension
¶ Bases:
object
-
FCSV
= '.fcsv'¶
-
H5
= '.h5'¶
-
NRRD
= '.nrrd'¶
-
TXT
= '.TXT'¶
-
VTK
= '.vtk'¶
-
-
class
SlicerDevelopmentToolboxUtils.constants.
STYLE
¶ -
GRAY_BACKGROUND
= 'background-color: gray;'¶
-
GREEN_BACKGROUND
= 'background-color: green;'¶
-
LIGHT_GRAY_BACKGROUND
= 'background-color: rgb(230,230,230)'¶
-
ORANGE_BACKGROUND
= 'background-color: rgb(255,102,0)'¶
-
RED_BACKGROUND
= 'background-color: red;'¶
-
WHITE_BACKGROUND
= 'background-color: rgb(255,255,255)'¶
-
YELLOW_BACKGROUND
= 'background-color: yellow;'¶
-
SlicerDevelopmentToolboxUtils.decorators module¶
-
class
SlicerDevelopmentToolboxUtils.decorators.
MultiMethod
(name)¶ Helper class for keeping track of multimethod decorated methods
See Also: http://www.artima.com/weblogs/viewpost.jsp?thread=101605
-
register
(types, func)¶
-
-
SlicerDevelopmentToolboxUtils.decorators.
beforeRunProcessEvents
(func)¶ Before running the decorated function slicer.app.processEvents() will be executed
-
SlicerDevelopmentToolboxUtils.decorators.
callCount
(level=10)¶ This decorator is useful for debugging purposes where one wants to know the call count of the decorated function.
-
class
SlicerDevelopmentToolboxUtils.decorators.
classproperty
(fget)¶ Bases:
object
This decorator enables adding properties to classes that can be called without instantiating an object
See Also: https://stackoverflow.com/a/13624858
-
class
SlicerDevelopmentToolboxUtils.decorators.
logmethod
(level=10)¶ Bases:
object
This decorator can be used for logging methods without the need of reimplementing log messages over and over again.
The decorator logs information about the called method name including caller and arguments.
from SlicerDevelopmentToolboxUtils.decorators import logmethod @logmethod() def sub(x,y, switch=False): return x -y if not switch else y-x @logmethod(level=logging.INFO) def sub(x,y, switch=False): return x -y if not switch else y-x
-
SlicerDevelopmentToolboxUtils.decorators.
multimethod
(*types)¶ This decorator can be used to define different signatures of a method/function for different data types
- NOTE: if you want to use classes that are not available when starting up slicer, define them as strings as follows:
- @multimethod([slicer.vtkMRMLScalarVolumeNode, “vtkMRMLMultiVolumeNode”], [str, unicode])
@multimethod([int, float], [int, float], str) def foo(arg1, arg2, arg3): print arg1, arg2, arg3 @multimethod([int, float], str) def foo(arg1, arg2, arg3): print arg1, arg2, arg3 foo(1,2,"bar") foo(1.0,2,"bar") foo(1,2.0,"bar") foo(1.0,2.0,"bar")
See Also: http://www.artima.com/weblogs/viewpost.jsp?thread=101605
-
SlicerDevelopmentToolboxUtils.decorators.
onExceptionReturnFalse
(func)¶ Whenever an exception occurs within the decorated function, this decorator will return False
>>> from SlicerDevelopmentToolboxUtils.decorators import onExceptionReturnFalse >>> @onExceptionReturnFalse ... def getElement(key, dictionary): ... return dictionary[key] >>> result = getElement('foobar', {'foo':1, 'bar':2}) # no foobar in dictionary >>> result is False
-
SlicerDevelopmentToolboxUtils.decorators.
onExceptionReturnNone
(func)¶ Whenever an exception occurs within the decorated function, this decorator will return None
from SlicerDevelopmentToolboxUtils.decorators import onExceptionReturnNone @onExceptionReturnNone def getElement(key, dictionary): return dictionary[key] result = getElement('foobar', {'foo':1, 'bar':2}) # no foobar in dictionary
-
class
SlicerDevelopmentToolboxUtils.decorators.
onModuleSelected
(moduleName)¶ Bases:
object
- This decorator can be used for executing the decorated function/method only if a certain Slicer module with name
- moduleName is currently selected
from SlicerDevelopmentToolboxUtils.decorators import onModuleSelected @onModuleSelected(moduleName="SliceTracker") def onLayoutChanged(self, layout=None): print "layout changed"
-
SlicerDevelopmentToolboxUtils.decorators.
onReturnProcessEvents
(func)¶ After running the decorated function slicer.app.processEvents() will be executed
-
SlicerDevelopmentToolboxUtils.decorators.
postCall
(functionToCall)¶ This decorator calls functionToCall after the decorated function.
Parameters: functionToCall (function) – function to be called after the decorated function
-
SlicerDevelopmentToolboxUtils.decorators.
priorCall
(functionToCall)¶ This decorator calls functionToCall prior to the decorated function.
Parameters: functionToCall (function) – function to be called prior(before) the decorated function
-
class
SlicerDevelopmentToolboxUtils.decorators.
processEventsEvery
(interval=100)¶ Decorator for executing a method/function every n milli seconds.
-
onTriggered
()¶
-
-
SlicerDevelopmentToolboxUtils.decorators.
singleton
(cls)¶ This decorator makes sure that only one instance of the decorated class will be created (singleton).
See Also: http://stackoverflow.com/questions/12305142/issue-with-singleton-python-call-two-times-init
-
SlicerDevelopmentToolboxUtils.decorators.
timer
(func)¶ This decorator can be used for profiling a method/function by printing the elapsed time after execution.
SlicerDevelopmentToolboxUtils.events module¶
SlicerDevelopmentToolboxUtils.exceptions module¶
-
exception
SlicerDevelopmentToolboxUtils.exceptions.
DICOMValueError
¶ Bases:
exceptions.ValueError
-
exception
SlicerDevelopmentToolboxUtils.exceptions.
NoEligibleSeriesFoundError
¶ Bases:
exceptions.ValueError
-
exception
SlicerDevelopmentToolboxUtils.exceptions.
PreProcessedDataError
¶ Bases:
exceptions.ValueError
-
exception
SlicerDevelopmentToolboxUtils.exceptions.
UnknownSeriesError
¶ Bases:
exceptions.ValueError
SlicerDevelopmentToolboxUtils.helpers module¶
SlicerDevelopmentToolboxUtils.icons module¶
-
class
SlicerDevelopmentToolboxUtils.icons.
Icons
¶ Bases:
object
The Icons class provides a bunch of frequently used icons.
All icons from
names
can directly be accessed by usingIcons.{name from names list}
(i.e.Icons.apply
)from SlicerDevelopmentToolboxUtils.icons import Icons Icons.names # a icon can be retrieved by calling Icons.{name} applyIcon = Icons.apply sideBySideIcon = Icons.layout_side_by_side_view
-
classmethod
getPath
(name)¶
-
names
= ['apply', 'back', 'cancel', 'connection', 'copy_to_left', 'copy_to_right', 'crosshair', 'cursor_window_level', 'edit', 'exit', 'fiducial_add', 'fiducial_modify', 'info', 'layout_four_up_plot_view', 'layout_four_up_table_view', 'layout_four_up_view', 'layout_one_up_red_slice_view', 'layout_side_by_side_view', 'move_to_left', 'move_to_right', 'new', 'open', 'redo', 'retry', 'settings', 'skip', 'star_filled', 'star_unfilled', 'start', 'text_info', 'thumbs_down', 'thumbs_up', 'undo', 'visible_off', 'visible_on', 'window_level_effect']¶
-
classmethod
-
class
SlicerDevelopmentToolboxUtils.icons.
IconsMetaClass
¶ Bases:
type
IconMetaClass searches the Resources/Icons directory for png files starting with ‘icon-‘ and provides class members
No code needs to be changed when adding a new icon. The filename of the icon should look as follows: ‘icon-‘…’.png’. Capital letters will be transformed to lower case and ‘-‘ and ‘ ‘ will be replaced with ‘_’
Examples
icon-fiducial-add.png –> Icons.fiducial_add
icon-cursor-WindowLevel.png –> Icons.cursor_window_level
icon-layout-OneUpRedSliceView.png –> Icons.layout_one_up_red_slice_view
Note
This class is used as a metaclass
-
classmethod
getIcon
(name)¶ Returning a QIcon for the retrieved icon name. Throws an exception if the name was not found.
-
classmethod
getPath
(name)¶ Returns the path to a specific icon.
-
classmethod
SlicerDevelopmentToolboxUtils.metaclasses module¶
-
class
SlicerDevelopmentToolboxUtils.metaclasses.
Singleton
¶ Bases:
type