Skip to content

Instantly share code, notes, and snippets.

@hirokai
hirokai / subtract average.ijm
Created January 16, 2015 19:20
Subtracting average of slices
run("Stack From List...", "open=/Users/hiroyuki/Desktop/bf.txt");
run("Z Project...", "projection=[Average Intensity]");
run("Calculator Plus", "i1=bf.txt i2=AVG_bf.txt operation=[Subtract: i2 = (i1-i2) x k1 + k2] k1=1 k2=0 create");
@hirokai
hirokai / list_to_column.rb
Created January 10, 2015 00:30
Convert list of numbers to 0/1 column.
# Used in combination with yes/no checker (http://hirokai.github.io/yesnochecker/)
list = [
[0,[90]],
[100,[22,25,38,39,40,43,45,46,52,53,54,55,56,59,62,68,69,70,71,72,73,74,75,76,77,79,80,81,85,86,87,89,90,93,94,95,96,97,98,99,100]],
[200,[1,2,3,4,5,6,7,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,42,44,45,48,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,67,69,70,71,72,73,75,76,77,78,79,81,82,83,84,85,86,87,88,89,90,91,92,93,95,96,97,98,100]],
[300,[4,6,10,11,12,13,15,17,18,21,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,56,57,58,59,63,64,65,66,67,68,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]],
[400,[1,3,4,5,6,9,10,11,12,13,15,16,17,18,19,25,26,29,30,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54]]
]
@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)
@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 / 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'):
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 / 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
@hirokai
hirokai / fiji_scripts.md
Last active August 29, 2015 14:11
Fiji and Python script collection for common image processing tasks
@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 / 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