本文整理汇总了Python中SampleData.downloadFromURL方法的典型用法代码示例。如果您正苦于以下问题:Python SampleData.downloadFromURL方法的具体用法?Python SampleData.downloadFromURL怎么用?Python SampleData.downloadFromURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SampleData
的用法示例。
在下文中一共展示了SampleData.downloadFromURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_RSNA2012ProstateDemo
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_RSNA2012ProstateDemo(self):
"""
Replicate one of the crashes in issue 2512
"""
print("Running RSNA2012ProstateDemo Test case:")
import SampleData
SampleData.downloadFromURL(
fileNames='RSNA2012ProstateDemo.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=10697')
# get all scene view nodes and test switching
svns = slicer.util.getNodes('vtkMRMLSceneViewNode*')
for reps in range(5):
for svname,svnode in svns.items():
self.delayDisplay('Restoring scene view %s ...' % svname )
svnode.RestoreScene()
self.delayDisplay('OK')
self.delayDisplay('Done testing scene views, will clear the scene')
slicer.mrmlScene.Clear(0)
self.delayDisplay('Test passed')
示例2: test_DataProbe1
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_DataProbe1(self):
""" Ideally you should have several levels of tests. At the lowest level
tests should exercise the functionality of the logic with different inputs
(both valid and invalid). At higher levels your tests should emulate the
way the user would interact with your code and confirm that it still works
the way you intended.
One of the most important features of the tests is that it should alert other
developers when their changes will have an impact on the behavior of your
module. For example, if a developer removes a feature that you depend on,
your test should break so they know that the feature is needed.
"""
self.delayDisplay("Starting the test")
#
# first, get some data
#
import SampleData
SampleData.downloadFromURL(
nodeNames='FA',
fileNames='FA.nrrd',
uris='http://slicer.kitware.com/midas3/download?items=5767')
self.delayDisplay('Finished with download and loading')
self.widget = DataProbeInfoWidget()
self.widget.frame.show()
self.delayDisplay('Test passed!')
示例3: onStartStopDicomPeer
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def onStartStopDicomPeer(self,flag):
if flag:
import os
self.startStopDicomPeerButton.setEnabled(False)
dicomFilesDirectory = slicer.app.temporaryPath
configFilePath = dicomFilesDirectory + '/Dcmtk-db/dcmqrscp.cfg'
processCurrentPath = dicomFilesDirectory + '/Dcmtk-db/'
if slicer.util.confirmYesNoDisplay('Do you want to choose local DCMTK database folder?'):
print 'Yes'
dicomFilesDirectory = qt.QFileDialog.getExistingDirectory(None, 'Select DCMTK database folder')
configFilePath = dicomFilesDirectory + '/dcmqrscp.cfg'
processCurrentPath = dicomFilesDirectory
else:
import SampleData
SampleData.downloadFromURL(
fileNames='Dcmtk-db.zip',
uris='http://slicer.kitware.com/midas3/download?items=18822')[0]
import subprocess
dcmqrscpExeOptions = (
'/bin',
'/../CTK-build/CMakeExternals/Install/bin',
'/../DCMTK-install/bin',
'/../DCMTK-build/bin',
)
dcmqrscpExePath = None
dcmqrscpExeName = '/dcmqrscp'
if slicer.app.os == 'win':
dcmqrscpExeName = dcmqrscpExeName + '.exe'
for path in dcmqrscpExeOptions:
testPath = slicer.app.slicerHome + path + dcmqrscpExeName
if os.path.exists(testPath):
dcmqrscpExePath = testPath
break
if not dcmqrscpExePath:
raise( UserWarning("Could not find dcmqrscp executable") )
args = (dcmqrscpExePath, '-c', configFilePath)
print 'Start DICOM peer'
self.popen = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=processCurrentPath)
self.startStopDicomPeerButton.setEnabled(True)
else:
print 'Stop DICOM peer'
self.popen.kill()
示例4: test_SlicerRestoreSceneViewCrashIssue3445
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_SlicerRestoreSceneViewCrashIssue3445(self):
""" Ideally you should have several levels of tests. At the lowest level
tests should exercise the functionality of the logic with different inputs
(both valid and invalid). At higher levels your tests should emulate the
way the user would interact with your code and confirm that it still works
the way you intended.
One of the most important features of the tests is that it should alert other
developers when their changes will have an impact on the behavior of your
module. For example, if a developer removes a feature that you depend on,
your test should break so they know that the feature is needed.
"""
logic = SlicerRestoreSceneViewCrashIssue3445Logic()
self.delayDisplay("Starting the test")
#
# first, get some data
#
import SampleData
filePath = SampleData.downloadFromURL(
fileNames='BrainAtlas2012.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=10937')[0]
self.delayDisplay('Finished with download')
ioManager = slicer.app.ioManager()
ioManager.loadFile(filePath)
slicer.mrmlScene.Clear(0)
slicer.util.selectModule('Data')
slicer.util.selectModule('Models')
ioManager.loadFile(filePath)
slicer.mrmlScene.Clear(0)
ioManager.loadFile(filePath)
ioManager.loadFile(filePath)
sceneViewNode = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLSceneViewNode')
sceneViewNode.RestoreScene()
# If test reach this point without crashing it is a success
self.delayDisplay('Test passed!')
示例5: test_Part3Liver
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part3Liver(self):
""" Test using the liver example data
"""
self.delayDisplay("Starting the test")
#
# first, get some data
#
import SampleData
SampleData.downloadFromURL(
fileNames='LiverData.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=8611')
self.delayDisplay('Finished with download and loading\n')
try:
logic = JRC2013VisLogic()
mainWindow = slicer.util.mainWindow()
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
redWidget = layoutManager.sliceWidget('Red')
redController = redWidget.sliceController()
viewNode = threeDView.mrmlViewNode()
cameras = slicer.util.getNodes('vtkMRMLCameraNode*')
for cameraNode in cameras.values():
if cameraNode.GetActiveTag() == viewNode.GetID():
break
self.delayDisplay('Segment II invisible')
mainWindow.moduleSelector().selectModule('Models')
segmentII = slicer.util.getNode('LiverSegment_II')
segmentII.GetDisplayNode().SetVisibility(0)
slicer.util.clickAndDrag(threeDView,start=(10,200),end=(10,10))
self.delayDisplay('Segment II visible')
segmentII.GetDisplayNode().SetVisibility(1)
cameraNode.GetCamera().Azimuth(0)
cameraNode.GetCamera().Elevation(0)
self.delayDisplay('View Adrenal')
segmentII.GetDisplayNode().SetVisibility(1)
cameraNode.GetCamera().Azimuth(180)
cameraNode.GetCamera().Elevation(-30)
segmentVII = slicer.util.getNode('LiverSegment_II')
redWidget.sliceController().setSliceVisible(True);
self.delayDisplay('Middle Hepatic')
models = slicer.util.getNodes('vtkMRMLModelNode*')
for modelNode in models.values():
modelNode.GetDisplayNode().SetVisibility(0)
segmentVII = slicer.util.getNode('LiverSegment_II')
transparentNodes = ('MiddleHepaticVein_and_Branches','LiverSegment_IVb','LiverSegmentV',)
for nodeName in transparentNodes:
modelNode = slicer.util.getNode(nodeName)
modelNode.GetDisplayNode().SetOpacity(0.5)
modelNode.GetDisplayNode().SetVisibility(1)
redWidget.sliceController().setSliceVisible(True);
cameraNode.GetCamera().Azimuth(30)
cameraNode.GetCamera().Elevation(-20)
self.delayDisplay('Test passed!')
except Exception, e:
import traceback
traceback.print_exc()
self.delayDisplay('Test caused exception!\n' + str(e))
示例6: test_Part2Head
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part2Head(self):
""" Test using the head atlas - may not be needed - Slicer4Minute is already tested
"""
self.delayDisplay("Starting the test")
#
# first, get some data
#
import SampleData
SampleData.downloadFromURL(
fileNames='3DHeadData.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=8609')
self.delayDisplay('Finished with download and loading\n')
try:
logic = JRC2013VisLogic()
mainWindow = slicer.util.mainWindow()
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
redWidget = layoutManager.sliceWidget('Red')
redController = redWidget.sliceController()
greenWidget = layoutManager.sliceWidget('Green')
greenController = greenWidget.sliceController()
self.delayDisplay('Models and Slice Model')
mainWindow.moduleSelector().selectModule('Models')
redWidget.sliceController().setSliceVisible(True);
self.delayDisplay('Scroll Slices')
for offset in xrange(-20,20,2):
redController.setSliceOffsetValue(offset)
self.delayDisplay('Skin Opacity')
# turn off skin and skull
skin = slicer.util.getNode(pattern='Skin.vtk')
skin.GetDisplayNode().SetOpacity(0.5)
self.delayDisplay('Skin and Skull Visibility')
skin.GetDisplayNode().SetVisibility(0)
skull = slicer.util.getNode(pattern='skull_bone.vtk')
skull.GetDisplayNode().SetVisibility(0)
self.delayDisplay('Green slice and Clipping')
greenWidget.sliceController().setSliceVisible(True);
hemispheric_white_matter = slicer.util.getNode(pattern='hemispheric_white_matter.vtk')
hemispheric_white_matter.GetDisplayNode().SetClipping(1)
clip = slicer.util.getNode(pattern='vtkMRMLClipModelsNode1')
clip.SetRedSliceClipState(0)
clip.SetYellowSliceClipState(0)
clip.SetGreenSliceClipState(2)
viewNode = threeDView.mrmlViewNode()
cameras = slicer.util.getNodes('vtkMRMLCameraNode*')
for cameraNode in cameras.values():
if cameraNode.GetActiveTag() == viewNode.GetID():
break
cameraNode.GetCamera().Azimuth(90)
cameraNode.GetCamera().Elevation(20)
self.delayDisplay('Rotate')
slicer.util.clickAndDrag(threeDView)
self.delayDisplay('Zoom')
threeDView = layoutManager.threeDWidget(0).threeDView()
slicer.util.clickAndDrag(threeDView,button='Right')
self.delayDisplay('Test passed!')
except Exception, e:
import traceback
traceback.print_exc()
self.delayDisplay('Test caused exception!\n' + str(e))
示例7: test_Part1DICOM
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part1DICOM(self):
""" Test the DICOM part of the test using the head atlas
"""
import os
self.delayDisplay("Starting the DICOM test")
#
# first, get the data - a zip file of dicom data
#
import SampleData
SampleData.downloadFromURL(
fileNames='Dcmtk-db.zip',
uris='http://slicer.kitware.com/midas3/download?items=18822')[0]
try:
self.delayDisplay("Switching to temp database directory")
originalDatabaseDirectory = DICOMUtils.openTemporaryDatabase('tempDICOMDatbase')
self.delayDisplay('Start Local DICOM Q/R SCP')
import subprocess
import os
configFilePath = dicomFilesDirectory + '/Dcmtk-db/dcmqrscp.cfg'
processCurrentPath = dicomFilesDirectory + '/Dcmtk-db/'
dcmqrscpExeOptions = (
'/bin',
'/../CTK-build/CMakeExternals/Install/bin',
'/../DCMTK-install/bin',
'/../DCMTK-build/bin',
)
dcmqrscpExePath = None
dcmqrscpExeName = '/dcmqrscp'
if slicer.app.os == 'win':
dcmqrscpExeName = dcmqrscpExeName + '.exe'
for path in dcmqrscpExeOptions:
testPath = slicer.app.slicerHome + path + dcmqrscpExeName
if os.path.exists(testPath):
dcmqrscpExePath = testPath
break
if not dcmqrscpExePath:
raise( UserWarning("Could not find dcmqrscp executable") )
args = (dcmqrscpExePath, '-c', configFilePath)
popen = subprocess.Popen(args, stdout=subprocess.PIPE, cwd=processCurrentPath)
self.delayDisplay('Retrieve DICOM')
mainWindow = slicer.util.mainWindow()
mainWindow.moduleSelector().selectModule('DICOM')
dicomRetrieve = ctk.ctkDICOMRetrieve()
dicomRetrieve.setKeepAssociationOpen(True)
dicomRetrieve.setDatabase(slicer.dicomDatabase)
dicomRetrieve.setCallingAETitle('SlicerAE')
dicomRetrieve.setCalledAETitle('DCMTK')
dicomRetrieve.setPort(12345)
dicomRetrieve.setHost('localhost')
dicomRetrieve.getStudy('1.2.124.113932.1.170.223.162.178.20050502.160340.12640015');
popen.kill()
dicomWidget.detailsPopup.open()
# click on the first row of the tree
index = dicomWidget.tree.indexAt(qt.QPoint(0,0))
dicomWidget.onTreeClicked(index)
self.delayDisplay('Loading Selection')
dicomWidget.detailsPopup.loadCheckedLoadables()
self.delayDisplay('Change Level')
layoutManager = slicer.app.layoutManager()
redWidget = layoutManager.sliceWidget('Red')
slicer.util.clickAndDrag(redWidget,start=(10,10),end=(10,40))
self.delayDisplay('Change Window')
slicer.util.clickAndDrag(redWidget,start=(10,10),end=(40,10))
self.delayDisplay('Change Layout')
layoutManager = slicer.app.layoutManager()
layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)
self.delayDisplay('Zoom')
slicer.util.clickAndDrag(redWidget,button='Right',start=(10,10),end=(10,40))
self.delayDisplay('Pan')
slicer.util.clickAndDrag(redWidget,button='Middle',start=(10,10),end=(40,40))
self.delayDisplay('Center')
redWidget.sliceController().fitSliceToBackground()
self.delayDisplay('Lightbox')
redWidget.sliceController().setLightboxTo6x6()
self.delayDisplay('Conventional Layout')
layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalView)
self.delayDisplay('No Lightbox')
redWidget.sliceController().setLightboxTo1x1()
self.delayDisplay('Four Up Layout')
layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView)
self.delayDisplay('Shift Mouse')
#.........这里部分代码省略.........
示例8: test_Part2ChangeTracker
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part2ChangeTracker(self,enableScreenshotsFlag=0,screenshotScaleFactor=1):
""" Test the ChangeTracker module
"""
logic = RSNAQuantTutorialLogic()
logic.enableScreenshots = enableScreenshotsFlag
logic.screenshotScaleFactor = screenshotScaleFactor
self.delayDisplay("Starting the test")
if not hasattr(slicer.modules, 'changetracker'):
self.delayDisplay("ChangeTracker not available, skipping the test.")
return
#
# first, get some data
#
import SampleData
SampleData.downloadFromURL(
fileNames='ChangeTrackerScene.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=124184')
logic.takeScreenshot('ChangeTracker-Loaded','Finished with download and loading',-1)
try:
mainWindow = slicer.util.mainWindow()
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
redWidget = layoutManager.sliceWidget('Red')
redController = redWidget.sliceController()
viewNode = threeDView.mrmlViewNode()
cameras = slicer.util.getNodes('vtkMRMLCameraNode*')
for cameraNode in cameras.values():
if cameraNode.GetActiveTag() == viewNode.GetID():
break
self.delayDisplay('Configure Module')
mainWindow.moduleSelector().selectModule('ChangeTracker')
logic.takeScreenshot('ChangeTracker-ModuleGUI','Select the ChangeTracker module',-1)
changeTracker = slicer.modules.changetracker.widgetRepresentation().self()
baselineNode = slicer.util.getNode('2006-spgr1')
followupNode = slicer.util.getNode('2007-spgr1')
changeTracker.selectScansStep._ChangeTrackerSelectScansStep__baselineVolumeSelector.setCurrentNode(baselineNode)
changeTracker.selectScansStep._ChangeTrackerSelectScansStep__followupVolumeSelector.setCurrentNode(followupNode)
logic.takeScreenshot('ChangeTracker-SetInputs','Select input scans',-1)
changeTracker.workflow.goForward()
logic.takeScreenshot('ChangeTracker-GoForward','Go Forward',-1)
slicer.util.clickAndDrag(redWidget,button='Right')
logic.takeScreenshot('ChangeTracker-Zoom','Inspect - zoom',-1)
slicer.util.clickAndDrag(redWidget,button='Middle')
logic.takeScreenshot('ChangeTracker-Pan','Inspect - pan',-1)
for offset in range(-20,20,2):
redController.setSliceOffsetValue(offset)
logic.takeScreenshot('ChangeTracker-Scroll','Inspect - scroll',-1)
self.delayDisplay('Set ROI')
roi = changeTracker.defineROIStep._ChangeTrackerDefineROIStep__roi
roi.SetXYZ(-2.81037, 28.7629, 28.4536)
logic.takeScreenshot('ChangeTracker-SetROICenter','Center VOI',-1)
roi.SetRadiusXYZ(22.6467, 22.6804, 22.9897)
logic.takeScreenshot('ChangeTracker-SetROIExtent','Resize the VOI',-1)
layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalWidescreenView)
logic.takeScreenshot('ChangeTracker-ConventionalWidescreen','Select the viewing mode Conventional Widescreen',-1)
slicer.util.clickAndDrag(redWidget,button='Right')
logic.takeScreenshot('ChangeTracker-ZoomVOI','Zoom',-1)
layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView)
logic.takeScreenshot('ChangeTracker-FourUpLayout','Go back to Four-Up layout',-1)
changeTracker.workflow.goForward()
logic.takeScreenshot('ChangeTracker-GoForward','Go Forward',-1)
changeTracker.segmentROIStep._ChangeTrackerSegmentROIStep__threshRange.minimumValue = 120
logic.takeScreenshot('ChangeTracker-Threshold','Set threshold',-1)
changeTracker.workflow.goForward()
logic.takeScreenshot('ChangeTracker-GoForward','Go Forward',-1)
checkList = changeTracker.analyzeROIStep._ChangeTrackerAnalyzeROIStep__metricCheckboxList
index = list(checkList.values()).index('IntensityDifferenceMetric')
list(checkList.keys())[index].checked = True
logic.takeScreenshot('ChangeTracker-PickMetric','Select the ROI analysis method',-1)
changeTracker.workflow.goForward()
logic.takeScreenshot('ChangeTracker-GoForward','Go Forward',-1)
self.delayDisplay('Look!')
redWidget.sliceController().setSliceVisible(True);
self.delayDisplay('Crosshairs')
compareWidget = layoutManager.sliceWidget('Compare1')
#.........这里部分代码省略.........
示例9: test_Part3PETCT
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part3PETCT(self,enableScreenshotsFlag=0,screenshotScaleFactor=1):
""" Test using the PETCT module
"""
logic = RSNAQuantTutorialLogic()
logic.enableScreenshots = enableScreenshotsFlag
logic.screenshotScaleFactor = screenshotScaleFactor
self.delayDisplay("Starting the test")
#
# first, get some data
#
import SampleData
extractPath = SampleData.downloadFromURL(
fileNames='dataset3_PETCT.zip',
uris='http://slicer.kitware.com/midas3/download?items=124185')[0]
self.delayDisplay("Loading PET_CT_pre-treatment.mrb")
preTreatmentPath = extractPath + '/PET_CT_pre-treatment.mrb'
slicer.util.loadScene(preTreatmentPath)
logic.takeScreenshot('PETCT-LoadedPre','Loaded pre-treatement scene',-1)
try:
mainWindow = slicer.util.mainWindow()
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
redWidget = layoutManager.sliceWidget('Red')
redController = redWidget.sliceController()
greenWidget = layoutManager.sliceWidget('Green')
greenController = greenWidget.sliceController()
yellowWidget = layoutManager.sliceWidget('Yellow')
yellowController = yellowWidget.sliceController()
viewNode = threeDView.mrmlViewNode()
cameras = slicer.util.getNodes('vtkMRMLCameraNode*')
for cameraNode in cameras.values():
if cameraNode.GetActiveTag() == viewNode.GetID():
break
threeDView.resetFocalPoint()
slicer.util.clickAndDrag(threeDView,button='Right')
redWidget.sliceController().setSliceVisible(True)
yellowWidget.sliceController().setSliceVisible(True)
logic.takeScreenshot('PETCT-ConfigureView','Configure View',-1)
mainWindow.moduleSelector().selectModule('Volumes')
compositNode = redWidget.mrmlSliceCompositeNode()
compositNode.SetForegroundOpacity(0.2)
logic.takeScreenshot('PETCT-ShowVolumes','Show Volumes with lesion',-1)
compositNode.SetForegroundOpacity(0.5)
logic.takeScreenshot('PETCT-CTOpacity','CT1 volume opacity to 0.5',-1)
yellowWidget.sliceController().setSliceVisible(False)
greenWidget.sliceController().setSliceVisible(True)
logic.takeScreenshot('PETCT-ShowSlices','Show axial and sagittal slices',-1)
self.delayDisplay('SUV Computation')
if not hasattr(slicer.modules, 'petstandarduptakevaluecomputation'):
self.delayDisplay("PET SUV Computation not available, skipping the test.")
return
slicer.util.selectModule('PETStandardUptakeValueComputation')
parameters = {
"PETDICOMPath": extractPath + '/' + 'PET1',
"PETVolume": slicer.util.getNode('PET1'),
"VOIVolume": slicer.util.getNode('PET1-label'),
}
suvComputation = slicer.modules.petstandarduptakevaluecomputation
self.CLINode1 = None
self.CLINode1 = slicer.cli.runSync(suvComputation, self.CLINode1, parameters, delete_temporary_files=False)
# close the scene
slicer.mrmlScene.Clear(0)
self.delayDisplay("Loading PET_CT_post-treatment.mrb")
postTreatmentPath = extractPath + '/PET_CT_post-treatment.mrb'
slicer.util.loadScene(postTreatmentPath)
logic.takeScreenshot('PETCT-LoadedPost','Loaded post-treatement scene',-1)
compositNode.SetForegroundOpacity(0.5)
logic.takeScreenshot('PETCT-CT2Opacity','CT2 volume opacity to 0.5',-1)
redController.setSliceOffsetValue(-165.01)
logic.takeScreenshot('PETCT-LarynxUptake','Mild uptake in the larynx and pharynx',-1)
redController.setSliceOffsetValue(-106.15)
logic.takeScreenshot('PETCT-TumorUptake','No uptake in the area of the primary tumor',-1)
self.delayDisplay('Test passed!')
except Exception as e:
import traceback
traceback.print_exc()
self.delayDisplay('Test caused exception!\n' + str(e))
示例10: test_AlternateReaders
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_AlternateReaders(self):
""" Test the DICOM loading of sample testing data
"""
testPass = True
import os, json
self.delayDisplay("Starting the DICOM test")
referenceData = [
{ "url": "http://slicer.kitware.com/midas3/download?items=292839",
"fileName": "Mouse-MR-example-where-GDCM_fails.zip",
"name": "Mouse-MR-example-where-GDCM_fails",
"seriesUID": "1.3.6.1.4.1.9590.100.1.2.366426457713813178933224342280246227461",
"expectedFailures": ["GDCM", "Archetype"],
"voxelValueQuantity": "(110852, DCM, \"MR signal intensity\")",
"voxelValueUnits": "(1, UCUM, \"no units\")"
},
{ "url": "http://slicer.kitware.com/midas3/download?items=294857",
"fileName": "deidentifiedMRHead-dcm-one-series.zip",
"name": "deidentifiedMRHead-dcm-one-series",
"seriesUID": "1.3.6.1.4.1.5962.99.1.3814087073.479799962.1489872804257.270.0",
"expectedFailures": [],
"voxelValueQuantity": "(110852, DCM, \"MR signal intensity\")",
"voxelValueUnits": "(1, UCUM, \"no units\")"
}
]
# another dataset that could be added in the future - currently fails for all readers
# due to invalid format - see https://issues.slicer.org/view.php?id=3569
#{ "url": "http://slicer.kitware.com/midas3/download/item/293587/RIDER_bug.zip",
#"fileName": "RIDER_bug.zip",
#"name": "RIDER_bug",
#"seriesUID": "1.3.6.1.4.1.9328.50.7.261772317324041365541450388603508531852",
#"expectedFailures": []
#}
loadingResult = {}
#
# first, get the data - a zip file of dicom data
#
self.delayDisplay("Downloading")
for dataset in referenceData:
try:
import SampleData
dicomFilesDirectory = SampleData.downloadFromURL(
fileNames=dataset['fileName'], uris=dataset['url'])[0]
self.delayDisplay('Finished with download')
#
# insert the data into th database
#
self.delayDisplay("Switching to temp database directory")
originalDatabaseDirectory = DICOMUtils.openTemporaryDatabase('tempDICOMDatabase')
self.delayDisplay('Importing DICOM')
mainWindow = slicer.util.mainWindow()
mainWindow.moduleSelector().selectModule('DICOM')
indexer = ctk.ctkDICOMIndexer()
indexer.addDirectory(slicer.dicomDatabase, dicomFilesDirectory, None)
indexer.waitForImportFinished()
#
# select the series
#
detailsPopup = slicer.modules.DICOMWidget.detailsPopup
detailsPopup.open()
# load the data by series UID
detailsPopup.offerLoadables(dataset['seriesUID'],'Series')
detailsPopup.examineForLoading()
loadable = detailsPopup.getAllSelectedLoadables().keys()[0]
#
# try loading using each of the selected readers, fail
# on enexpected load issue
#
scalarVolumePlugin = slicer.modules.dicomPlugins['DICOMScalarVolumePlugin']()
readerApproaches = scalarVolumePlugin.readerApproaches()
basename = loadable.name
volumesByApproach = {}
for readerApproach in readerApproaches:
self.delayDisplay('Loading Selection with approach: %s' % readerApproach)
loadable.name = basename + "-" + readerApproach
volumeNode = scalarVolumePlugin.load(loadable,readerApproach)
if not volumeNode and readerApproach not in dataset['expectedFailures']:
raise Exception("Expected to be able to read with %s, but couldn't" % readerApproach)
if volumeNode and readerApproach in dataset['expectedFailures']:
raise Exception("Expected to NOT be able to read with %s, but could!" % readerApproach)
if volumeNode:
volumesByApproach[readerApproach] = volumeNode
self.delayDisplay('Test quantity and unit')
if 'voxelValueQuantity' in dataset.keys():
self.assertEqual(volumeNode.GetVoxelValueQuantity().GetAsPrintableString(), dataset['voxelValueQuantity'])
if 'voxelValueUnits' in dataset.keys():
self.assertEqual(volumeNode.GetVoxelValueUnits().GetAsPrintableString(), dataset['voxelValueUnits'])
#
# for each approach that loaded as expected, compare the volumes
# to ensure they match in terms of pixel data and metadata
#.........这里部分代码省略.........
示例11: test_Part2Head
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part2Head(self,enableScreenshotsFlag=0,screenshotScaleFactor=1):
""" Test using the head atlas - may not be needed - Slicer4Minute is already tested
"""
logic = RSNAVisTutorialLogic()
logic.enableScreenshots = enableScreenshotsFlag
logic.screenshotScaleFactor = screenshotScaleFactor
self.delayDisplay("Starting the test")
#
# first, get some data
#
import SampleData
SampleData.downloadFromURL(
fileNames='Head_Scene.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=124180')
logic.takeScreenshot('Head-Downloaded','Finished with download and loading',-1)
try:
mainWindow = slicer.util.mainWindow()
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
redWidget = layoutManager.sliceWidget('Red')
redController = redWidget.sliceController()
greenWidget = layoutManager.sliceWidget('Green')
greenController = greenWidget.sliceController()
mainWindow.moduleSelector().selectModule('Models')
redWidget.sliceController().setSliceVisible(True);
logic.takeScreenshot('Head-ModelsAndSliceModel','Models and Slice Model',-1)
slicer.util.clickAndDrag(threeDView)
logic.takeScreenshot('Head-Rotate','Rotate',-1)
redController.setSliceVisible(True);
logic.takeScreenshot('Head-AxialSlice','Display Axial Slice',-1)
layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalView)
logic.takeScreenshot('Head-ConventionalView','Conventional Layout',-1)
viewNode = threeDView.mrmlViewNode()
cameras = slicer.util.getNodes('vtkMRMLCameraNode*')
for cameraNode in cameras.values():
if cameraNode.GetActiveTag() == viewNode.GetID():
break
cameraNode.GetCamera().Azimuth(90)
cameraNode.GetCamera().Elevation(20)
# turn off skin and skull
skin = slicer.util.getNode(pattern='Skin.vtk')
skin.GetDisplayNode().SetOpacity(0.5)
logic.takeScreenshot('Head-SkinOpacity','Skin Opacity to 0.5',-1)
skin.GetDisplayNode().SetVisibility(0)
logic.takeScreenshot('Head-SkinOpacityZero','Skin Opacity to 0',-1)
skull = slicer.util.getNode(pattern='skull_bone.vtk')
greenWidget.sliceController().setSliceVisible(True);
logic.takeScreenshot('Head-GreenSlice','Display Coronal Slice',-1)
# hemispheric_white_matter.GetDisplayNode().SetClipping(1)
skull.GetDisplayNode().SetClipping(1)
clip = slicer.util.getNode(pattern='vtkMRMLClipModelsNode1')
clip.SetRedSliceClipState(0)
clip.SetYellowSliceClipState(0)
clip.SetGreenSliceClipState(2)
logic.takeScreenshot('Head-SkullClipping','Turn on clipping for skull model',-1)
for offset in range(-20,20,2):
greenController.setSliceOffsetValue(offset)
logic.takeScreenshot('Head-ScrollCoronal','Scroll through coronal slices',-1)
skull.GetDisplayNode().SetVisibility(0)
logic.takeScreenshot('Head-HideSkull','Make the skull invisible',-1)
for offset in range(-40,-20,2):
greenController.setSliceOffsetValue(offset)
logic.takeScreenshot('Head-ScrollCoronalWhiteMatter','Scroll through coronal slices to show white matter',-1)
hemispheric_white_matter = slicer.util.getNode(pattern='hemispheric_white_matter.vtk')
hemispheric_white_matter.GetDisplayNode().SetVisibility(0)
logic.takeScreenshot('Head-HideWhiteMatter','Turn off white matter',-1)
self.delayDisplay('Rotate')
slicer.util.clickAndDrag(threeDView)
self.delayDisplay('Zoom')
threeDView = layoutManager.threeDWidget(0).threeDView()
slicer.util.clickAndDrag(threeDView,button='Right')
logic.takeScreenshot('Head-Zoom','Zoom',-1)
self.delayDisplay('Test passed!')
except Exception as e:
import traceback
traceback.print_exc()
self.delayDisplay('Test caused exception!\n' + str(e))
示例12: test_Part1DICOM
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part1DICOM(self,enableScreenshotsFlag=0,screenshotScaleFactor=1):
""" Test the DICOM part of the test using the head atlas
"""
logic = RSNAVisTutorialLogic()
logic.enableScreenshots = enableScreenshotsFlag
logic.screenshotScaleFactor = screenshotScaleFactor
import os
self.delayDisplay("Starting the DICOM test")
#
# first, get the data - a zip file of dicom data
#
import SampleData
dicomFilesDirectory = SampleData.downloadFromURL(
fileNames='dataset1_Thorax_Abdomen.zip',
uris='http://slicer.kitware.com/midas3/download?items=124183')[0]
try:
self.delayDisplay("Switching to temp database directory")
originalDatabaseDirectory = DICOMUtils.openTemporaryDatabase('tempDICOMDatabase')
self.delayDisplay('Importing DICOM')
mainWindow = slicer.util.mainWindow()
mainWindow.moduleSelector().selectModule('DICOM')
indexer = ctk.ctkDICOMIndexer()
indexer.addDirectory(slicer.dicomDatabase, dicomFilesDirectory, None)
indexer.waitForImportFinished()
dicomWidget = slicer.modules.DICOMWidget
dicomWidget.detailsPopup.open()
# load the data by series UID
dicomWidget.detailsPopup.offerLoadables('1.3.12.2.1107.5.1.4.50025.30000005060811542834300000776','Series')
dicomWidget.detailsPopup.examineForLoading()
self.delayDisplay('Loading Selection')
dicomWidget.detailsPopup.loadCheckedLoadables()
logic.takeScreenshot('LoadingADICOMVolume-Loaded','Loaded DICOM Volume',-1)
layoutManager = slicer.app.layoutManager()
redWidget = layoutManager.sliceWidget('Red')
slicer.util.clickAndDrag(redWidget,start=(10,10),end=(10,40))
slicer.util.clickAndDrag(redWidget,start=(10,10),end=(40,10))
logic.takeScreenshot('LoadingADICOMVolume-WL','Changed level and window',-1)
redWidget.sliceController().setSliceLink(True)
redWidget.sliceController().setSliceVisible(True);
logic.takeScreenshot('LoadingADICOMVolume-LinkView','Linked and visible',-1)
slicer.util.clickAndDrag(redWidget,button='Right',start=(10,10),end=(10,40))
logic.takeScreenshot('LoadingADICOMVolume-Zoom','Zoom',-1)
threeDView = layoutManager.threeDWidget(0).threeDView()
slicer.util.clickAndDrag(threeDView)
logic.takeScreenshot('LoadingADICOMVolume-Rotate','Rotate',-1)
threeDView.resetFocalPoint()
logic.takeScreenshot('LoadingADICOMVolume-Center','Center the view',-1)
layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalWidescreenView)
logic.takeScreenshot('LoadingADICOMVolume-ConventionalWidescreen','Conventional Widescreen Layout',-1)
slicer.util.mainWindow().moduleSelector().selectModule('VolumeRendering')
logic.takeScreenshot('VolumeRendering-Module','Volume Rendering',-1)
volumeRenderingWidgetRep = slicer.modules.volumerendering.widgetRepresentation()
abdomenVolume = slicer.mrmlScene.GetFirstNodeByName('6: CT_Thorax_Abdomen')
volumeRenderingWidgetRep.setMRMLVolumeNode(abdomenVolume)
logic.takeScreenshot('VolumeRendering-SelectVolume','Select the volume 6: CT_Thorax_Abdomen',-1)
presetsScene = slicer.modules.volumerendering.logic().GetPresetsScene()
ctCardiac3 = presetsScene.GetFirstNodeByName('CT-Cardiac3')
volumeRenderingWidgetRep.applyPreset(ctCardiac3)
logic.takeScreenshot('VolumeRendering-SelectPreset','Select the Preset CT-Cardiac-3')
self.delayDisplay('Skipping: Select VTK CPU Ray Casting')
volumeRenderingNode = slicer.mrmlScene.GetFirstNodeByName('VolumeRendering')
volumeRenderingNode.SetVisibility(1)
logic.takeScreenshot('VolumeRendering-ViewRendering','View Volume Rendering',-1)
self.delayDisplay('Skipping Move the Shift slider')
redWidget.sliceController().setSliceVisible(False);
logic.takeScreenshot('VolumeRendering-SlicesOff','Turn off visibility of slices in 3D',-1)
threeDView = layoutManager.threeDWidget(0).threeDView()
slicer.util.clickAndDrag(threeDView)
logic.takeScreenshot('VolumeRendering-RotateVolumeRendering','Rotate volume rendered image',-1)
volumeRenderingNode.SetVisibility(0)
logic.takeScreenshot('VolumeRendering-TurnOffVolumeRendering','Turn off volume rendered image',-1)
volumeRenderingNode.SetCroppingEnabled(1)
annotationROI = slicer.mrmlScene.GetFirstNodeByName('AnnotationROI')
annotationROI.SetDisplayVisibility(1)
#.........这里部分代码省略.........
示例13: test_Part3ChangeTracker
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part3ChangeTracker(self):
self.delayDisplay("Starting the test")
#
# first, get some data
#
self.delayDisplay("Starting the test")
import SampleData
SampleData.downloadFromURL(
fileNames='RSNA2011_ChangeTracker_data.zip',
uris='http://slicer.kitware.com/midas3/download?items=8986')
try:
mainWindow = slicer.util.mainWindow()
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
redWidget = layoutManager.sliceWidget('Red')
redController = redWidget.sliceController()
viewNode = threeDView.mrmlViewNode()
cameras = slicer.util.getNodes('vtkMRMLCameraNode*')
for cameraNode in cameras.values():
if cameraNode.GetActiveTag() == viewNode.GetID():
break
self.delayDisplay('Configure Module')
mainWindow.moduleSelector().selectModule('ChangeTracker')
changeTracker = slicer.modules.changetracker.widgetRepresentation().self()
baselineNode = slicer.util.getNode('2006-spgr1')
followupNode = slicer.util.getNode('2007-spgr1')
changeTracker.selectScansStep._ChangeTrackerSelectScansStep__baselineVolumeSelector.setCurrentNode(baselineNode)
changeTracker.selectScansStep._ChangeTrackerSelectScansStep__followupVolumeSelector.setCurrentNode(followupNode)
'''
self.delayDisplay('Go Forward')
changeTracker.workflow.goForward()
self.delayDisplay('Inspect - zoom')
slicer.util.clickAndDrag(redWidget,button='Right')
self.delayDisplay('Inspect - pan')
slicer.util.clickAndDrag(redWidget,button='Middle')
self.delayDisplay('Inspect - scroll')
for offset in xrange(-20,20,2):
redController.setSliceOffsetValue(offset)
self.delayDisplay('Set ROI')
roi = changeTracker.defineROIStep._ChangeTrackerDefineROIStep__roi
roi.SetXYZ(-2.81037, 28.7629, 28.4536)
roi.SetRadiusXYZ(22.6467, 22.6804, 22.9897)
self.delayDisplay('Go Forward')
changeTracker.workflow.goForward()
self.delayDisplay('Set Threshold')
changeTracker.segmentROIStep._ChangeTrackerSegmentROIStep__threshRange.minimumValue = 142
self.delayDisplay('Go Forward')
changeTracker.workflow.goForward()
self.delayDisplay('Pick Metric')
checkList = changeTracker.analyzeROIStep._ChangeTrackerAnalyzeROIStep__metricCheckboxList
index = checkList.values().index('IntensityDifferenceMetric')
checkList.keys()[index].checked = True
self.delayDisplay('Go Forward')
changeTracker.workflow.goForward()
self.delayDisplay('Look!')
redWidget.sliceController().setSliceVisible(True);
self.delayDisplay('Crosshairs')
compareWidget = layoutManager.sliceWidget('Compare1')
style = compareWidget.interactorStyle()
interactor = style.GetInteractor()
for step in xrange(100):
interactor.SetEventPosition(10,step)
style.OnMouseMove()
self.delayDisplay('Zoom')
slicer.util.clickAndDrag(compareWidget,button='Right')
self.delayDisplay('Pan')
slicer.util.clickAndDrag(compareWidget,button='Middle')
self.delayDisplay('Inspect - scroll')
compareController = redWidget.sliceController()
for offset in xrange(10,30,2):
compareController.setSliceOffsetValue(offset)
self.delayDisplay('Close Scene')
slicer.mrmlScene.Clear(0)
'''
self.delayDisplay('Test passed!')
# intentionally do not close the scene -- the issue is reproduced on close
#.........这里部分代码省略.........
示例14: test_Slicer4Minute1
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Slicer4Minute1(self):
""" Tests parts of the Slicer4Minute tutorial.
Currently testing 'Part 2' which covers volumes, models, visibility and clipping.
"""
self.delayDisplay("Starting the test")
logic = Slicer4MinuteLogic()
#
# first, get some data
#
import SampleData
SampleData.downloadFromURL(
fileNames='slicer4minute.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=8466')
self.delayDisplay('Finished with download and loading')
# Testing "Part 2" of Tutorial
#
#
self.delayDisplay('Testing Part 2 of the Tutorial')
# check volume is loaded out of scene
volumeNode = slicer.util.getNode(pattern="grayscale")
self.assertIsNotNone( logic.hasImageData(volumeNode) )
# check the slice planes
red = slicer.util.getNode(pattern="vtkMRMLSliceNode1")
red.SetSliceVisible(1)
green = slicer.util.getNode(pattern="vtkMRMLSliceNode3")
green.SetSliceVisible(1)
# rotate a bit
cam = slicer.util.getNode(pattern='vtkMRMLCameraNode1')
cam.GetCamera().Azimuth(90)
cam.GetCamera().Elevation(20)
# turn off skin and skull
skin = slicer.util.getNode(pattern='Skin')
skin.GetDisplayNode().SetVisibility(0)
skull = slicer.util.getNode(pattern='skull_bone')
skull.GetDisplayNode().SetVisibility(0)
# clip the model hemispheric_white_matter.vtk
m = slicer.util.mainWindow()
m.moduleSelector().selectModule('Models')
models = slicer.util.getModule('Models')
logic = models.logic()
hemispheric_white_matter = slicer.util.getNode(pattern='hemispheric_white_matter')
hemispheric_white_matter.GetDisplayNode().SetClipping(1)
clip = slicer.util.getNode('ClipModelsParameters1')
clip.SetRedSliceClipState(0)
clip.SetYellowSliceClipState(0)
clip.SetGreenSliceClipState(2)
# Can we make this more than just a Smoke Test?
self.delayDisplay('Optic chiasm should be visible. Front part of white matter should be clipped.')
# Done
#
#
self.delayDisplay('Test passed!')
示例15: test_Part4Lung
# 需要导入模块: import SampleData [as 别名]
# 或者: from SampleData import downloadFromURL [as 别名]
def test_Part4Lung(self):
""" Test using the lung data
"""
self.delayDisplay("Starting the test")
#
# first, get some data
#
import SampleData
SampleData.downloadFromURL(
fileNames='LungData.mrb',
loadFiles=True,
uris='http://slicer.kitware.com/midas3/download?items=8612')
self.delayDisplay('Finished with download and loading\n')
try:
mainWindow = slicer.util.mainWindow()
layoutManager = slicer.app.layoutManager()
threeDView = layoutManager.threeDWidget(0).threeDView()
redWidget = layoutManager.sliceWidget('Red')
redController = redWidget.sliceController()
viewNode = threeDView.mrmlViewNode()
cameras = slicer.util.getNodes('vtkMRMLCameraNode*')
for cameraNode in cameras.values():
if cameraNode.GetActiveTag() == viewNode.GetID():
break
self.delayDisplay('Reset view')
threeDView.resetFocalPoint()
mainWindow.moduleSelector().selectModule('Models')
self.delayDisplay('View Question 1')
cameraNode.GetCamera().Azimuth(-100)
cameraNode.GetCamera().Elevation(-40)
redWidget.sliceController().setSliceVisible(True);
lungs = slicer.util.getNode('chestCT_lungs')
lungs.GetDisplayNode().SetVisibility(0)
self.delayDisplay('View Question 2')
cameraNode.GetCamera().Azimuth(-65)
cameraNode.GetCamera().Elevation(-20)
lungs.GetDisplayNode().SetVisibility(1)
lungs.GetDisplayNode().SetOpacity(0.24)
redController.setSliceOffsetValue(-50)
self.delayDisplay('View Question 3')
cameraNode.GetCamera().Azimuth(-165)
cameraNode.GetCamera().Elevation(-10)
redWidget.sliceController().setSliceVisible(False);
self.delayDisplay('View Question 4')
cameraNode.GetCamera().Azimuth(20)
cameraNode.GetCamera().Elevation(-10)
lowerLobeNodes = slicer.util.getNodes('*LowerLobe*')
for showNode in lowerLobeNodes:
self.delayDisplay('Showing Node %s' % showNode, 300)
for node in lowerLobeNodes:
displayNode = lowerLobeNodes[node].GetDisplayNode()
if displayNode:
displayNode.SetVisibility(1 if node == showNode else 0)
self.delayDisplay('Test passed!')
except Exception, e:
import traceback
traceback.print_exc()
self.delayDisplay('Test caused exception!\n' + str(e))