Skip to content

Instantly share code, notes, and snippets.

Kevin Mader kmader

  • Magic Leap
  • Zurich, Switzerland
View GitHub Profile
View R Snippet for reading dicom headers
library(oro.dicom)$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
) -> all_header
kmader / material_switch.css
Last active Jul 26, 2017
Here is a collection of useful CSS files that I 'host' on gist for use in dash-apps
View material_switch.css
.material-switch > input[type="checkbox"] {
display: none;
.material-switch > label {
cursor: pointer;
height: 0px;
position: relative;
width: 40px;
View DashDemo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
kmader /
Created May 8, 2017
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 = pyspark.SparkContext(conf = new_conf, serializer = PickleSerializer())
kmader /
Last active Mar 21, 2017
KNIME DICOM Reading Issue

Loading Issue

I think the image loading problem is related to the 'Load group files' checkbox, if you leave it unchecked it seems to work fine.

The error message is:

ERROR Image Reader         3:38       Execute failed: Encountered duplicate row ID  "/Users/mader/Documents/TCGA_DICOMS/DOI/TCGA-17-Z011/" at row number 3

The test file is attached as 000000.dcm

View stage1_labels.csv
id cancer
0015ceb851d7251b8f399e39779d1e7d 1
0030a160d58723ff36d73f41b170ec21 0
003f41c78e6acfa92430a057ac0b306e 0
006b96310a37b36cccb2ab48d10b49a3 1
008464bb8521d09a42985dd8add3d0d2 1
0092c13f9e00a3717fdc940641f00015 0
00986bebc45e12038ef0ce3e9962b51a 0
00cba091fa4ad62cc3200a657aeb957e 0
00edff4f51a893d80dae2d42a7f45ad1 1
kmader /
Last active Jan 17, 2017
DictDialog in pyqt


Creates a simple dialog box based on a dictionary with various keys like (check, list, and linedit)

kmader / Simple_Submission.ipynb
Created Dec 11, 2016
A python script for making a submission to the InClass Kaggle competition for Micro and Nano Tomography
View Simple_Submission.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
kmader /
Last active Oct 21, 2016
Important Docker Python Packages

Deep Learning / Tensorflow

# Install Python 3 Tensorflow
RUN conda install --quiet --yes 'tensorflow=0.9.0'
# Keras
RUN conda install --channel --quiet --yes 'keras=1.0.8'


kmader /
Created Oct 20, 2016

Goal: Keras to KNIME

Model Conversion

JSON -> KNIME Workflow

The model file is below as a json output.

Weight Importing

Original (better)

Original weights are stored in HDF5

You can’t perform that action at this time.