This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run with: gunicorn coreslicer:app --daemon | |
@app.route('/endpoint', methods = ['POST']) | |
def handle_endpoint_function(): | |
pass | |
def app(environ, start_response): | |
port = 8000 | |
app.run(host='0.0.0.0', port=port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, send_file | |
import numpy as np, os, json | |
from scipy.misc import imsave | |
from coreslicer import read_dcm | |
app = Flask(__name__) | |
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) | |
UPLOAD_FOLDER = os.path.join(APP_ROOT, '../tmp/coreslicer') | |
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Serves as a repository for images used in the CoreSlicer documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# on remote machine | |
cd /home/coreslicer/www/ | |
mkdir coreslicer && cd coreslicer | |
git init | |
git config receive.denyCurrentBranch updateInstead | |
cd .. && mkdir coreslicer_pipeline && cd coreslicer_pipeline | |
git init | |
git config receive.denyCurrentBranch updateInstead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def window_level(arr, window_center, window_width, lut_min=0, lut_max=255): | |
# Basic sanity checking. | |
if np.isreal(arr).sum() != arr.size: raise ValueError | |
if lut_max != 255: raise ValueError | |
if arr.dtype != np.float64: arr = arr.astype(np.float64) | |
# Get window information. | |
window_width = max(1, window_width) | |
wc, ww = np.float64(window_center), np.float64(window_width) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, glob | |
import numpy as np | |
import os | |
import matplotlib.pyplot as plt | |
from matplotlib import colors | |
from scipy.signal import convolve2d | |
import scipy | |
from scipy import ndimage | |
from scipy.misc import imread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, glob | |
import numpy as np | |
import os | |
import matplotlib.pyplot as plt | |
from matplotlib import colors | |
from scipy.signal import convolve2d | |
import scipy | |
from scipy import ndimage | |
from scipy.misc import imread |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FalseClass | |
def +(b); 0 + b.to_i; end | |
def to_i; 0; end | |
end | |
class TrueClass | |
def +(b); 1 + b.to_i; end | |
def to_i; 1; end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
""" | |
A very simple 'animation' of a 3D plot | |
""" | |
from mpl_toolkits.mplot3d import axes3d | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import time | |
def generate(X, Y, phi): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Fast algorithm for spectral analysis of unevenly sampled data | |
The Lomb-Scargle method performs spectral analysis on unevenly sampled | |
data and is known to be a powerful way to find, and test the | |
significance of, weak periodic signals. The method has previously been | |
thought to be 'slow', requiring of order 10(2)N(2) operations to analyze | |
N data points. We show that Fast Fourier Transforms (FFTs) can be used | |
in a novel way to make the computation of order 10(2)N log N. Despite | |
its use of the FFT, the algorithm is in no way equivalent to |