diff --git a/Applications/SlicerApp/Testing/Python/BRAINSFitRigidRegistrationCrashIssue4139.py b/Applications/SlicerApp/Testing/Python/BRAINSFitRigidRegistrationCrashIssue4139.py index a477a9524ba7b5764daa768bcc62111627cb1374..ef92aae57eeda9101710d308f2b8e7215d5d59d5 100644 --- a/Applications/SlicerApp/Testing/Python/BRAINSFitRigidRegistrationCrashIssue4139.py +++ b/Applications/SlicerApp/Testing/Python/BRAINSFitRigidRegistrationCrashIssue4139.py @@ -103,12 +103,12 @@ class BRAINSFitRigidRegistrationCrashIssue4139Test(ScriptedLoadableModuleTest): logic = BRAINSFitRigidRegistrationCrashIssue4139Logic() - from SampleData import SampleDataLogic + import SampleData - fixed = SampleDataLogic().downloadMRBrainTumor1() + fixed = SampleData.downloadSample('MRBrainTumor1')[0] self.assertIsNotNone(logic.hasImageData(fixed)) - moving = SampleDataLogic().downloadMRBrainTumor2() + moving = SampleData.downloadSample('MRBrainTumor2')[0] self.assertIsNotNone(logic.hasImageData(moving)) self.delayDisplay('Finished with download and loading') diff --git a/Applications/SlicerApp/Testing/Python/CLIEventTest.py b/Applications/SlicerApp/Testing/Python/CLIEventTest.py index a7de28161c5d71ce902cfc70a5c9620d5d7546ba..1027ee207b1da3ee2f4063e1f02dc4efb88d4407 100644 --- a/Applications/SlicerApp/Testing/Python/CLIEventTest.py +++ b/Applications/SlicerApp/Testing/Python/CLIEventTest.py @@ -219,8 +219,8 @@ class CLIEventTestTest(ScriptedLoadableModuleTest): self.delayDisplay('Test that output node moved to referenced node location in subject hierarchy') self.delayDisplay('Load input volume') - from SampleData import SampleDataLogic - inputVolume = SampleDataLogic().downloadMRHead() + import SampleData + inputVolume = SampleData.downloadSample("MRHead")[0] self.delayDisplay('Create subject hierarchy of input volume') shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene) diff --git a/Applications/SlicerApp/Testing/Python/FiducialLayoutSwitchBug1914.py b/Applications/SlicerApp/Testing/Python/FiducialLayoutSwitchBug1914.py index 5e8cddb0afe5317e2c9338e68ddc9798b026e247..9f5735550c6bc35c29a378087ad1d1e882a50f5f 100644 --- a/Applications/SlicerApp/Testing/Python/FiducialLayoutSwitchBug1914.py +++ b/Applications/SlicerApp/Testing/Python/FiducialLayoutSwitchBug1914.py @@ -135,8 +135,8 @@ class FiducialLayoutSwitchBug1914Logic(ScriptedLoadableModuleLogic): self.delayDisplay("Conventional view") # Download MRHead from sample data - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] # Place a fiducial on the red slice markupsLogic = slicer.modules.markups.logic() diff --git a/Applications/SlicerApp/Testing/Python/RSNAQuantTutorial.py b/Applications/SlicerApp/Testing/Python/RSNAQuantTutorial.py index 6d9e9f92569acff438f04bd272b55fc82f8a0d91..c09997bee25ad98c84bb1a800b987601f86980ac 100644 --- a/Applications/SlicerApp/Testing/Python/RSNAQuantTutorial.py +++ b/Applications/SlicerApp/Testing/Python/RSNAQuantTutorial.py @@ -158,8 +158,8 @@ class RSNAQuantTutorialTest(ScriptedLoadableModuleTest): # # first, get some data # - from SampleData import SampleDataLogic - tumor = SampleDataLogic().downloadMRBrainTumor1() + import SampleData + tumor = SampleData.downloadSample('MRBrainTumor1')[0] try: # four up view diff --git a/Applications/SlicerApp/Testing/Python/SlicerBoundsTest.py b/Applications/SlicerApp/Testing/Python/SlicerBoundsTest.py index 4a5a1f2606b67f0850813d6c198294f84fdfcda1..463b8b1e9c5c8884a9dd524ea63967b9f443716d 100644 --- a/Applications/SlicerApp/Testing/Python/SlicerBoundsTest.py +++ b/Applications/SlicerApp/Testing/Python/SlicerBoundsTest.py @@ -71,8 +71,8 @@ class SlicerBoundsTestTest(ScriptedLoadableModuleTest): """ Test the GetRASBounds & GetBounds method on a volume. """ #self.delayDisplay("Starting test_Volume") - from SampleData import SampleDataLogic - volumeNode = SampleDataLogic().downloadAbdominalCTVolume() + import SampleData + volumeNode = SampleData.downloadSample('CTA abdomen\n(Panoramix)')[0] bounds = range(6) volumeNode.GetRASBounds(bounds) diff --git a/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreLoopTest.py b/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreLoopTest.py index 5ca879b994cd2dc88ec6ddf0979f970641a63412..31d6afa287942aac9f5bfc6ddcbc8465b38129ef 100644 --- a/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreLoopTest.py +++ b/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreLoopTest.py @@ -89,8 +89,8 @@ class SlicerMRBMultipleSaveRestoreLoop(ScriptedLoadableModuleTest): # first, get the data # print("Getting MR Head Volume") - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] # Place a fiducial markupsLogic = slicer.modules.markups.logic() diff --git a/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreTest.py b/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreTest.py index 7cdb318277aef05a6df6f8b774bf7059a85b66c8..47e3c6a6e878a7b6faac5dcd1af795d4bf8bb72c 100644 --- a/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreTest.py +++ b/Applications/SlicerApp/Testing/Python/SlicerMRBMultipleSaveRestoreTest.py @@ -86,8 +86,8 @@ class SlicerMRBMultipleSaveRestore(ScriptedLoadableModuleTest): # first, get the data # print("Getting MR Head Volume") - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] # Place a fiducial markupsLogic = slicer.modules.markups.logic() diff --git a/Applications/SlicerApp/Testing/Python/SlicerMRBSaveRestoreCheckPathsTest.py b/Applications/SlicerApp/Testing/Python/SlicerMRBSaveRestoreCheckPathsTest.py index 8eae0afb9bbcb127ed13539b523c8f76abaa29d4..fe30276882a7e973aec50afb19a9976bf528f0d7 100644 --- a/Applications/SlicerApp/Testing/Python/SlicerMRBSaveRestoreCheckPathsTest.py +++ b/Applications/SlicerApp/Testing/Python/SlicerMRBSaveRestoreCheckPathsTest.py @@ -154,8 +154,8 @@ class SlicerMRBSaveRestoreCheckPaths(ScriptedLoadableModuleTest): # first, get the volume data # print("Getting MR Head Volume") - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] slicer.util.delayDisplay('Finished with download of volume') diff --git a/Applications/SlicerApp/Testing/Python/SlicerOrientationSelectorTest.py b/Applications/SlicerApp/Testing/Python/SlicerOrientationSelectorTest.py index bde74195212d5a28b62d9ef6b0bdc290c43fcde4..c28ef5f8f368ac16ea5a5262080f4c79cce8c4b0 100644 --- a/Applications/SlicerApp/Testing/Python/SlicerOrientationSelectorTest.py +++ b/Applications/SlicerApp/Testing/Python/SlicerOrientationSelectorTest.py @@ -100,8 +100,8 @@ class SlicerOrientationSelectorTestTest(ScriptedLoadableModuleTest): logic = SlicerOrientationSelectorTestLogic() self.delayDisplay("Starting the test") - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] slicer.util.selectModule('Reformat') diff --git a/Applications/SlicerApp/Testing/Python/SlicerTransformInteractionTest1.py b/Applications/SlicerApp/Testing/Python/SlicerTransformInteractionTest1.py index c68cae57552474f64da6012ff2757a811e729960..af6642469cac5919df5cff5691f009beafc76573 100644 --- a/Applications/SlicerApp/Testing/Python/SlicerTransformInteractionTest1.py +++ b/Applications/SlicerApp/Testing/Python/SlicerTransformInteractionTest1.py @@ -135,8 +135,8 @@ class SlicerTransformInteractionTest1Test(ScriptedLoadableModuleTest): """ logic = SlicerTransformInteractionTest1Logic() - from SampleData import SampleDataLogic - volume = SampleDataLogic().downloadAbdominalCTVolume() + import SampleData + volume = SampleData.downloadSample('CTA abdomen\n(Panoramix)')[0] #self.delayDisplay("Starting test_3D_interactionVolume") logic = SlicerTransformInteractionTest1Logic() diff --git a/Applications/SlicerApp/Testing/Python/UtilTest.py b/Applications/SlicerApp/Testing/Python/UtilTest.py index 1987501b66608294f66e2282796d8fbd8d7af6cb..7735829a6ec9496e9f116e6df638930126ad302d 100644 --- a/Applications/SlicerApp/Testing/Python/UtilTest.py +++ b/Applications/SlicerApp/Testing/Python/UtilTest.py @@ -96,11 +96,11 @@ class UtilTestTest(ScriptedLoadableModuleTest): self.assertIsNone(redSliceCompositeNode.GetForegroundVolumeID()) self.assertIsNone(redSliceCompositeNode.GetLabelVolumeID()) - from SampleData import SampleDataLogic + import SampleData - backgroundNode = SampleDataLogic().downloadMRHead() + backgroundNode = SampleData.downloadSample("MRHead")[0] backgroundNode.SetName('Background') - foregroundNode = SampleDataLogic().downloadMRHead() + foregroundNode = SampleData.downloadSample("MRHead")[0] 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 = SampleDataLogic().downloadMRHead() + otherBackgroundNode = SampleData.downloadSample("MRHead")[0] otherBackgroundNode.SetName('OtherBackground') - otherForegroundNode = SampleDataLogic().downloadMRHead() + otherForegroundNode = SampleData.downloadSample("MRHead")[0] otherForegroundNode.SetName('OtherForeground') otherLabelmapNode = volumesLogic.CreateAndAddLabelVolume( slicer.mrmlScene, backgroundNode, 'OtherLabelmap' ) @@ -199,8 +199,8 @@ class UtilTestTest(ScriptedLoadableModuleTest): # Test if retrieving voxels as a numpy array works self.delayDisplay('Download sample data') - from SampleData import SampleDataLogic - volumeNode = SampleDataLogic().downloadMRHead() + import SampleData + volumeNode = SampleData.downloadSample("MRHead")[0] self.delayDisplay('Test voxel value read') voxelPos = [120,135,89] @@ -221,8 +221,8 @@ class UtilTestTest(ScriptedLoadableModuleTest): # Test if updating voxels from a numpy array works self.delayDisplay('Download sample data') - from SampleData import SampleDataLogic - volumeNode = SampleDataLogic().downloadMRHead() + import SampleData + volumeNode = SampleData.downloadSample("MRHead")[0] import numpy as np import math @@ -254,8 +254,8 @@ class UtilTestTest(ScriptedLoadableModuleTest): self.assertEqual(tableNode1.GetNumberOfRows(), 3) self.delayDisplay('Download sample data') - from SampleData import SampleDataLogic - volumeNode = SampleDataLogic().downloadMRHead() + import SampleData + volumeNode = SampleData.downloadSample("MRHead")[0] self.delayDisplay('Compute histogram') histogram = np.histogram(slicer.util.arrayFromVolume(volumeNode)) @@ -290,8 +290,8 @@ class UtilTestTest(ScriptedLoadableModuleTest): # Test if convenience function of getting numpy array from various nodes works self.delayDisplay('Test array with scalar image') - from SampleData import SampleDataLogic - volumeNode = SampleDataLogic().downloadMRHead() + import SampleData + volumeNode = SampleData.downloadSample("MRHead")[0] 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 = SampleDataLogic().downloadDTIBrain() + tensorVolumeNode = SampleData.downloadSample('DTIBrain')[0] narray = slicer.util.array(tensorVolumeNode.GetName()) self.assertEqual(narray.shape, (85, 144, 144, 3, 3)) diff --git a/Applications/SlicerApp/Testing/Python/ViewControllersSliceInterpolationBug1926.py b/Applications/SlicerApp/Testing/Python/ViewControllersSliceInterpolationBug1926.py index 52aa77fdfa250df4182156381e1ab5baf34eeece..e0a63a968d84e346926d14351d41e4955bce0765 100644 --- a/Applications/SlicerApp/Testing/Python/ViewControllersSliceInterpolationBug1926.py +++ b/Applications/SlicerApp/Testing/Python/ViewControllersSliceInterpolationBug1926.py @@ -96,9 +96,9 @@ class ViewControllersSliceInterpolationBug1926Test(ScriptedLoadableModuleTest): # first, get some data # self.delayDisplay("Getting Data") - from SampleData import SampleDataLogic - head = SampleDataLogic().downloadMRHead() - tumor = SampleDataLogic().downloadMRBrainTumor1() + import SampleData + head = SampleData.downloadSample("MRHead")[0] + tumor = SampleData.downloadSample('MRBrainTumor1')[0] # Change to a CompareView ln = slicer.util.getNode(pattern='vtkMRMLLayoutNode*') diff --git a/Applications/SlicerApp/Testing/Python/sceneImport2428.py b/Applications/SlicerApp/Testing/Python/sceneImport2428.py index aca2f1d25cad8ec5e334467e33baa855d228865f..c7c5ba940b06700fc268f5bd8a832b0e37aa0e94 100644 --- a/Applications/SlicerApp/Testing/Python/sceneImport2428.py +++ b/Applications/SlicerApp/Testing/Python/sceneImport2428.py @@ -97,8 +97,8 @@ class sceneImport2428Test(ScriptedLoadableModuleTest): # first, get some data # self.delayDisplay("Getting Data") - from SampleData import SampleDataLogic - head = SampleDataLogic().downloadMRHead() + import SampleData + head = SampleData.downloadSample("MRHead")[0] # # create a label map and set it for editing diff --git a/Base/Python/slicer/util.py b/Base/Python/slicer/util.py index cb9d2d1ed7eea0bc84089d70c31a95679d4e0749..83db6917c77fa56fa81297cc9e94f82c38899ef7 100644 --- a/Base/Python/slicer/util.py +++ b/Base/Python/slicer/util.py @@ -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.SampleDataLogic().downloadMRHead() + volumeNode = SampleData.downloadSample("MRHead")[0] # 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.SampleDataLogic().downloadMRHead() + volumeNode = SampleData.downloadSample("MRHead")[0] # Create variable that will store plot nodes (chart, table, series) plotNodes = {} diff --git a/Base/Python/tests/test_sitkUtils.py b/Base/Python/tests/test_sitkUtils.py index c6ebe1ef23734ce4463432514362eb200b9211e8..cef301e3b12e8484b82c0c508ecc7232b2619cda 100644 --- a/Base/Python/tests/test_sitkUtils.py +++ b/Base/Python/tests/test_sitkUtils.py @@ -13,8 +13,8 @@ class SitkUtilsTests(unittest.TestCase): """ Download the MRHead node """ - from SampleData import SampleDataLogic - SampleDataLogic().downloadMRHead() + import SampleData + SampleData.downloadSample("MRHead")[0] volumeNode1 = slicer.util.getNode('MRHead') self.assertEqual(volumeNode1.GetName(), "MRHead") @@ -86,8 +86,8 @@ class SitkUtilsTests(unittest.TestCase): """ Download the MRHead node """ - from SampleData import SampleDataLogic - SampleDataLogic().downloadMRHead() + import SampleData + SampleData.downloadSample("MRHead")[0] volumeNode1 = slicer.util.getNode('MRHead') self.assertEqual(volumeNode1.GetName(), "MRHead") diff --git a/Extensions/Testing/ScriptedSegmentEditorEffectExtensionTemplate/ScriptedSegmentEditorEffectModuleTemplate/SegmentEditorScriptedSegmentEditorEffectModuleTemplate.py b/Extensions/Testing/ScriptedSegmentEditorEffectExtensionTemplate/ScriptedSegmentEditorEffectModuleTemplate/SegmentEditorScriptedSegmentEditorEffectModuleTemplate.py index ce0c39c82ad4edcd90a806aaf05e7905ff2153e1..3cc8dc65f2c432b94b79d5b0e5746bbd3ba789e0 100644 --- a/Extensions/Testing/ScriptedSegmentEditorEffectExtensionTemplate/ScriptedSegmentEditorEffectModuleTemplate/SegmentEditorScriptedSegmentEditorEffectModuleTemplate.py +++ b/Extensions/Testing/ScriptedSegmentEditorEffectExtensionTemplate/ScriptedSegmentEditorEffectModuleTemplate/SegmentEditorScriptedSegmentEditorEffectModuleTemplate.py @@ -66,8 +66,8 @@ class SegmentEditorScriptedSegmentEditorEffectModuleTemplateTest(ScriptedLoadabl ################################## self.delayDisplay("Load master volume") - from SampleData import SampleDataLogic - masterVolumeNode = SampleDataLogic().downloadMRBrainTumor1() + import SampleData + masterVolumeNode = SampleData.downloadSample('MRBrainTumor1')[0] ################################## self.delayDisplay("Create segmentation containing a few spheres") diff --git a/Modules/Loadable/CropVolume/Testing/Python/CropVolumeSelfTest.py b/Modules/Loadable/CropVolume/Testing/Python/CropVolumeSelfTest.py index fb978a976a8b025a12f1e354364455f32bb17fc2..6d724b95b0558f3d0e380084460dc5e7c92b65f9 100644 --- a/Modules/Loadable/CropVolume/Testing/Python/CropVolumeSelfTest.py +++ b/Modules/Loadable/CropVolume/Testing/Python/CropVolumeSelfTest.py @@ -58,9 +58,9 @@ class CropVolumeSelfTestTest(ScriptedLoadableModuleTest): print("Running CropVolumeSelfTest Test case:") - from SampleData import SampleDataLogic + import SampleData - vol = SampleDataLogic().downloadMRHead() + vol = SampleData.downloadSample("MRHead")[0] 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 = SampleDataLogic().downloadMRHead() + vol = SampleData.downloadSample("MRHead")[0] roi = slicer.vtkMRMLAnnotationROINode() roi.Initialize(slicer.mrmlScene) cropVolumeNode.SetInputVolumeNodeID(vol.GetID()) diff --git a/Modules/Loadable/Markups/Testing/Python/MarkupsInCompareViewersSelfTest.py b/Modules/Loadable/Markups/Testing/Python/MarkupsInCompareViewersSelfTest.py index 5c70de08e9c4858628e21965e3757450eb68b0d8..3ac5ef23f0467c9a99467ff278fc20d523260d72 100644 --- a/Modules/Loadable/Markups/Testing/Python/MarkupsInCompareViewersSelfTest.py +++ b/Modules/Loadable/Markups/Testing/Python/MarkupsInCompareViewersSelfTest.py @@ -80,8 +80,8 @@ class MarkupsInCompareViewersSelfTestLogic(ScriptedLoadableModuleLogic): # first load the data # print("Getting MR Head Volume") - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] # # link the viewers diff --git a/Modules/Loadable/Markups/Testing/Python/MarkupsInViewsSelfTest.py b/Modules/Loadable/Markups/Testing/Python/MarkupsInViewsSelfTest.py index 7d83be338ae64d58792fac91244083910cf3186d..620208d839b126d43b09b61731025e4f9ae1d867 100644 --- a/Modules/Loadable/Markups/Testing/Python/MarkupsInViewsSelfTest.py +++ b/Modules/Loadable/Markups/Testing/Python/MarkupsInViewsSelfTest.py @@ -135,8 +135,8 @@ class MarkupsInViewsSelfTestLogic(ScriptedLoadableModuleLogic): # first load the data # print("Getting MR Head Volume") - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] # # link the viewers diff --git a/Modules/Loadable/Markups/Testing/Python/NeurosurgicalPlanningTutorialMarkupsSelfTest.py b/Modules/Loadable/Markups/Testing/Python/NeurosurgicalPlanningTutorialMarkupsSelfTest.py index 91b477ded53aa5772cdfed9f5f8bc0fd190d835f..2799b5a31b029a934b71ef3e38d3836c5213f207 100644 --- a/Modules/Loadable/Markups/Testing/Python/NeurosurgicalPlanningTutorialMarkupsSelfTest.py +++ b/Modules/Loadable/Markups/Testing/Python/NeurosurgicalPlanningTutorialMarkupsSelfTest.py @@ -143,8 +143,8 @@ class NeurosurgicalPlanningTutorialMarkupsSelfTestLogic(ScriptedLoadableModuleLo # use the sample data module logic to load data for the self test self.delayDisplay("Getting Baseline volume") - from SampleData import SampleDataLogic - baselineVolume = SampleDataLogic().downloadWhiteMatterExplorationBaselineVolume() + import SampleData + baselineVolume = SampleData.downloadSample('BaselineVolume')[0] self.takeScreenshot('NeurosurgicalPlanning-Loaded','Data loaded') diff --git a/Modules/Loadable/SceneViews/Testing/Python/AddStorableDataAfterSceneViewTest.py b/Modules/Loadable/SceneViews/Testing/Python/AddStorableDataAfterSceneViewTest.py index 8f1e1194ae2987e6e0ed2405614649d34fae8130..99245fc211db474ef155154ec30ecb6a77a42861 100644 --- a/Modules/Loadable/SceneViews/Testing/Python/AddStorableDataAfterSceneViewTest.py +++ b/Modules/Loadable/SceneViews/Testing/Python/AddStorableDataAfterSceneViewTest.py @@ -156,8 +156,8 @@ class AddStorableDataAfterSceneViewTestTest(ScriptedLoadableModuleTest): # add another storable node, a volume # slicer.util.delayDisplay("Adding a new storable node, after creating a scene view") - from SampleData import SampleDataLogic - mrHeadVolume = SampleDataLogic().downloadMRHead() + import SampleData + mrHeadVolume = SampleData.downloadSample("MRHead")[0] mrHeadID = mrHeadVolume.GetID() # @@ -178,7 +178,7 @@ class AddStorableDataAfterSceneViewTestTest(ScriptedLoadableModuleTest): # # add new storable again - mrHeadVolume = SampleDataLogic().downloadMRHead() + mrHeadVolume = SampleData.downloadSample("MRHead")[0] mrHeadID = mrHeadVolume.GetID() # diff --git a/Modules/Loadable/Segmentations/Testing/Python/SegmentationWidgetsTest1.py b/Modules/Loadable/Segmentations/Testing/Python/SegmentationWidgetsTest1.py index 4044aaa8f01912877b5b53551d511901eff6f92e..985155337cbe3077224913dfb0dd4c4902ce9813 100644 --- a/Modules/Loadable/Segmentations/Testing/Python/SegmentationWidgetsTest1.py +++ b/Modules/Loadable/Segmentations/Testing/Python/SegmentationWidgetsTest1.py @@ -132,9 +132,9 @@ class SegmentationWidgetsTest1(ScriptedLoadableModuleTest): closedSurfaceReprName = vtkSegmentationCore.vtkSegmentationConverter.GetClosedSurfaceRepresentationName() # Use MRHead and Tinypatient for testing - from SampleData import SampleDataLogic - mrVolumeNode = SampleDataLogic().downloadMRHead() - [tinyVolumeNode, tinySegmentationNode] = SampleDataLogic().downloadSample('TinyPatient') + import SampleData + mrVolumeNode = SampleData.downloadSample("MRHead")[0] + [tinyVolumeNode, tinySegmentationNode] = SampleData.downloadSample('TinyPatient') # Convert MRHead to oriented image data import vtkSlicerSegmentationsModuleLogicPython as vtkSlicerSegmentationsModuleLogic diff --git a/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingSceneClose.py b/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingSceneClose.py index 1bb05274ade075af974530fee0cff727d76f8259..c75a9c2533aa0687511dbc840372317811765253 100644 --- a/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingSceneClose.py +++ b/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingSceneClose.py @@ -97,8 +97,8 @@ class VolumeRenderingSceneCloseLogic(ScriptedLoadableModuleLogic): self.delayDisplay('Running the aglorithm') - from SampleData import SampleDataLogic - ctVolume = SampleDataLogic().downloadCTChest() + import SampleData + ctVolume = SampleData.downloadSample('CTChest')[0] self.delayDisplay('Downloaded CT sample data') # go to the volume rendering module diff --git a/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingThreeDOnlyLayout.py b/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingThreeDOnlyLayout.py index a08071fb00d6499c64f452cdd80ab2b969486d2b..148f09396e562196bc2333314d0220369b8e8d1a 100644 --- a/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingThreeDOnlyLayout.py +++ b/Modules/Loadable/VolumeRendering/Testing/Python/VolumeRenderingThreeDOnlyLayout.py @@ -34,8 +34,8 @@ class VolumeRenderingThreeDOnlyLayout(ScriptedLoadableModuleTest): layoutManager.setMRMLScene(mrmlScene) # Load MRHead volume - from SampleData import SampleDataLogic - SampleDataLogic().downloadMRHead() + import SampleData + SampleData.downloadSample("MRHead")[0] # Enter the volume rendering module slicer.util.mainWindow().moduleSelector().selectModule('VolumeRendering') diff --git a/Modules/Loadable/Volumes/Testing/Python/LoadVolumeDisplaybleSceneModelClose.py b/Modules/Loadable/Volumes/Testing/Python/LoadVolumeDisplaybleSceneModelClose.py index 720dcf4edd758f5d479bdc9c2fea87ec30a2fb7c..82892899e240319443858251b9857fe08c10f1fa 100644 --- a/Modules/Loadable/Volumes/Testing/Python/LoadVolumeDisplaybleSceneModelClose.py +++ b/Modules/Loadable/Volumes/Testing/Python/LoadVolumeDisplaybleSceneModelClose.py @@ -17,8 +17,8 @@ class VolumesLoadSceneCloseTesting(ScriptedLoadableModuleTest): # # first, get some sample data # - from SampleData import SampleDataLogic - SampleDataLogic().downloadMRHead() + import SampleData + SampleData.downloadSample("MRHead")[0] # # enter the models module diff --git a/Modules/Loadable/Volumes/Testing/Python/VolumesLogicCompareVolumeGeometry.py b/Modules/Loadable/Volumes/Testing/Python/VolumesLogicCompareVolumeGeometry.py index 7548784a98561c5223de9ada9be838ea898724b7..9d342022e820c8e1fc47fb4f3ff09bf50d2fc2ca 100644 --- a/Modules/Loadable/Volumes/Testing/Python/VolumesLogicCompareVolumeGeometry.py +++ b/Modules/Loadable/Volumes/Testing/Python/VolumesLogicCompareVolumeGeometry.py @@ -18,8 +18,8 @@ class VolumesLogicCompareVolumeGeometryTesting(ScriptedLoadableModuleTest): # # first, get some sample data # - from SampleData import SampleDataLogic - head = SampleDataLogic().downloadMRHead() + import SampleData + head = SampleData.downloadSample("MRHead")[0] # # get the volumes logic and print out default epsilon and precision diff --git a/Modules/Scripted/EditorLib/Testing/StandaloneEditorWidgetTest.py b/Modules/Scripted/EditorLib/Testing/StandaloneEditorWidgetTest.py index 49ce46d79e343fba889e230eea3ab4d6c75e8623..ec012b996909aa999e3c7a5f349e48b8786e15a3 100644 --- a/Modules/Scripted/EditorLib/Testing/StandaloneEditorWidgetTest.py +++ b/Modules/Scripted/EditorLib/Testing/StandaloneEditorWidgetTest.py @@ -30,8 +30,8 @@ class EditorLibTesting(ScriptedLoadableModuleTest): # # first, get some sample data # - from SampleData import SampleDataLogic - head = SampleDataLogic().downloadMRHead() + import SampleData + head = SampleData.downloadSample("MRHead")[0] # # create a label map and set it for editing diff --git a/Modules/Scripted/EditorLib/Testing/ThresholdThreadingTest.py b/Modules/Scripted/EditorLib/Testing/ThresholdThreadingTest.py index e56bff3989d8bee7864ca57f7b9beb91854514e5..eeaf15a40e2c865a30b9a4bd63218469b78da516 100644 --- a/Modules/Scripted/EditorLib/Testing/ThresholdThreadingTest.py +++ b/Modules/Scripted/EditorLib/Testing/ThresholdThreadingTest.py @@ -58,8 +58,8 @@ class ThresholdThreadingTestTest(ScriptedLoadableModuleTest): # first, get some sample data # self.delayDisplay("Get some data") - from SampleData import SampleDataLogic - head = SampleDataLogic().downloadMRHead() + import SampleData + head = SampleData.downloadSample("MRHead")[0] # # now, define an ROI in it diff --git a/Modules/Scripted/LabelStatistics/LabelStatistics.py b/Modules/Scripted/LabelStatistics/LabelStatistics.py index 7c18d501506b7825bffa9352b9b1b5f95c7b815e..6f521fe5114f8c737bf36803950555410e0860cb 100644 --- a/Modules/Scripted/LabelStatistics/LabelStatistics.py +++ b/Modules/Scripted/LabelStatistics/LabelStatistics.py @@ -517,9 +517,9 @@ class LabelStatisticsTest(ScriptedLoadableModuleTest): # # first, get some data # - from SampleData import SampleDataLogic - mrHead = SampleDataLogic().downloadMRHead() - ctChest = SampleDataLogic().downloadCTChest() + import SampleData + mrHead = SampleData.downloadSample("MRHead")[0] + ctChest = SampleData.downloadSample('CTChest')[0] self.delayDisplay('Two data sets loaded') volumesLogic = slicer.modules.volumes.logic() diff --git a/Modules/Scripted/PerformanceTests/PerformanceTests.py b/Modules/Scripted/PerformanceTests/PerformanceTests.py index 9cfa63c38e4e1d7319c1cd0fecd7a5fe8d278b72..3b6c8fc2ae1b4d2db047e151d1e37ad136549e2d 100644 --- a/Modules/Scripted/PerformanceTests/PerformanceTests.py +++ b/Modules/Scripted/PerformanceTests/PerformanceTests.py @@ -54,10 +54,10 @@ class PerformanceTestsWidget(ScriptedLoadableModuleWidget): self.layout.addStretch(1) def downloadMRHead(self): - from SampleData import SampleDataLogic + import SampleData self.log.insertHtml('Requesting downloading MRHead') self.log.repaint() - mrHeadVolume = SampleDataLogic().downloadMRHead() + mrHeadVolume = SampleData.downloadSample("MRHead")[0] if mrHeadVolume: self.log.insertHtml('finished.\n') self.log.insertPlainText('\n') diff --git a/Modules/Scripted/SampleData/SampleData.py b/Modules/Scripted/SampleData/SampleData.py index 239226b1e7ac3fd21ba29ee3adb27de27a634713..cc24d16173ca6a627629eeec5082aaa6f5c0cb9f 100644 --- a/Modules/Scripted/SampleData/SampleData.py +++ b/Modules/Scripted/SampleData/SampleData.py @@ -37,6 +37,11 @@ def downloadFromURL(uris, fileNames, nodeNames=None, uris, fileNames, nodeNames, customDownloader, loadFileTypes, loadFileProperties) +def downloadSample(sampleName): + """For a given sample name this will search the available sources + and load it if it is available. Returns the loaded nodes.""" + return SampleDataLogic().downloadSample(sampleName) + # # SampleData # diff --git a/Modules/Scripted/ScreenCapture/ScreenCapture.py b/Modules/Scripted/ScreenCapture/ScreenCapture.py index f6e22054ceedb2a2174ccabab5c98c9b7d1b3e4c..e8f83c13d24c09e8eb6fc3cb2e2ead66b98d6582 100644 --- a/Modules/Scripted/ScreenCapture/ScreenCapture.py +++ b/Modules/Scripted/ScreenCapture/ScreenCapture.py @@ -1130,9 +1130,9 @@ class ScreenCaptureTest(ScriptedLoadableModuleTest): """ Do whatever is needed to reset the state - typically a scene clear will be enough. """ slicer.mrmlScene.Clear(0) - from SampleData import SampleDataLogic - self.image1 = SampleDataLogic().downloadMRBrainTumor1() - self.image2 = SampleDataLogic().downloadMRBrainTumor2() + import SampleData + self.image1 = SampleData.downloadSample('MRBrainTumor1')[0] + self.image2 = SampleData.downloadSample('MRBrainTumor2')[0] # make the output volume appear in all the slice views selectionNode = slicer.app.applicationLogic().GetSelectionNode() diff --git a/Modules/Scripted/SegmentStatistics/SegmentStatistics.py b/Modules/Scripted/SegmentStatistics/SegmentStatistics.py index 1aaca31c5619d776233536dd9ea2a4c710f6ded5..c1e3bcf8311d7d8c9710b9c871fdd21d6d5ec3e0 100644 --- a/Modules/Scripted/SegmentStatistics/SegmentStatistics.py +++ b/Modules/Scripted/SegmentStatistics/SegmentStatistics.py @@ -645,12 +645,12 @@ class SegmentStatisticsTest(ScriptedLoadableModuleTest): self.delayDisplay("Starting test_SegmentStatisticsBasic") import vtkSegmentationCorePython as vtkSegmentationCore - from SampleData import SampleDataLogic + import SampleData from SegmentStatistics import SegmentStatisticsLogic self.delayDisplay("Load master volume") - masterVolumeNode = SampleDataLogic().downloadMRBrainTumor1() + masterVolumeNode = SampleData.downloadSample('MRBrainTumor1')[0] self.delayDisplay("Create segmentation containing a few spheres") @@ -703,12 +703,12 @@ class SegmentStatisticsTest(ScriptedLoadableModuleTest): self.delayDisplay("Starting test_SegmentStatisticsPlugins") import vtkSegmentationCorePython as vtkSegmentationCore - from SampleData import SampleDataLogic + import SampleData from SegmentStatistics import SegmentStatisticsLogic self.delayDisplay("Load master volume") - masterVolumeNode = SampleDataLogic().downloadMRBrainTumor1() + masterVolumeNode = SampleData.downloadSample('MRBrainTumor1')[0] self.delayDisplay("Create segmentation containing a few spheres") diff --git a/Utilities/Templates/Modules/ScriptedSegmentEditorEffect/SegmentEditorTemplateKey.py b/Utilities/Templates/Modules/ScriptedSegmentEditorEffect/SegmentEditorTemplateKey.py index de4a6f7fcf1d53e7c0c956b27b60419fc8f20608..02f2ada775beee9a5f3510fe0682c22bceb5777d 100644 --- a/Utilities/Templates/Modules/ScriptedSegmentEditorEffect/SegmentEditorTemplateKey.py +++ b/Utilities/Templates/Modules/ScriptedSegmentEditorEffect/SegmentEditorTemplateKey.py @@ -60,13 +60,13 @@ class SegmentEditorTemplateKeyTest(ScriptedLoadableModuleTest): import vtkSegmentationCorePython as vtkSegmentationCore import vtkSlicerSegmentationsModuleLogicPython as vtkSlicerSegmentationsModuleLogic - from SampleData import SampleDataLogic + import SampleData from SegmentStatistics import SegmentStatisticsLogic ################################## self.delayDisplay("Load master volume") - masterVolumeNode = SampleDataLogic().downloadMRBrainTumor1() + masterVolumeNode = SampleData.downloadSample('MRBrainTumor1')[0] ################################## self.delayDisplay("Create segmentation containing a few spheres")