This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load dry bone CT of skull into the scene and run this script to automatically segment endocranium | |
masterVolumeNode = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLScalarVolumeNode") | |
smoothingKernelSizeMm = 3.0 # this is used for closing small holes in the se | |
# Compute bone threshold value automatically | |
import vtkITK | |
thresholdCalculator = vtkITK.vtkITKImageThresholdCalculator() | |
thresholdCalculator.SetInputData(masterVolumeNode.GetImageData()) | |
thresholdCalculator.SetMethodToOtsu() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load/generate input data | |
################################################ | |
# Load master volume | |
import SampleData | |
sampleDataLogic = SampleData.SampleDataLogic() | |
masterVolumeNode = sampleDataLogic.downloadMRBrainTumor1() | |
# Define boundary points | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a dental CT scan | |
import SampleData | |
volumeNode = SampleData.SampleDataLogic().downloadDentalSurgery()[1] | |
# Define curve | |
curveNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLMarkupsCurveNode') | |
curveNode.CreateDefaultDisplayNodes() | |
curveNode.GetCurveGenerator().SetNumberOfPointsPerInterpolatingSegment(25) # add more curve points between control points than the default 10 | |
curveNode.AddControlPoint(vtk.vtkVector3d(-45.85526315789473, -104.59210526315789, 74.67105263157896)) | |
curveNode.AddControlPoint(vtk.vtkVector3d(-50.9078947368421, -90.06578947368418, 66.4605263157895)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import unittest | |
import vtk, qt, ctk, slicer | |
from slicer.ScriptedLoadableModule import * | |
from array import array | |
import logging | |
import vtk.util.numpy_support | |
import numpy as np | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
volumesDir = r"c:\Users\andra\OneDrive\Projects\SlicerTesting4\20190523-AutoWWWL\volumes" | |
screenshotsDir = r"c:\Users\andra\OneDrive\Projects\SlicerTesting4\20190523-AutoWWWL\screenshots" | |
methods = [ | |
["baseline", autoContrastSlicerDefault], | |
["hist-0.1-99.9", lambda fn: autoContrastVtkImageHistogramStatisticsDefault(fn, 0.1, 99.9, 0.00, 0.0)], # = itksnap | |
["hist-1.0-99.9", lambda fn: autoContrastVtkImageHistogramStatisticsDefault(fn, 1.0, 99.9, 0.10, 0.0)], | |
["hist-1.0-99.0-x0.10", lambda fn: autoContrastVtkImageHistogramStatisticsDefault(fn, 1.0, 99.0, 0.10, 0.10)], | |
["hist-1.0-99.0-x0.20", lambda fn: autoContrastVtkImageHistogramStatisticsDefault(fn, 1.0, 99.0, 0.10, 0.20)], | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download a sample data set (chest CT) | |
import SampleData | |
masterVolumeNode = SampleData.SampleDataLogic().downloadCTChest() | |
# Create segmentation | |
segmentationNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode") | |
segmentationNode.CreateDefaultDisplayNodes() # only needed for display | |
segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(masterVolumeNode) | |
# Create temporary segment editor to get access to effects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def showSimpleUserInterface(simpleView): | |
# Do not store these display settings permanently | |
settings = qt.QSettings() | |
settings.setValue('MainWindow/RestoreGeometry', not simpleView) | |
for toolbar in slicer.util.mainWindow().findChildren('QToolBar'): | |
toolbar.setVisible(not simpleView) | |
modulePanelDockWidget = slicer.util.mainWindow().findChildren('QDockWidget','PanelDockWidget')[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The module is now moved to SlicerSandbox extension: | |
# | |
# https://github.com/PerkLab/SlicerSandbox/tree/master/SegmentCrossSectionArea | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Important: the input volume must have isotropic spacing. | |
# If surface is thick, use Extract skeleton module with Skeleton type = 2D, Do not prune branches = enabled. | |
# Increase radius parameter to fill more holes. | |
# Increase dimension to preserve more details. | |
inputLabelmap = getNode('Input labelmap') | |
ici = vtk.vtkImageChangeInformation() | |
ici.SetInputData(inputLabelmap.GetImageData()) | |
ici.SetOutputSpacing(inputLabelmap.GetSpacing()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate input data | |
################################################ | |
import SampleData | |
import numpy as np | |
# Load master volume | |
sampleDataLogic = SampleData.SampleDataLogic() | |
masterVolumeNode = sampleDataLogic.downloadMRBrainTumor1() |