Skip to content

Instantly share code, notes, and snippets.

@fepegar
Created October 1, 2020 18:36
Show Gist options
  • Save fepegar/69b11c0004a4f8848dcb43ae61146d63 to your computer and use it in GitHub Desktop.
Save fepegar/69b11c0004a4f8848dcb43ae61146d63 to your computer and use it in GitHub Desktop.
Run a brain parcellation deep learning model within 3D Slicer
# Paste this code into the Slicer Python console
pip_install('highresnet')
import SampleData
from highresnet.inference import infer
from highresnet.cli.download_oasis import download_oasis
input_path = download_oasis()
loadVolume(input_path)
output_path = input_path.replace('.nii', '_seg.nii')
colors_path = 'Colors.ctbl'
downloadFile('https://raw.githubusercontent.com/fepegar/highresnet/master/GIFNiftyNet.ctbl', colors_path)
infer(
input_path,
output_path,
batch_size=1,
window_cropping=2,
volume_padding=10,
window_size=128,
cuda_device=0,
use_niftynet_hist_std=True,
)
labelNode = loadLabelVolume(output_path)
colorNode = loadColorTable(colors_path)
displayNode = labelNode.GetDisplayNode()
displayNode.SetAndObserveColorNodeID(colorNode.GetID())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment