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 projFigure(vol, limits, plDims=[16,10,5], zscale=5, colors='gray',title=None): | |
x,y,z = plDims | |
grid = (y+z,x+z) | |
zRat = zscale*(float(y)/z) | |
plt.figure(figsize=grid[-1::-1]) | |
# plot the x-y view (top-down) | |
ax1 = plt.subplot2grid(grid,(0,0),rowspan=y,colspan=x) | |
plt.imshow(vol.max(0) + vol.min(0),clim=limits,cmap=colors,origin='leftcorner',interpolation='Nearest') |
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 numpy import where,array,meshgrid, vstack | |
from matplotlib.path import Path | |
def getInteriorPoints(coords): | |
""" | |
Given a list of pairs of points which define a polygon, return a list of pairs of points interior to the polygon | |
""" | |
bounds = array(coords).astype('int') | |
bMax = bounds.max(0) |
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
Done saving /tier2/ahrens/davis/data/spark/20150217/7dpf_gfap_gc6f_misha_omr_photo_20150217_202934/mat/mxProj_z_2-9 | |
15/02/25 20:20:50 ERROR TaskSchedulerImpl: Lost executor 0 on h05u09.int.janelia.org: remote Akka client disassociated | |
15/02/25 20:20:50 ERROR SparkDeploySchedulerBackend: Asked to remove non-existent executor 0 | |
15/02/25 20:20:50 ERROR SparkDeploySchedulerBackend: Asked to remove non-existent executor 0 | |
15/02/25 20:21:36 ERROR TaskSchedulerImpl: Lost executor 1 on h07u27.int.janelia.org: remote Akka client disassociated | |
15/02/25 20:21:36 ERROR SparkDeploySchedulerBackend: Asked to remove non-existent executor 1 | |
15/02/25 20:21:36 ERROR SparkDeploySchedulerBackend: Asked to remove non-existent executor 1 | |
15/02/25 20:34:20 ERROR TaskSetManager: Task 10634 in stage 56.0 failed 4 times; aborting job | |
--------------------------------------------------------------------------- | |
Py4JJavaError Traceback (most recent call last) |
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 bz2compress(raw_fname, wipe=False, overwrite=False): | |
""" | |
:param raw_fname: string, full path of file to be compressed | |
:param wipe: bool, optional. If set to True, raw file will be deleted after compression. Defaults to False. | |
:param overwrite: bool, optional. If set to True, overwrites file sharing name of output file. Defaults to False | |
:return: | |
""" | |
import bz2 | |
import os |
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
# test all matplotlib colormaps for a given image | |
# the image to plot | |
toPlot = vol[-1] | |
fName = '/Users/bennettd/Dropbox/media/imag/all_mpl_cmaps.png' | |
cmaps = 'Spectral, summer, coolwarm, Wistia_r, pink_r, Set1, Set2, Set3, brg_r, Dark2, prism, PuOr_r, afmhot_r, terrain_r, PuBuGn_r, RdPu, gist_ncar_r, gist_yarg_r, Dark2_r, YlGnBu, RdYlBu, hot_r, gist_rainbow_r, gist_stern, PuBu_r, cool_r, cool, gray, copper_r, Greens_r, GnBu, gist_ncar, spring_r, gist_rainbow, gist_heat_r, Wistia, OrRd_r, CMRmap, bone, gist_stern_r, RdYlGn, Pastel2_r, spring, terrain, YlOrRd_r, Set2_r, winter_r, PuBu, RdGy_r, spectral, rainbow, flag_r, jet_r, RdPu_r, gist_yarg, BuGn, Paired_r, hsv_r, bwr, cubehelix, Greens, PRGn, gist_heat, spectral_r, Paired, hsv, Oranges_r, prism_r, Pastel2, Pastel1_r, Pastel1, gray_r, jet, Spectral_r, gnuplot2_r, gist_earth, YlGnBu_r, copper, gist_earth_r, Set3_r, OrRd, gnuplot_r, ocean_r, brg, gnuplot2, PuRd_r, bone_r, BuPu, Oranges, RdYlGn_r, PiYG, CMRmap_r, YlGn, binary_r, gist_gray_r, Accent, BuPu_r, |
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 thunder/rdds/timeseries.py | |
# found at https://github.com/thunder-project/thunder/blob/b15ba0a38642312d597a98643cf3514e2d46b69d/thunder/rdds/timeseries.py | |
def normalize(self, baseline='percentile', window=None, perc=20): | |
""" | |
Normalize each time series by subtracting and dividing by a baseline. | |
Baseline can be derived from a global mean or percentile, | |
or a smoothed percentile estimated within a rolling window. | |
Parameters | |
---------- |
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 thunder/rdds/timeseries.py | |
# found at https://github.com/thunder-project/thunder/blob/b15ba0a38642312d597a98643cf3514e2d46b69d/thunder/rdds/timeseries.py | |
def normalize(self, baseline='percentile', window=None, perc=20): | |
""" | |
Normalize each time series by subtracting and dividing by a baseline. | |
Baseline can be derived from a global mean or percentile, | |
or a smoothed percentile estimated within a rolling window. | |
Parameters | |
---------- |
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
# Convert a list of (k,v) pairs into an array | |
def kvp_to_array(dims, data, ind=0, baseline=0): | |
vol = np.zeros(dims,dtype=data[0][1].dtype) + np.array(baseline).astype(data[0][1].dtype) | |
for k,v in data: | |
# check if data contains a single value or an iterable | |
if hasattr(v,'__iter__'): | |
vol[k] = v[ind] | |
else: | |
vol[k] = v |
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
import matplotlib.pyplot as plt | |
from ipywidgets import interact | |
%matplotlib inline | |
def browse_images(im): | |
n = len(im) | |
def view_image(i): | |
plt.figure() | |
plt.imshow(im[i]) | |
plt.show() |
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
%%html | |
<script> | |
var code_show=true; //true -> hide code at first | |
function code_toggle() { | |
$('div.prompt').hide(); // always hide prompt | |
if (code_show){ | |
$('div.input').hide(); | |
} else { |
OlderNewer