Skip to content

Instantly share code, notes, and snippets.

@hirokai
hirokai / microjson.py
Created February 21, 2015 21:18
microjson by Patrick Hensley
# microjson - Minimal JSON parser/emitter for use in standalone scripts.
# No warranty. Free to use/modify as you see fit. Trades speed for compactness.
# Send ideas, bugs, simplifications to http://github.com/phensley
# Copyright (c) 2010 Patrick Hensley <[email protected]>
# std
import math
import StringIO
import types
@hirokai
hirokai / auto_detect.py
Last active August 29, 2015 14:16
Auto cell detection by RICM, for 20150206 FC1 fixed
# auto_detect.py
from ij import IJ
from ij.plugin import ImageCalculator
IJ.run("Close All")
IJ.run("Stack From List...", "open=/Users/hiroyuki/Desktop/images.txt")
IJ.run("Gaussian Blur...", "sigma=5 stack")
imp = IJ.getImage()
imp.setTitle("all")
@hirokai
hirokai / hiroutil.py
Created March 12, 2015 06:53
Utility for Fiji image processing
# hiroutil.py
from ij import ImageStack, IJ
def load_stack(w,h,paths):
stk = ImageStack(w,h)
for path in paths:
ip = IJ.openImage(path).getProcessor()
stk.addSlice(ip)
@hirokai
hirokai / generate_nc.hs
Created July 31, 2015 09:51
Generate PRODIA M45 NC file
import Data.List
import Data.Monoid
import Text.Printf
data Sgn = Posi | Neg deriving Eq
data FP = FP Int Int Sgn | FPInt Int | FPDouble Double
add :: Double -> FP -> FP
add v (FPDouble a) = FPDouble (a + v)
@hirokai
hirokai / generate_nc.purs
Created August 19, 2015 05:47
Generate NC files for PRODIA M45
-- Generate NC files for PRODIA M45
module Main where
import Prelude
import Math hiding (log)
import Data.Array
import Data.Monoid
-- import Data.List (foldl)
@hirokai
hirokai / threshold_and_measure_circles.fiji.py
Created September 10, 2015 01:58
Thresholding and measuring circles for scope calibration
from ij import IJ
from ij.measure import ResultsTable
from ij.plugin.filter import ParticleAnalyzer
import time
def analyze(path):
IJ.open(path)
IJ.run("16-bit");
IJ.run("Auto Threshold", "method=Minimum");
@hirokai
hirokai / find_cells.fiji.py
Created September 17, 2015 02:39
Find cells in all frames from a movie
# This script runs on Fiji.
# Just drag and drop this file into a Fiji window.
from ij import IJ, ImageStack, ImagePlus
from ij.process import ImageProcessor
from ij.plugin import ImageCalculator, ZProjector
from ij.plugin.filter import GaussianBlur, Analyzer, ParticleAnalyzer
from ij.measure import Measurements
import sys
@hirokai
hirokai / find_cells-headless.fiji.py
Created September 17, 2015 02:49
Find cells in all frames from a movie, which can run in headless mode of Fiji
# This script runs on Fiji.
# Just drag and drop this file into a Fiji window.
# You can also use headless mode
# > /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --headless \
# > find_cells-headless.fiji.py /path/to/movie.avi
from ij import IJ, ImageStack, ImagePlus
from ij.process import ImageProcessor, ImageConverter
from ij.plugin import ImageCalculator, AVI_Reader, ZProjector, HyperStackConverter
from ij.plugin.filter import GaussianBlur, Analyzer, ParticleAnalyzer
@hirokai
hirokai / calc_trajectories.py
Last active September 17, 2015 03:33
Calculate cell migration trajectories from cell coordinates of all frames
# Calculate trajectories using data from find_cells-headless.fiji.py
import csv
import sys
def norm_sq(a, b):
return (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2
@hirokai
hirokai / julia-image-cookbook.md
Created October 14, 2015 05:39
Julia image processing cookbook

Cookbook for image processing in Julia

Image loading, showing, saving

using Images