Skip to content

Instantly share code, notes, and snippets.

View thouis's full-sized avatar

Thouis (Ray) Jones thouis

  • Broad Institute
  • Cambridge, MA, USA
View GitHub Profile
@thouis
thouis / median_by_gene.py
Created June 11, 2011 20:53
median of medians sorted by gene, sorted by gene
import xlrd
import sys
import numpy as np
book = xlrd.open_workbook(sys.argv[1])
sheet = book.sheet_by_name('Normalization 1')
headers = [c.value for c in sheet.row(0)]
# find columns
colidx = dict([(name, headers.index(name)) for name in ['Gene', 'rep1', 'rep2', 'rep3']])
@thouis
thouis / flypy.el
Created June 30, 2011 12:53
my flypy.el
;;; from http://richardriley.net/projects/emacs/dotprogramming#sec-1.5
(when (load "flymake" t)
(defun flymake-pycheckers-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "/Users/tjones/elisp/pycheckers.sh" (list local-file)))))
@thouis
thouis / gist:1056421
Created June 30, 2011 15:04
initial rewrite of recalculate_groups
def recalculate_group(self, workspace, indexes):
'''Recalculate all measurements once post_group has run
workspace - the workspace being operated on
indexes - the indexes of the group's image sets' measurements
'''
m = workspace.measurements
object_name = self.object_name.value
assert isinstance(m, cpmeas.Measurements)
parent_object_numbers = m.get_all_measurements(
@thouis
thouis / build-cpdev-v1.sh
Created November 6, 2011 19:04
CellProfiler Mac Development Builder script
#!/bin/sh
# TODO: check for virtualenv
# TODO: verify python is universal 32+64 bit
virtualenv -p /Library/Frameworks/Python.framework/Versions/2.7/bin/python --no-site-packages ${1}/cpdev
. ${1}/cpdev/bin/activate
pip install -U pip # to get git+https
@thouis
thouis / script.py
Created January 19, 2012 15:28 — forked from bennihepp/script.py
Example script for CellProfiler RunScript module
import cpscript
from scipy import ndimage
labels = cpscript.Cells.segmented
background_labels = np.array(labels == 0, dtype=int)
dt_labels = ndimage.distance_transform_edt(background_labels)
imVSVG_pixels = cpscript.imVSVG.pixel_data
imVSVG_dt_pixels = imVSVG_pixels * dt_labels
@thouis
thouis / filterbank.py
Created July 23, 2012 11:39 — forked from amueller/filterbank.py
Filterbank responses for low level vision
##########################################################################
# Maximum Response filterbank from
# http://www.robots.ox.ac.uk/~vgg/research/texclass/filters.html
# based on several edge and bar filters.
# Adapted to Python by Andreas Mueller amueller@ais.uni-bonn.de
# Share and enjoy
#
import numpy as np
import matplotlib.pyplot as plt
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
local grad = require 'autograd'
local nn = require 'nn'
local W1 = torch.FloatTensor(1, 1, 10, 10):normal()
local pooler = nn.SpatialMaxPooling(2, 2, 2, 2)
local unpooler = nn.SpatialMaxUnpooling(pooler)
-- not sure why these lines are necessary.
pooler.indices = torch.FloatTensor()
pooler.output = torch.FloatTensor()
import sys
import h5py
import numpy as np
def pygame(h5, name, board, moves):
for idx in range(board.shape[0]):
for plane in range(board.shape[1]):
if plane < 44:
# different board orderings
f = board[idx, plane, ...].T[:, ::-1]
@thouis
thouis / 0_reuse_code.js
Created May 12, 2016 01:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console