Skip to content

Instantly share code, notes, and snippets.

Avatar

Andras Lasso lassoan

View GitHub Profile
@lassoan
lassoan / export_files_assembla.ps1
Created Sep 25, 2017
Download all files from Assembla (Files tool - including all ticket and wiki attachments)
View export_files_assembla.ps1
##################
## Written by: Kyle Sunderland
##
## Downloads all files from an assembla project
## Need to change repo_name, api_key, and api_secret for the script to work
##################
$repo_name = "REPO_NAME" # Name of the repo
# personal keys found at: https://app.assembla.com/user/edit/manage_clients
@lassoan
lassoan / ReconstructSurface.py
Created Mar 16, 2018
Reconstruct open surface from labelmap
View ReconstructSurface.py
# 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())
@lassoan
lassoan / MarkupsInfo.py
Created Sep 21, 2017
Compute the total length between all the points of a markup list in 3D Slicer
View MarkupsInfo.py
from __main__ import qt, slicer
#
# MarkupsInfo module
#
class MarkupsInfo:
def __init__(self, parent):
import string
parent.title = "Markups info"
@lassoan
lassoan / CardiacAgatstonScoring
Last active Oct 11, 2018
Cardiac Agatston scoring function for 3D Slicer
View CardiacAgatstonScoring
# There are several variants of the metric. If you need to compute the metric slice by slice then
# you can use Mask volume effect (available in Segment Editor module after you install SegmentEditorExtraEffects
# extension) to create a volume where all voxels are blanked out except the calcifications in the selected vessel
# and compute the total score using this script.
def computeAgatstonScore(volumeNode, minimumIntensityThreshold=130, minimumIslandSizeInMm2=1.0, verbose=False):
import numpy as np
import math
import SimpleITK as sitk
voxelArray = slicer.util.arrayFromVolume(volumeNode)
@lassoan
lassoan / LineProfile.py
Last active Dec 11, 2018
3D Slicer module for computing intensity profile in a volume along a ruler line
View LineProfile.py
#
#
#
#
#
# This example has been completely reworked and converted to a module, now available at:
#
#
# https://github.com/lassoan/SlicerLineProfile/blob/master/LineProfile/LineProfile.py
#
@lassoan
lassoan / SimpleView.py
Last active Dec 20, 2018
Simple 3D Slicer based image viewer
View SimpleView.py
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]
@lassoan
lassoan / SegmentGrowCut.py
Last active May 15, 2019
This example script demonstrates how a grow-cut operation can be performed without graphical user interface using 3D Slicer
View SegmentGrowCut.py
# 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
################################################
View AutoWindowLevelTest.py
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)],
]
@lassoan
lassoan / AngleMeasurement.py
Last active Jun 22, 2019
3D Slicer scripted module for measuring angle between rulers
View AngleMeasurement.py
#
# Installation:
# - Save this file as AngleMeasurement.py to a directory on your computer
# - Add the directory to the additional module paths in the Slicer application settings:
# - Choose in the menu: Edit / Application settings
# - Click Modules, click >> next to Additional module paths
# - Click Add, and choose the .py file's location
# - After you restart Slicer, "Angle Measurment" module should show up in Quantification category
#
@lassoan
lassoan / MaskVolumeHistogramPlot.py
Last active Sep 3, 2019
Histogram plot of volume masked by segments
View MaskVolumeHistogramPlot.py
# Generate input data
################################################
import SampleData
import numpy as np
# Load master volume
sampleDataLogic = SampleData.SampleDataLogic()
masterVolumeNode = sampleDataLogic.downloadMRBrainTumor1()
You can’t perform that action at this time.