SlicerDevelopmentToolboxUtils package

SlicerDevelopmentToolboxUtils.buttons module

SlicerDevelopmentToolboxUtils.constants module

class SlicerDevelopmentToolboxUtils.constants.COLOR
GRAY
GREEN
RED
YELLOW
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

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.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

class SlicerDevelopmentToolboxUtils.events.SlicerDevelopmentToolboxEvents

Bases: object

CanceledEvent
FailedEvent
FileCountChangedEvent
FinishedEvent
NewFileIndexedEvent
NewImageDataReceivedEvent
SkippedEvent
StartedEvent
StatusChangedEvent
StoppedEvent
SuccessEvent

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

SlicerDevelopmentToolboxUtils.metaclasses module

class SlicerDevelopmentToolboxUtils.metaclasses.Singleton

Bases: type

SlicerDevelopmentToolboxUtils.mixins module

SlicerDevelopmentToolboxUtils.widgets module

Module contents