Skip to content

Instantly share code, notes, and snippets.

@hirokai
hirokai / tools_fiji.py
Created October 21, 2015 07:05
Fiji image processing common tools
# tools_fiji.py
from ij import ImagePlus, ImageStack, IJ
print('tools_fiji.py loaded.')
# Image load/save
# Open a list of files.
@hirokai
hirokai / collect_minimum.py
Created October 21, 2015 00:09
Collect minimum values in csv
#!/usr/bin/env python
import matplotlib.pyplot as plt
import glob
import csv
y_mins = []
file_list = glob.glob('*.csv')
print('Reading %d files...\n' % len(file_list))
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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)