Skip to content

Instantly share code, notes, and snippets.

@hirokai
hirokai / compute.py
Created December 15, 2014 17:46
Dispy benchmark (Delaunay triangulation algorithm)
def rgb2gray(rgb):
r, g, b = rgb[0,:,:], rgb[1,:,:], rgb[2,:,:]
gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
return gray
def compute(img):
try:
# print('Computing...')
import time, socket
@hirokai
hirokai / dispy-main.py
Created December 15, 2014 18:04
Dispy benchmark
# 'compute' is distributed to each node running 'dispynode';
# runs on each processor in each of the nodes
from compute import compute,search,rgb2gray
def main(n):
import dispy, random
import logging
import tifffile as tiff
import time
@hirokai
hirokai / dispy_simplest.py
Created December 15, 2014 19:14
Dispy template
# 'compute' is distributed to each node running 'dispynode';
# runs on each processor in each of the nodes
from compute_simplest import compute,search
def main(n):
import dispy
import logging
import time
import numpy as np
@hirokai
hirokai / compute_simplest.py
Created December 15, 2014 19:15
Dispy template (algorithm)
def compute(i):
import time,socket
host = socket.gethostname()
time.sleep(1)
return (host, i)
def search():
import fnmatch
import os
@hirokai
hirokai / fiji_scripts.md
Last active August 29, 2015 14:11
Fiji and Python script collection for common image processing tasks
@hirokai
hirokai / timelapse_stitching.py
Created December 22, 2014 18:39
MicroManager images: Time lapse stitching by NumPy and Scipy
# Make time lapse of stitched image.
# Uses Numpy, Scipy, and tifffile
import numpy as np # numpy
import tifffile # tifffile
import cv2 # opencv
from scipy.ndimage.interpolation import zoom # scipy
import json
original_side = 1024
require 'kconv'
require 'mail' # gem install mail
require 'csv'
def parse_message(message)
m = Mail.new(message)
o = {:id => m.message_id, :from => m.from, :to => m.to, :subject => m.subject, :reply => m.in_reply_to, :date => m.date, :ref => m.references}
p o
o
end
@hirokai
hirokai / plot_email_hist.py
Created January 3, 2015 08:05
Email reply time histogram
import matplotlib.pyplot as plt
import csv
import numpy as np
ns = []
ms = []
with open('result.csv','rb') as f:
reader = csv.reader(f)
for row in reader:
if not row[3].startswith('Fwd'):
@hirokai
hirokai / auto_contrast.ijm
Last active August 29, 2015 14:13
Auto contrast for slice processing for cropping cells
// Move to next slice, and reset scale, autocontrast, and make 250x250 rect.
run("Select None");
run("Next Slice [>]");
run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel");
resetMinAndMax();
run("Enhance Contrast", "saturated=0.3");
run("Specify...", "width=250 height=250 x=256 y=256");
@hirokai
hirokai / crop_and_show.py
Created January 9, 2015 20:13
Cropping and showing images
import requests
import keyring
import json
import csv
gist_images = 'XXXX'
gist_rois = 'YYYY'
username = 'ZZZZ'
password = keyring.get_password('Github API', username)