How to use the slicer.util function in slicer

To help you get started, we’ve selected a few slicer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SlicerDMRI / SlicerDMRI / Modules / Loadable / TractographyDisplay / Testing / Python / test_tractography_display.py View on Github external
def setUp(self):
    """ Do whatever is needed to reset the state - typically a scene clear will be enough.
    """
    slicer.mrmlScene.Clear(0)
    #
    # first, get some data
    #
    import urllib
    downloads = (
        ('http://slicer.kitware.com/midas3/download?items=5768', 'tract1.vtk', slicer.util.loadFiberBundle),
        )

    for url,name,loader in downloads:
      filePath = slicer.app.temporaryPath + '/' + name
      if not os.path.exists(filePath) or os.stat(filePath).st_size == 0:
        print('Requesting download %s from %s...\n' % (name, url))
        urllib.urlretrieve(url, filePath)
      if loader:
        print('Loading %s...\n' % (name,))
        loader(filePath)
    self.delayDisplay('Finished with download and loading\n')

    # use the volumes module to replicate the bug report
    m = slicer.util.mainWindow()
    m.moduleSelector().selectModule('TractographyDisplay')
    self.delayDisplay("Entered Tractography module")
github faustomilletari / TOMAAT-Slicer / TOMAAT / utils / dependencies.py View on Github external
import sys

if sys.version_info.major == 2:
  # import pip main
  try:
    from pip import main as pipmain
  except:
    from pip._internal import main as pipmain
  pip_install = lambda module: pipmain(['install',module])

else:
  import slicer
  pip_install = slicer.util.pip_install

# install requests
try:
  import requests
except:
  pip_install('requests')
  import requests
  pass

# install requests_toolbelt
try:
  from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
except:
  pip_install('requests_toolbelt')
  from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
  pass
github SlicerIGT / SlicerIGT / Scoliosis / SlicerExtension / PostureAssessmentToolkit / PreProcessLandmarks / PreProcessLandmarks.py View on Github external
def OnRemovePointButton(self):
    
    # Get sub-patch to add point to 
    SubIntervalNumber = self.SubIntervalSelector.value
    NodeUnderRepair = self.RepairSideSelector.currentNode()
    OldPatchName = NodeUnderRepair.GetName() + "_Patch"
    OldPatchNode = slicer.util.getNode(OldPatchName)
    
    if OldPatchName.__contains__("Left"):
      
      # Get patch with point added
      SideUnderRepair = self.logic.PatientModel.LeftSide
      NewPatchNode = SideUnderRepair.RemovePointFromSubPatch(SubIntervalNumber)
      
      # Update scene
      slicer.mrmlScene.RemoveNode(OldPatchNode)
      slicer.mrmlScene.AddNode(NewPatchNode)
      NewPatchNode.CreateDefaultDisplayNodes()
      
      # Update UI
      self.LeftPatchSelector.setCurrentNode(NewPatchNode)
      
    else: