当前位置: 首页>>代码示例>>Python>>正文


Python SampleData类代码示例

本文整理汇总了Python中SampleData的典型用法代码示例。如果您正苦于以下问题:Python SampleData类的具体用法?Python SampleData怎么用?Python SampleData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SampleData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_LoadVolumeCloseScene

  def test_LoadVolumeCloseScene(self):
    """
    Load a volume, go to a module that has a displayable scene model set for the tree view, then close the scene.
    Tests the case of closing a scene with a displayable node in it while a GUI is up that is showing a tree view with a displayable scene model (display nodes are set to null during scene closing and can trigger events).
    """
    self.delayDisplay("Starting the test")

    #
    # first, get some sample data
    #
    import SampleData
    SampleData.downloadSample("MRHead")

    #
    # enter the models module
    #
    mainWindow = slicer.util.mainWindow()
    mainWindow.moduleSelector().selectModule('Models')

    #
    # close the scene
    #
    slicer.mrmlScene.Clear(0)

    self.delayDisplay('Test passed')
开发者ID:BRAINSia,项目名称:Slicer,代码行数:25,代码来源:LoadVolumeDisplaybleSceneModelClose.py

示例2: _context

def _context():
    gwas = _gwas()
    model = _prediction_model()
    s = SampleData.dataframe_from_covariance(SampleData.sample_covariance_s_1())
    covariance = MatrixManager.MatrixManager(s, D)
    c = Utilities._build_context(model, covariance, gwas)
    return c
开发者ID:torstees,项目名称:MetaXcan,代码行数:7,代码来源:test_association_calculation.py

示例3: test_LabelStatisticsBasic

  def test_LabelStatisticsBasic(self):
    """
    This tests some aspects of the label statistics
    """

    self.delayDisplay("Starting test_LabelStatisticsBasic")
    #
    # first, get some data
    #
    import SampleData
    mrHead = SampleData.downloadSample("MRHead")
    ctChest = SampleData.downloadSample('CTChest')
    self.delayDisplay('Two data sets loaded')

    volumesLogic = slicer.modules.volumes.logic()

    mrHeadLabel = volumesLogic.CreateAndAddLabelVolume( slicer.mrmlScene, mrHead, "mrHead-label" )

    warnings = volumesLogic.CheckForLabelVolumeValidity(ctChest, mrHeadLabel)

    self.delayDisplay("Warnings for mismatch:\n%s" % warnings)

    self.assertNotEqual( warnings, "" )

    warnings = volumesLogic.CheckForLabelVolumeValidity(mrHead, mrHeadLabel)

    self.delayDisplay("Warnings for match:\n%s" % warnings)

    self.assertEqual( warnings, "" )

    self.delayDisplay('test_LabelStatisticsBasic passed!')
开发者ID:Slicer,项目名称:Slicer,代码行数:31,代码来源:LabelStatistics.py

示例4: test_RSNA2012ProstateDemo

  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')
开发者ID:BRAINSia,项目名称:Slicer,代码行数:25,代码来源:RSNA2012ProstateDemo.py

示例5: test_VolumeRenderThreeDOnlyLayout

    def test_VolumeRenderThreeDOnlyLayout(self):
        """
        Test that the following workflow does not segfault:
        - Set 3D-only layout, reinitialize slice widgets
        - Load volume
        - Enter the volume rendering module
        """
        self.delayDisplay("Starting the test")

        # Set 3D-only layout
        layoutManager = slicer.app.layoutManager()
        layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUp3DView)

        # Reinitialize MRML scene to force re-creating slice widgets
        mrmlScene = layoutManager.mrmlScene()
        layoutManager.setMRMLScene(None)
        layoutManager.setMRMLScene(mrmlScene)

        # Load MRHead volume
        import SampleData
        SampleData.downloadSample("MRHead")

        # Enter the volume rendering module
        slicer.util.mainWindow().moduleSelector().selectModule('VolumeRendering')

        self.delayDisplay('Test passed!')
开发者ID:BRAINSia,项目名称:Slicer,代码行数:26,代码来源:VolumeRenderingThreeDOnlyLayout.py

示例6: test_DataProbe1

  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!')
开发者ID:cpinter,项目名称:Slicer,代码行数:28,代码来源:DataProbe.py

示例7: test_gwas_from_data

    def test_gwas_from_data(self):
        gwas = GWASUtilities.gwas_from_data(SampleData.sample_gwas_data_1())
        assert_gwas_1(self, gwas)

        gwas = GWASUtilities.gwas_from_data(SampleData.sample_gwas_data_2())
        assert_gwas_2(self, gwas)

        gwas = GWASUtilities.gwas_from_data(SampleData.sample_gwas_data_1_e(), extra_columns=[("number",6), ("character",7)])
        assert_gwas_1_e(self, gwas)
开发者ID:jiamaozheng,项目名称:MetaXcan,代码行数:9,代码来源:test_gwas_utilities.py

示例8: test_intersection_d

    def test_intersection_d(self):
        gwas = SampleData.dataframe_from_gwas(SampleData.sample_gwas_data_4())
        p = _prediction_model()
        g, s = Utilities._data_intersection(p, gwas)
        self.assertEqual(set(s), set(['rs1666', 'rs1', 'rs2', 'rs3', 'rs6', 'rs7', 'rs7666', 'rs8', 'rs9','rs100', 'rs101', 'rs102', 'rs202', 'rs401', 'rs402']))
        self.assertEqual(set(g), set(["A","B","C","D","F","G"]))

        t_gwas = gwas[3:10]
        g, s = Utilities._data_intersection(p, t_gwas)
        self.assertEqual(set(s), set(['rs3', 'rs6', 'rs7', 'rs7666', 'rs8', 'rs9']))
        self.assertEqual(set(g), set(["B"]))
开发者ID:torstees,项目名称:MetaXcan,代码行数:11,代码来源:test_association_calculation.py

示例9: test_SubjectHierarchyReference

  def test_SubjectHierarchyReference(self):
    self.delayDisplay('Test that output node moved to referenced node location in subject hierarchy')

    self.delayDisplay('Load input volume')
    import SampleData
    inputVolume = SampleData.downloadSample("MRHead")

    self.delayDisplay('Create subject hierarchy of input volume')
    shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
    self.patientItemID = shNode.CreateSubjectItem(shNode.GetSceneItemID(), "John Doe")
    self.studyItemID = shNode.CreateStudyItem(self.patientItemID, "Some study")
    self.folderItemID = shNode.CreateFolderItem(self.studyItemID, "Some group")
    shNode.SetItemParent(shNode.GetItemByDataNode(inputVolume), self.folderItemID)

    outputVolume = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode")
    # New node is expected to be created in the subject hierarchy root
    self.assertEqual(shNode.GetItemParent(shNode.GetItemByDataNode(outputVolume)), shNode.GetSceneItemID())

    self.delayDisplay('Run CLI module')
    cliParams = {'InputVolume': inputVolume.GetID(), 'OutputVolume': outputVolume.GetID(), 'ThresholdValue' : 100, 'ThresholdType' : 'Above'}
    cliNode = slicer.cli.run(slicer.modules.thresholdscalarvolume, None, cliParams, wait_for_completion=True)

    # After CLI execution is completed, output volume must be in the same folder as the referenced node
    self.assertEqual(shNode.GetItemParent(shNode.GetItemByDataNode(outputVolume)), shNode.GetItemParent(shNode.GetItemByDataNode(inputVolume)))

    # After pending events are processed, the output volume must be in the same subject hierarchy folder
    slicer.app.processEvents()
    self.assertEqual(shNode.GetItemParent(shNode.GetItemByDataNode(outputVolume)), shNode.GetItemParent(shNode.GetItemByDataNode(inputVolume)))
开发者ID:BRAINSia,项目名称:Slicer,代码行数:28,代码来源:CLIEventTest.py

示例10: test_ThresholdThreading

  def test_ThresholdThreading(self):
    """
    Test for issue 2329, using the slicer EditorLib components
    in outside of the editor.
    """
    self.delayDisplay("Starting the test")

    #
    # first, get some sample data
    #
    import SampleData
    head = SampleData.downloadSample("MRHead")

    #
    # create a label map and set it for editing
    #
    volumesLogic = slicer.modules.volumes.logic()
    # AF: intentionally use the naming convention that does not match the one
    # used by Editor
    headLabel = volumesLogic.CreateAndAddLabelVolume( slicer.mrmlScene, head, head.GetName() + '-segmentation' )

    selectionNode = slicer.app.applicationLogic().GetSelectionNode()
    selectionNode.SetActiveVolumeID( head.GetID() )
    selectionNode.SetActiveLabelVolumeID( headLabel.GetID() )
    slicer.app.applicationLogic().PropagateVolumeSelection(0)

    #
    # Instantiate a new widget, and add Editor widget to it
    #
    from Editor import EditorWidget
    editorWidget = EditorWidget(showVolumesFrame=False)

    self.delayDisplay("Test passed!")
开发者ID:BRAINSia,项目名称:Slicer,代码行数:33,代码来源:StandaloneEditorWidgetTest.py

示例11: run

  def run(self):
    """
    Run the actual algorithm
    """

    layoutManager = slicer.app.layoutManager()
    layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalView)

    self.delayDisplay('Running the aglorithm')

    import SampleData
    ctVolume = SampleData.downloadSample('CTChest')
    self.delayDisplay('Downloaded CT sample data')

    # go to the volume rendering module
    slicer.util.mainWindow().moduleSelector().selectModule('VolumeRendering')
    self.delayDisplay('Volume Rendering module')

    # turn it on
    volumeRenderingWidgetRep = slicer.modules.volumerendering.widgetRepresentation()
    volumeRenderingWidgetRep.setMRMLVolumeNode(ctVolume)
    volumeRenderingNode = slicer.mrmlScene.GetFirstNodeByName('VolumeRendering')
    volumeRenderingNode.SetVisibility(1)
    self.delayDisplay('Volume Rendering')

    # set up a cropping ROI
    volumeRenderingNode.SetCroppingEnabled(1)
    annotationROI = slicer.mrmlScene.GetFirstNodeByName('AnnotationROI')
    annotationROI.SetDisplayVisibility(1)
    self.delayDisplay('Cropping')

    # close the scene
    slicer.mrmlScene.Clear(0)

    return True
开发者ID:Slicer,项目名称:Slicer,代码行数:35,代码来源:VolumeRenderingSceneClose.py

示例12: onStartStopDicomPeer

  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()
开发者ID:BRAINSia,项目名称:Slicer,代码行数:46,代码来源:JRC2013Vis.py

示例13: test_load_model

    def test_load_model(self):
        snp_model = PredictionModel.load_model("tests/_td/dbs/test_1.db")

        e_e = SampleData.dataframe_from_extra(SampleData.sample_extra_2())
        numpy.testing.assert_array_equal(snp_model.extra[PredictionModel.WDBEQF.K_GENE], e_e[PredictionModel.WDBEQF.K_GENE])
        numpy.testing.assert_array_equal(snp_model.extra[PredictionModel.WDBEQF.K_GENE_NAME], e_e[PredictionModel.WDBEQF.K_GENE_NAME])
        numpy.testing.assert_array_equal(snp_model.extra[PredictionModel.WDBEQF.K_N_SNP_IN_MODEL], e_e[PredictionModel.WDBEQF.K_N_SNP_IN_MODEL])
        numpy.testing.assert_array_equal(snp_model.extra[PredictionModel.WDBEQF.K_PRED_PERF_R2], e_e[PredictionModel.WDBEQF.K_PRED_PERF_R2])
        numpy.testing.assert_array_equal(snp_model.extra[PredictionModel.WDBEQF.K_PRED_PERF_PVAL], e_e[PredictionModel.WDBEQF.K_PRED_PERF_PVAL])
        numpy.testing.assert_array_equal(snp_model.extra[PredictionModel.WDBEQF.K_PRED_PERF_QVAL], e_e[PredictionModel.WDBEQF.K_PRED_PERF_QVAL])

        e_w = SampleData.dataframe_from_weights(SampleData.sample_weights_2())
        numpy.testing.assert_array_equal(snp_model.weights[PredictionModel.WDBQF.K_RSID], e_w[PredictionModel.WDBQF.K_RSID])
        numpy.testing.assert_array_equal(snp_model.weights[PredictionModel.WDBQF.K_GENE], e_w[PredictionModel.WDBQF.K_GENE])
        numpy.testing.assert_array_equal(snp_model.weights[PredictionModel.WDBQF.K_WEIGHT], e_w[PredictionModel.WDBQF.K_WEIGHT])
        numpy.testing.assert_array_equal(snp_model.weights[PredictionModel.WDBQF.K_NON_EFFECT_ALLELE], e_w[PredictionModel.WDBQF.K_NON_EFFECT_ALLELE])
        numpy.testing.assert_array_equal(snp_model.weights[PredictionModel.WDBQF.K_EFFECT_ALLELE], e_w[PredictionModel.WDBQF.K_EFFECT_ALLELE])
开发者ID:jiamaozheng,项目名称:MetaXcan,代码行数:17,代码来源:test_prediction_model.py

示例14: test_Part1Ruler

  def test_Part1Ruler(self,enableScreenshotsFlag=0,screenshotScaleFactor=1):
    """ Test using rulers
    """
    logic = RSNAQuantTutorialLogic()
    logic.enableScreenshots = enableScreenshotsFlag
    logic.screenshotScaleFactor = screenshotScaleFactor

    self.delayDisplay("Starting the test")

    #
    # first, get some data
    #
    import SampleData
    tumor = SampleData.downloadSample('MRBrainTumor1')

    try:
      # four up view
      layoutManager = slicer.app.layoutManager()
      layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView)

      # annotations module
      m = slicer.util.mainWindow()
      m.moduleSelector().selectModule('Annotations')

      # add ruler 1
      rulerNode1 = slicer.vtkMRMLAnnotationRulerNode()
      rulerNode1.SetName("d1")
      rulerNode1.SetPosition1(-7.59519,43.544,28.6)
      rulerNode1.SetPosition2(-5.56987,14.177,28.6)
      rulerNode1.Initialize(slicer.mrmlScene)
      self.delayDisplay("Ruler 1")

      # add ruler 2
      rulerNode2 = slicer.vtkMRMLAnnotationRulerNode()
      rulerNode2.SetName("d2")
      rulerNode2.SetPosition1(-3.54455,27.656,13.1646)
      rulerNode2.SetPosition2(-2.5319,27.656,47.5949)
      rulerNode2.Initialize(slicer.mrmlScene)
      self.delayDisplay("Ruler 2")

      # scroll
      annotLogic = slicer.modules.annotations.logic()
      annotLogic.JumpSlicesToAnnotationCoordinate(rulerNode1.GetID())

      # show slices
      redWidget = layoutManager.sliceWidget('Red')
      redWidget.sliceController().setSliceLink(True)
      redWidget.sliceController().setSliceVisible(True);


      logic.takeScreenshot('Ruler','Ruler used to measure tumor diameter',-1)

      self.delayDisplay('Test passed!')
    except Exception as e:
      import traceback
      traceback.print_exc()
      self.delayDisplay('Test caused exception!\n' + str(e))
开发者ID:Slicer,项目名称:Slicer,代码行数:57,代码来源:RSNAQuantTutorial.py

示例15: test_SegmentStatisticsBasic

  def test_SegmentStatisticsBasic(self):
    """
    This tests some aspects of the label statistics
    """

    self.delayDisplay("Starting test_SegmentStatisticsBasic")

    import vtkSegmentationCorePython as vtkSegmentationCore
    import SampleData
    from SegmentStatistics import SegmentStatisticsLogic

    self.delayDisplay("Load master volume")

    masterVolumeNode = SampleData.downloadSample('MRBrainTumor1')

    self.delayDisplay("Create segmentation containing a few spheres")

    segmentationNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode')
    segmentationNode.CreateDefaultDisplayNodes()
    segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(masterVolumeNode)

    # Geometry for each segment is defined by: radius, posX, posY, posZ
    segmentGeometries = [[10, -6,30,28], [20, 0,65,32], [15, 1, -14, 30], [12, 0, 28, -7], [5, 0,30,64],
                         [12, 31, 33, 27], [17, -42, 30, 27]]
    for segmentGeometry in segmentGeometries:
      sphereSource = vtk.vtkSphereSource()
      sphereSource.SetRadius(segmentGeometry[0])
      sphereSource.SetCenter(segmentGeometry[1], segmentGeometry[2], segmentGeometry[3])
      sphereSource.Update()
      uniqueSegmentID = segmentationNode.GetSegmentation().GenerateUniqueSegmentID("Test")
      segmentationNode.AddSegmentFromClosedSurfaceRepresentation(sphereSource.GetOutput(), uniqueSegmentID)

    self.delayDisplay("Compute statistics")

    segStatLogic = SegmentStatisticsLogic()
    segStatLogic.getParameterNode().SetParameter("Segmentation", segmentationNode.GetID())
    segStatLogic.getParameterNode().SetParameter("ScalarVolume", masterVolumeNode.GetID())
    segStatLogic.computeStatistics()

    self.delayDisplay("Check a few numerical results")
    self.assertEqual( segStatLogic.getStatistics()["Test_2","LabelmapSegmentStatisticsPlugin.voxel_count"], 9807)
    self.assertEqual( segStatLogic.getStatistics()["Test_4","ScalarVolumeSegmentStatisticsPlugin.voxel_count"], 380)

    self.delayDisplay("Export results to table")
    resultsTableNode = slicer.vtkMRMLTableNode()
    slicer.mrmlScene.AddNode(resultsTableNode)
    segStatLogic.exportToTable(resultsTableNode)
    segStatLogic.showTable(resultsTableNode)

    self.delayDisplay("Export results to string")
    logging.info(segStatLogic.exportToString())

    outputFilename = slicer.app.temporaryPath + '/SegmentStatisticsTestOutput.csv'
    self.delayDisplay("Export results to CSV file: "+outputFilename)
    segStatLogic.exportToCSVFile(outputFilename)

    self.delayDisplay('test_SegmentStatisticsBasic passed!')
开发者ID:Slicer,项目名称:Slicer,代码行数:57,代码来源:SegmentStatistics.py


注:本文中的SampleData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。