This file contains 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 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
# This gist contained a script that automatically removes table from a CT volume. | |
# The code was improved and turned into a Slicer module, available in the Sandbox extension: | |
# https://github.com/PerkLab/SlicerSandbox#remove-ct-table | |
# | |
# Source code: | |
# https://github.com/PerkLab/SlicerSandbox/blob/master/RemoveCtTable/RemoveCtTable.py#L251 |
This file contains 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 SampleData | |
sampleDataLogic = SampleData.SampleDataLogic() | |
masterVolumeNode = sampleDataLogic.downloadMRHead() | |
# Create segmentation | |
segmentationNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode") | |
segmentationNode.CreateDefaultDisplayNodes() # only needed for display | |
segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(masterVolumeNode) | |
addedSegmentID = segmentationNode.GetSegmentation().AddEmptySegment("skin") |
This file contains 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
# This example script demonstrates how a grow-cut | |
# operation can be performed without graphical user interface. | |
# The first half of the script downloads input data and creates seed segments. | |
# The second half of the script converts segments to merged labelmap (that's the required | |
# input format for grow-cut filter), computes the complete segmentation, and writes | |
# results into new segments. | |
# Generate input data | |
################################################ |
This file contains 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 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 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
# Source data can be obtained from http://lifesciencedb.jp/bp3d/ (tested with partof_BP3D_4.0_obj_99) | |
# These input file must be loaded into the scene: | |
# - partof_inclusion_relation_list.txt and partof_element_parts.txt (loaded as Table nodes) | |
# - OBJ files | |
shNode = slicer.mrmlScene.GetSubjectHierarchyNode() | |
sceneItemID = shNode.GetSceneItemID() | |
def getItemParentsFmaIds(shNode, itemShItemId): | |
existingParentShItemId = shNode.GetItemParent(itemShItemId) |
This file contains 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 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 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() |