Skip to content

Instantly share code, notes, and snippets.

@hirokai
hirokai / point.py
Created February 25, 2014 04:38
2D Point class in Python
from math import sqrt
class Point:
def __init__(self,x_init,y_init):
self.x = x_init
self.y = y_init
def shift(self, x, y):
self.x += x
@hirokai
hirokai / titration_plot.py
Created February 25, 2014 05:59
Matplotlib subplots example
import csv
from pylab import *
names = ['40nm_1_0_b',
'40nm_1_1_b',
'40nm_1_5_b',
'40nm_1_10_b',
'40nm_1_20_b',
'40nm_1_50_b',
'40nm_1_100_b',
@hirokai
hirokai / test-input.csv
Created February 25, 2014 22:41
Test input of CSV
Number Area BX BY Width Height Major Minor Angle Major/minor
68 6927 1533 1077 101 103 94.31 93.52 13.41 1.008447391
82 8806 1088 1372 108 115 106.62 105.16 56.63 1.013883606
10 6557 1352 46 95 95 92.14 90.6 133.78 1.016997792
48 8825 1496 722 111 116 107.11 104.9 113.78 1.021067684
65 8461 1173 1046 109 107 104.97 102.63 62.97 1.022800351
24 7265 1430 237 105 97 97.47 94.9 10.55 1.027081138
30 8758 1214 325 111 115 107.23 103.99 147.46 1.031156842
42 9653 1485 565 114 115 112.72 109.03 128.94 1.033843896
52 8054 1414 798 106 110 102.97 99.59 74.08 1.033939151
@hirokai
hirokai / statistics-fiji.py
Created March 4, 2014 22:37
Fiji image statistics example
from ij import IJ
from ij.process import ImageStatistics as IS
import os
options = IS.MEAN | IS.MEDIAN | IS.MIN_MAX | IS.AREA
def getStatistics(imp):
""" Return statistics for the given ImagePlus """
global options
@hirokai
hirokai / radial_profile_batch.py
Last active May 30, 2016 13:17
Radial profile in Fiji
# Example of Fiji script for calculating a radial profile.
from ij import IJ
from ij.process import ImageStatistics as IS
from ij.gui import Roi, OvalRoi
import csv
# Get mean pixel intensity in a specified donut-shaped area
def get_mean_in_donut(imp, cx, cy, min_r, max_r):
@hirokai
hirokai / delaunay.py
Created March 10, 2014 04:55
Nanodot spacing analysis by Delaunay triangulation
def getVal(table, i):
x = table.getValue('X', i)
y = table.getValue('Y', i)
return (x, y)
# Stub
def delaunay(coords):
return None
@hirokai
hirokai / nanodots.py
Created March 15, 2014 20:55
Nanodot spacing analysis
import httplib, urllib, marshal
from math import floor
def getVal(table, i):
x = table.getValue('X', i)
y = table.getValue('Y', i)
return [x, y]
def draw_triangles(imp, triangles):
ip = imp.getProcessor()
@hirokai
hirokai / delaunay-server.hs
Created March 15, 2014 22:26
Delaunay triangulation as a web service
{-# LANGUAGE OverloadedStrings #-}
-- Used packages: delaunay, scotty, aeson
import Graphics.Triangulation.Delaunay
import Data.Vector.V2
import Data.Aeson
import Data.ByteString (ByteString)
import Data.Text.Lazy.Encoding (encodeUtf8)
import Data.Text.Lazy (Text)