Skip to content

Instantly share code, notes, and snippets.

View ahmedhosny's full-sized avatar

Ahmed Hosny ahmedhosny

View GitHub Profile
@ahmedhosny
ahmedhosny / plot_1D_vector_and_smooth.py
Created January 11, 2018 22:01
plots 1D vectors and smoothes them using plotly
import numpy as np
import plotly
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import plotly.graph_objs as go
init_notebook_mode(connected=True)
from plotly import tools
import scipy.signal as signal
from scipy.interpolate import interp1d
# myX - x axis values
@ahmedhosny
ahmedhosny / nrrd_to_hdf5.py
Last active December 18, 2017 22:43
Converts nrrd to hdf5 (without metadata)
# assumes CT image nrrds with minimum value of -1024
# assumes CT mask nrrds with 0's and 1's
# assumes the shape of each patient data (iamge and mask) are different - therefore,
# this will pad all images and masks to the size of the largest
# does not preform any interpolation to isotrpic voxels or any normalization
# only saves the image and mask, therefore the metadata and pixel spacing is lost
import nrrd # pip install pynrrd # probably better performance with sitk
import numpy as np
import glob
@ahmedhosny
ahmedhosny / nrrd_to_nifti.py
Created December 12, 2017 15:49
nrrd to nifti
import nrrd # pip install pynrrd
import nibabel as nib # pip install nibabel
import numpy as np
# load nrrd
_nrrd = nrrd.read('/path/to/nrrd.nrrd')
data = _nrrd[0]
header = _nrrd[1]
print data.shape, header
@ahmedhosny
ahmedhosny / CutCircularArc.json
Last active September 18, 2016 21:53 — forked from mrivlin/CutCircularArc.json
Plethora Add-In Technical Exercise
{
"Edges": {
"53330552": {
"Type": "LineSegment",
"Vertices": [
10212927,
43495525
]
},
"24807479": {