Skip to content

Instantly share code, notes, and snippets.

@hirokai
hirokai / batch.py
Created March 15, 2014 23:01
Batch processing template for Fiji with Jython
# Example of Fiji script for batch processing.
import csv
# Stub
# You can put whatever opearations you want to apply.
def get_radialprofile(imp, cx, cy, r, num_bin)
return None
@hirokai
hirokai / radial_profile.py
Created March 15, 2014 23:06
Simple radial profile analysis for Fiji with Jython
# 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
# Get mean pixel intensity in a specified donut-shaped area
def get_mean_in_donut(imp, cx, cy, min_r, max_r):
options = IS.MEAN | IS.MEDIAN | IS.MIN_MAX | IS.AREA
@hirokai
hirokai / links-fiji-tutorial.md
Last active August 29, 2015 13:57
Links of resources in the Fiji tutorial
@hirokai
hirokai / crop_and_merge.py
Created November 18, 2014 00:56
Fiji script: Cropping by csv files of ROIs
from ij import IJ, ImagePlus, ImageStack, WindowManager
from ij.plugin import ContrastEnhancer,StackCombiner,ImageCalculator
from ij.process import ImageConverter, ImageProcessor
from time import sleep
import csv
folder = "/Volumes/Macintosh HD/Google Drive/Groves/Scope 7/20141103/05-A FC4 488 568/"
@hirokai
hirokai / crop_and_merge2.py
Last active August 29, 2015 14:10
Fiji script: Crop and merge images by ROIs. Adds green and red colors to images with no LUT.
from ij import IJ, ImagePlus, ImageStack
from ij.process import ColorProcessor, ImageConverter
from ij.plugin import ContrastEnhancer, ImageCalculator, StackCombiner
import csv
folder = "/Volumes/Macintosh HD/Google Drive/Groves/Scope 7/20141126 Immunostaining/"
def in_path(folder,num):
return [folder + "01 FC4 of 1125/02 tirf and confocal/tirf_"+row[0]+"/Pos0/img_000000000_488tirf_100x_000.tif",
@hirokai
hirokai / crop_confocal.py
Created November 29, 2014 00:51
Fiji script: Crop confocal images (2 channels)
from ij import IJ,ImagePlus
from ij.process import ColorProcessor
from ij.plugin import ContrastEnhancer
import csv
folder = "/Volumes/Macintosh HD/Google Drive/Groves/Scope 7/20141126 Immunostaining/"
def crop(imp,x,y,w,h):
imp.setRoi(x,y,w,h)
st = imp.getStack()
@hirokai
hirokai / detect_pattern.ijm
Created November 29, 2014 06:35
Fiji macro: detect bright circles.
run("Enhance Contrast", "saturated=0.35");
run("Gaussian Blur...", "sigma=5");
run("8-bit");
run("Auto Local Threshold", "method=Mean radius=50 parameter_1=0 parameter_2=0 white");
run("Invert");
run("Fill Holes");
run("Watershed");
run("Set Measurements...", "area mean standard modal min center bounding redirect=None decimal=2");
run("Analyze Particles...", "size=150-300 show=Ellipses display clear include");
@hirokai
hirokai / lattice.py
Created December 4, 2014 00:24
Lattice point approximation
from math import cos, sin, pi, sqrt, atan
import matplotlib.pyplot as plt
import numpy as np
from mydata import *
# vector addition
def abs2(a):
return a[0] * a[0] + a[1] * a[1]
@hirokai
hirokai / stitch_timelapse.py
Created December 5, 2014 17:14
Fiji script: Time lapse of stitched images (conversion from (multipos,frames) to (frames))
# 02A: Make time lapse of stitched image.
from ij import IJ, ImagePlus, ImageStack, WindowManager
from ij.plugin import ContrastEnhancer,StackCombiner,ImageCalculator
from ij.process import ImageConverter, ImageProcessor
from java.awt.image import IndexColorModel
from time import sleep
import csv
from jarray import zeros
@hirokai
hirokai / 02B2.rb
Created December 5, 2014 19:02
Parsing MicroManager metadata.txt to extract time lapse info
#!/usr/bin/env ruby
# Collecting elapsed time from all frames and positions.
require 'csv'
positions = [["4-Pos_000_000", "4-Pos_000_001", "4-Pos_000_002", "4-Pos_000_003"], ["4-Pos_001_000", "4-Pos_001_001", "4-Pos_001_002", "4-Pos_001_003"],
["4-Pos_002_000", "4-Pos_002_001", "4-Pos_002_002", "4-Pos_002_003"], ["4-Pos_003_000", "4-Pos_003_001", "4-Pos_003_002", "4-Pos_003_003"]]
CSV.open("02B frames.csv", "wb") do |csv|