Commit 97e0d902 authored by jcfr's avatar jcfr
Browse files

ENH: SampleData: Simplify downloadSample and introduce downloadSamples()


Suggested-by: Andras Lasso's avatarAndras Lasso <lasso@queensu.ca>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@27649 3bd1e089-480b-0410-8dfb-8563597acbee
parent 2315de82
......@@ -105,10 +105,10 @@ class BRAINSFitRigidRegistrationCrashIssue4139Test(ScriptedLoadableModuleTest):
import SampleData
fixed = SampleData.downloadSample('MRBrainTumor1')[0]
fixed = SampleData.downloadSample('MRBrainTumor1')
self.assertIsNotNone(logic.hasImageData(fixed))
moving = SampleData.downloadSample('MRBrainTumor2')[0]
moving = SampleData.downloadSample('MRBrainTumor2')
self.assertIsNotNone(logic.hasImageData(moving))
self.delayDisplay('Finished with download and loading')
......
......@@ -220,7 +220,7 @@ class CLIEventTestTest(ScriptedLoadableModuleTest):
self.delayDisplay('Load input volume')
import SampleData
inputVolume = SampleData.downloadSample("MRHead")[0]
inputVolume = SampleData.downloadSample("MRHead")
self.delayDisplay('Create subject hierarchy of input volume')
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
......
......@@ -136,7 +136,7 @@ class FiducialLayoutSwitchBug1914Logic(ScriptedLoadableModuleLogic):
# Download MRHead from sample data
import SampleData
mrHeadVolume = SampleData.downloadSample("MRHead")[0]
mrHeadVolume = SampleData.downloadSample("MRHead")
# Place a fiducial on the red slice
markupsLogic = slicer.modules.markups.logic()
......
......@@ -159,7 +159,7 @@ class RSNAQuantTutorialTest(ScriptedLoadableModuleTest):
# first, get some data
#
import SampleData
tumor = SampleData.downloadSample('MRBrainTumor1')[0]
tumor = SampleData.downloadSample('MRBrainTumor1')
try:
# four up view
......
......@@ -72,7 +72,7 @@ class SlicerBoundsTestTest(ScriptedLoadableModuleTest):
"""
#self.delayDisplay("Starting test_Volume")
import SampleData
volumeNode = SampleData.downloadSample('CTA abdomen\n(Panoramix)')[0]
volumeNode = SampleData.downloadSample('CTA abdomen\n(Panoramix)')
bounds = range(6)
volumeNode.GetRASBounds(bounds)
......
......@@ -90,7 +90,7 @@ class SlicerMRBMultipleSaveRestoreLoop(ScriptedLoadableModuleTest):
#
print("Getting MR Head Volume")
import SampleData
mrHeadVolume = SampleData.downloadSample("MRHead")[0]
mrHeadVolume = SampleData.downloadSample("MRHead")
# Place a fiducial
markupsLogic = slicer.modules.markups.logic()
......
......@@ -87,7 +87,7 @@ class SlicerMRBMultipleSaveRestore(ScriptedLoadableModuleTest):
#
print("Getting MR Head Volume")
import SampleData
mrHeadVolume = SampleData.downloadSample("MRHead")[0]
mrHeadVolume = SampleData.downloadSample("MRHead")
# Place a fiducial
markupsLogic = slicer.modules.markups.logic()
......
......@@ -155,7 +155,7 @@ class SlicerMRBSaveRestoreCheckPaths(ScriptedLoadableModuleTest):
#
print("Getting MR Head Volume")
import SampleData
mrHeadVolume = SampleData.downloadSample("MRHead")[0]
mrHeadVolume = SampleData.downloadSample("MRHead")
slicer.util.delayDisplay('Finished with download of volume')
......
......@@ -101,7 +101,7 @@ class SlicerOrientationSelectorTestTest(ScriptedLoadableModuleTest):
self.delayDisplay("Starting the test")
import SampleData
mrHeadVolume = SampleData.downloadSample("MRHead")[0]
mrHeadVolume = SampleData.downloadSample("MRHead")
slicer.util.selectModule('Reformat')
......
......@@ -136,7 +136,7 @@ class SlicerTransformInteractionTest1Test(ScriptedLoadableModuleTest):
logic = SlicerTransformInteractionTest1Logic()
import SampleData
volume = SampleData.downloadSample('CTA abdomen\n(Panoramix)')[0]
volume = SampleData.downloadSample('CTA abdomen\n(Panoramix)')
#self.delayDisplay("Starting test_3D_interactionVolume")
logic = SlicerTransformInteractionTest1Logic()
......
......@@ -98,9 +98,9 @@ class UtilTestTest(ScriptedLoadableModuleTest):
import SampleData
backgroundNode = SampleData.downloadSample("MRHead")[0]
backgroundNode = SampleData.downloadSample("MRHead")
backgroundNode.SetName('Background')
foregroundNode = SampleData.downloadSample("MRHead")[0]
foregroundNode = SampleData.downloadSample("MRHead")
foregroundNode.SetName('Foreground')
volumesLogic = slicer.modules.volumes.logic()
......@@ -133,9 +133,9 @@ class UtilTestTest(ScriptedLoadableModuleTest):
self.assertEqual(redSliceCompositeNode.GetLabelOpacity(), 0.1)
# Try to reset
otherBackgroundNode = SampleData.downloadSample("MRHead")[0]
otherBackgroundNode = SampleData.downloadSample("MRHead")
otherBackgroundNode.SetName('OtherBackground')
otherForegroundNode = SampleData.downloadSample("MRHead")[0]
otherForegroundNode = SampleData.downloadSample("MRHead")
otherForegroundNode.SetName('OtherForeground')
otherLabelmapNode = volumesLogic.CreateAndAddLabelVolume( slicer.mrmlScene, backgroundNode, 'OtherLabelmap' )
......@@ -200,7 +200,7 @@ class UtilTestTest(ScriptedLoadableModuleTest):
self.delayDisplay('Download sample data')
import SampleData
volumeNode = SampleData.downloadSample("MRHead")[0]
volumeNode = SampleData.downloadSample("MRHead")
self.delayDisplay('Test voxel value read')
voxelPos = [120,135,89]
......@@ -222,7 +222,7 @@ class UtilTestTest(ScriptedLoadableModuleTest):
self.delayDisplay('Download sample data')
import SampleData
volumeNode = SampleData.downloadSample("MRHead")[0]
volumeNode = SampleData.downloadSample("MRHead")
import numpy as np
import math
......@@ -255,7 +255,7 @@ class UtilTestTest(ScriptedLoadableModuleTest):
self.delayDisplay('Download sample data')
import SampleData
volumeNode = SampleData.downloadSample("MRHead")[0]
volumeNode = SampleData.downloadSample("MRHead")
self.delayDisplay('Compute histogram')
histogram = np.histogram(slicer.util.arrayFromVolume(volumeNode))
......@@ -291,7 +291,7 @@ class UtilTestTest(ScriptedLoadableModuleTest):
self.delayDisplay('Test array with scalar image')
import SampleData
volumeNode = SampleData.downloadSample("MRHead")[0]
volumeNode = SampleData.downloadSample("MRHead")
voxelPos = [120,135,89]
voxelValueVtk = volumeNode.GetImageData().GetScalarComponentAsDouble(voxelPos[0], voxelPos[1], voxelPos[2], 0)
narray = slicer.util.arrayFromVolume(volumeNode)
......@@ -299,7 +299,7 @@ class UtilTestTest(ScriptedLoadableModuleTest):
self.assertEqual(voxelValueVtk, voxelValueNumpy)
self.delayDisplay('Test array with tensor image')
tensorVolumeNode = SampleData.downloadSample('DTIBrain')[0]
tensorVolumeNode = SampleData.downloadSample('DTIBrain')
narray = slicer.util.array(tensorVolumeNode.GetName())
self.assertEqual(narray.shape, (85, 144, 144, 3, 3))
......
......@@ -97,8 +97,8 @@ class ViewControllersSliceInterpolationBug1926Test(ScriptedLoadableModuleTest):
#
self.delayDisplay("Getting Data")
import SampleData
head = SampleData.downloadSample("MRHead")[0]
tumor = SampleData.downloadSample('MRBrainTumor1')[0]
head = SampleData.downloadSample("MRHead")
tumor = SampleData.downloadSample('MRBrainTumor1')
# Change to a CompareView
ln = slicer.util.getNode(pattern='vtkMRMLLayoutNode*')
......
......@@ -98,7 +98,7 @@ class sceneImport2428Test(ScriptedLoadableModuleTest):
#
self.delayDisplay("Getting Data")
import SampleData
head = SampleData.downloadSample("MRHead")[0]
head = SampleData.downloadSample("MRHead")
#
# create a label map and set it for editing
......
......@@ -1366,7 +1366,7 @@ def plot(narray, xColumnIndex = -1, columnNames = None, title = None, show = Tru
# Get sample data
import numpy as np
import SampleData
volumeNode = SampleData.downloadSample("MRHead")[0]
volumeNode = SampleData.downloadSample("MRHead")
# Create new plot
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)
......@@ -1383,7 +1383,7 @@ def plot(narray, xColumnIndex = -1, columnNames = None, title = None, show = Tru
# Get sample data
import numpy as np
import SampleData
volumeNode = SampleData.downloadSample("MRHead")[0]
volumeNode = SampleData.downloadSample("MRHead")
# Create variable that will store plot nodes (chart, table, series)
plotNodes = {}
......
......@@ -14,7 +14,7 @@ class SitkUtilsTests(unittest.TestCase):
""" Download the MRHead node
"""
import SampleData
SampleData.downloadSample("MRHead")[0]
SampleData.downloadSample("MRHead")
volumeNode1 = slicer.util.getNode('MRHead')
self.assertEqual(volumeNode1.GetName(), "MRHead")
......@@ -87,7 +87,7 @@ class SitkUtilsTests(unittest.TestCase):
""" Download the MRHead node
"""
import SampleData
SampleData.downloadSample("MRHead")[0]
SampleData.downloadSample("MRHead")
volumeNode1 = slicer.util.getNode('MRHead')
self.assertEqual(volumeNode1.GetName(), "MRHead")
......
......@@ -67,7 +67,7 @@ class SegmentEditorScriptedSegmentEditorEffectModuleTemplateTest(ScriptedLoadabl
self.delayDisplay("Load master volume")
import SampleData
masterVolumeNode = SampleData.downloadSample('MRBrainTumor1')[0]
masterVolumeNode = SampleData.downloadSample('MRBrainTumor1')
##################################
self.delayDisplay("Create segmentation containing a few spheres")
......
......@@ -60,7 +60,7 @@ class CropVolumeSelfTestTest(ScriptedLoadableModuleTest):
import SampleData
vol = SampleData.downloadSample("MRHead")[0]
vol = SampleData.downloadSample("MRHead")
roi = slicer.vtkMRMLAnnotationROINode()
roi.Initialize(slicer.mrmlScene)
......@@ -87,7 +87,7 @@ class CropVolumeSelfTestTest(ScriptedLoadableModuleTest):
mainWindow.moduleSelector().selectModule('Transforms')
mainWindow.moduleSelector().selectModule('CropVolume')
cropVolumeNode = slicer.mrmlScene.GetNodeByID('vtkMRMLCropVolumeParametersNode1')
vol = SampleData.downloadSample("MRHead")[0]
vol = SampleData.downloadSample("MRHead")
roi = slicer.vtkMRMLAnnotationROINode()
roi.Initialize(slicer.mrmlScene)
cropVolumeNode.SetInputVolumeNodeID(vol.GetID())
......
......@@ -81,7 +81,7 @@ class MarkupsInCompareViewersSelfTestLogic(ScriptedLoadableModuleLogic):
#
print("Getting MR Head Volume")
import SampleData
mrHeadVolume = SampleData.downloadSample("MRHead")[0]
mrHeadVolume = SampleData.downloadSample("MRHead")
#
# link the viewers
......
......@@ -136,7 +136,7 @@ class MarkupsInViewsSelfTestLogic(ScriptedLoadableModuleLogic):
#
print("Getting MR Head Volume")
import SampleData
mrHeadVolume = SampleData.downloadSample("MRHead")[0]
mrHeadVolume = SampleData.downloadSample("MRHead")
#
# link the viewers
......
......@@ -144,7 +144,7 @@ class NeurosurgicalPlanningTutorialMarkupsSelfTestLogic(ScriptedLoadableModuleLo
# use the sample data module logic to load data for the self test
self.delayDisplay("Getting Baseline volume")
import SampleData
baselineVolume = SampleData.downloadSample('BaselineVolume')[0]
baselineVolume = SampleData.downloadSample('BaselineVolume')
self.takeScreenshot('NeurosurgicalPlanning-Loaded','Data loaded')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment