Skip to content

Instantly share code, notes, and snippets.

View kmader's full-sized avatar

Kevin Mader kmader

  • Zurich, Switzerland
View GitHub Profile
@kmader
kmader / volume_labelmap.py
Created August 17, 2018 09:26
convert volumes to labelmaps in Slicer3D
from glob import glob
import os
cur_glob = '/Volumes/NO NAME/*seg.nii'
files_to_process = glob(cur_glob)
print('Processing', len(files_to_process), 'files')
def process_file(in_path):
slicer.mrmlScene.Clear(0)
[success, loadedVolumeNode] = slicer.util.loadVolume(in_path, returnNode=True)
outputLabelMap = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLabelMapVolumeNode')
vol_logic = slicer.modules.volumes.logic()
@kmader
kmader / jupyanno.html
Created August 2, 2018 16:44
FunAnnotation.html
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<title>Thebe Lab examples</title>
<link rel="stylesheet" type="text/css" href="index.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js">
</script>
<!-- Configure and load Thebe !-->
@kmader
kmader / ImageEnhancementPlayground.ipynb
Created March 7, 2018 11:24
Using IPywidgets and Matplotlib Together
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kmader
kmader / README.md
Created February 13, 2018 17:01
RCNN / YOLO in JS

How to display output

How to display reasonable output from a RCNN in JS

@kmader
kmader / CNN_MNIST_PlaidML.ipynb
Last active September 9, 2020 04:06
PlaidML Keras MNIST
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kmader
kmader / AnalysisSubmitTool.ipynb
Created October 20, 2017 10:12
A simple Dash and Luigi Job Submission Tool
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kmader
kmader / R Snippet for reading dicom headers
Created August 17, 2017 13:00
Read Dicom Headers in KNIME
library(tidyverse)
library(oro.dicom)
knime.in$Location %>%
plyr::ldply(function(in_path) {
readDICOMFile(as.character(in_path), pixelData = F)$hdr %>%
group_by(name) %>% summarize_all(funs(first)) %>% # remove duplicate names
select(name, value) %>% spread(name, value) %>% # reformat as a table
head(1)
}
) -> all_header
@kmader
kmader / material_switch.css
Last active July 26, 2017 10:20
Here is a collection of useful CSS files that I 'host' on gist for use in dash-apps
.material-switch > input[type="checkbox"] {
display: none;
}
.material-switch > label {
cursor: pointer;
height: 0px;
position: relative;
width: 40px;
}
@kmader
kmader / DashDemo.ipynb
Last active June 27, 2017 12:02
Dash Demo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kmader
kmader / Overview.md
Created May 8, 2017 15:36
pyspark change environment and serializer

Change Configuration / Environment

Often it is important to change a core configuration setting in pyspark before running (like a serializer, PYTHONHASHSEED for python3 users, or

from pyspark import SparkContext
from pyspark.serializers import PickleSerializer
new_conf = sc._conf.setExecutorEnv('PYTHONHASHSEED', '1234')
sc.stop()
sc = pyspark.SparkContext(conf = new_conf, serializer = PickleSerializer())