Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _initializeChartTable(self):
self._chartTable = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTableNode", "Target Displacement")
vesselLumenModelNode = self.getVesselModelNode()
if not vesselLumenModelNode:
vesselLumenModelNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLModelNode', 'VesselLumenModel')
vesselLumenModelNode.CreateDefaultDisplayNodes()
vesselLumenModelNode.SetAndObserveTransformNodeID(vesselLumenSegmentationNode.GetTransformNodeID())
vesselLumenModelNode.GetDisplayNode().SetOpacity(0.5)
vesselLumenModelNode.GetDisplayNode().SliceIntersectionVisibilityOn()
shNode.SetItemParent(shNode.GetItemByDataNode(vesselLumenModelNode), centerlineFolderShItem)
self.setVesselModelNode(vesselLumenModelNode)
slicer.modules.segmentations.logic().ExportSegmentToRepresentationNode(
vesselLumenSegmentationNode.GetSegmentation().GetSegment(vesselLumenSegmentId), vesselLumenModelNode)
# Create centerline curve
centerlineCurveNode = self.getCenterlineNode()
if not centerlineCurveNode:
centerlineCurveNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLMarkupsCurveNode', 'VesselCenterlineCurve')
centerlineCurveNode.CreateDefaultDisplayNodes()
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
shNode.SetItemParent(shNode.GetItemByDataNode(centerlineCurveNode), centerlineFolderShItem)
self.setCenterlineNode(centerlineCurveNode)
# Extract skeleton
slicer.util.showStatusMessage("Extracting centerline, this may take a few minutes...", 3000)
parameters = {}
parameters["InputImageFileName"] = vesselLumenLabelMapNode.GetID()
vesselCenterlineOutputLabelMapNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode', 'VesselCenterlineLabelMapTemp')
parameters["OutputImageFileName"] = vesselCenterlineOutputLabelMapNode.GetID()
parameters["OutputFiducialsFileName"] = centerlineCurveNode.GetID()
parameters["NumberOfPoints"] = 100
centerlineExtractor = slicer.modules.extractskeleton
qt.QApplication.setOverrideCursor(qt.Qt.WaitCursor)
cliNode = slicer.cli.runSync(centerlineExtractor, None, parameters)
def createPlot(self, color, plotNumber):
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLPlotSeriesNode", self.PLOT_NAMES[plotNumber - 1])
plotSeriesNode.SetAndObserveTableNodeID(self._chartTable.GetID())
plotSeriesNode.SetXColumnName(self._chartTable.GetColumnName(0))
plotSeriesNode.SetYColumnName(self._chartTable.GetColumnName(plotNumber))
plotSeriesNode.SetColor(color)
plotSeriesNode.SetPlotType(slicer.vtkMRMLPlotSeriesNode.PlotTypeScatter)
plotSeriesNode.SetMarkerStyle(4)
plotSeriesNode.SetMarkerSize(3 * plotSeriesNode.GetLineWidth())
self._plotSeriesNodes.append(plotSeriesNode)
self._plotChartNode.AddAndObservePlotSeriesNodeID(plotSeriesNode.GetID())
def createNewSegmentationNode(self):
return slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
def _initializeSegmentationNode(self):
self.segmentationNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
self.segmentationNode.CreateDefaultDisplayNodes()
self.segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(self.volumeNode)