Skip to content

Instantly share code, notes, and snippets.

View bogovicj's full-sized avatar

John Bogovic bogovicj

  • HHMI Janelia Research Campus
  • Washington DC metro area
View GitHub Profile
@bogovicj
bogovicj / bsplineInterpolationDemo.groovy
Created March 4, 2020 16:19
Demonstration cubic bspline interpolation with imglib2
#@ Dataset img
#@ Boolean(value=true) precompute
/**
* Prerequisite:
* Get the bspline branch of bogovicj's (my) fork of imglib2:
* git clone -b bspline [email protected]:bogovicj/imglib2.git
*
* Install it:
* mvn -Dscijava.app.directory=<your_Fiji_directory> install
@bogovicj
bogovicj / FCWB-to-JRC2018F_bwlandmarks.csv
Created September 3, 2019 18:58
Rough bigwarp landmarks for FCWB template to JRC2018F template.
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 8 columns, instead of 6 in line 7.
"Pt-0","true","281.716910229645","95.80208768267224","48.70146137787056","313.5204418371608","97.00407557411268","86.78014572025053"
"Pt-1","true","221.96116910229637","30.159081419624187","60.77035490605427","253.6870980375783","25.727196075156513","96.26193244258873"
"Pt-2","true","341.4726513569937","31.63089770354904","60.77035490605427","372.04595298538624","24.74632158663877","96.26193244258873"
"Pt-3","true","281.42254697286006","209.72066805845515","20.442588726513552","312.8665255114823","202.9385203340292","35.447714154488516"
"Pt-4","true","147.78162839248424","82.8501043841336","59.887265135699366","178.48672058455114","79.34833478079327","104.43588651356994"
"Pt-5","true","412.41419624217116","80.20083507306887","61.94780793319415","444.9576232985387","76.40571131524001","106.07067732776619"
"Pt-6","true","282.01127348643","104.33862212943632","77.84342379958247","313.19348367432156","88.83012150313147","145.305656868476"
"Pt-7","true","129.9088624076395","145.08624526854425","90.75408368394483",
@bogovicj
bogovicj / bigwarpSimilarityPart.groovy
Last active June 7, 2022 12:31
Extract the scale parameter for a set of bigwarp landmark points defining a similarity model.
#@ File (label="Landmark file") landmarksPath
#@ Integer (label="Number of dimensions", value=3) nd
#@ String (label="Direction", choices={"Forward", "Inverse" }, value="Forward") direction
import mpicbg.models.*;
import bigwarp.landmarks.LandmarkTableModel;
import net.imglib2.util.*;
import ij.IJ;
import ij.ImagePlus;
import ij.WindowManager;
import ij.gui.GenericDialog;
import ij.gui.Line;
import ij.gui.Roi;
import ij.plugin.PlugIn;
import ij.process.ByteProcessor;
import ij.process.ColorProcessor;
import ij.process.FloatProcessor;
@bogovicj
bogovicj / bigwarpDemo.groovy
Created July 25, 2019 18:16
An imagej2 example script for running bigwarp and getting at its landmark pairs
#@ Dataset (label="moving image") mvgImg
#@ Dataset (label="target image") tgtImg
#@ File (label="landmarks file csv", required=false ) landmarksFile
import bdv.util.*;
import bdv.viewer.*;
import net.imagej.*;
import bigwarp.*;
#@ OpService ops
#@ UIService ui
#@ Dataset(label="Binary image") image
#@ Integer(label="Width of the structuring element", min=1, value=1) width
/*
* A Fiji script for applying a morphological opening using imageJ ops,
*/
import net.imglib2.type.numeric.integer.*;
import net.imglib2.algorithm.neighborhood.*;
@bogovicj
bogovicj / merge_images.groovy
Last active April 5, 2019 14:11
An ImageJ2 script for combining binary images with specified physical bounding boxes
// @UIService ui
// @LogService log
// @Dataset base
// @String baseMinArg
// @String baseMaxArg
// @Dataset add
// @String addMinArg
// @String addMaxArg
// @Integer value
#@Dataset(label="Image to transform") img
#@Double(label="scale") scaling_factor
#@UIService ui
import net.imglib2.*;
import net.imglib2.realtransform.*;
import net.imglib2.view.*;
import net.imglib2.interpolation.*;
import net.imglib2.interpolation.randomaccess.*;
@bogovicj
bogovicj / parse_and_transform.groovy
Last active April 2, 2019 17:27
ImageJ / Fiji: Parses a string representing an affine transormation, applies it to an image, and displays it.
#@Dataset(label="Image to transform") img
#@String(label="affine transform string") affineString
#@UIService ui
import net.imglib2.realtransform.*;
import net.imglib2.view.*;
import net.imglib2.interpolation.*;
import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory;
nd = 3
@bogovicj
bogovicj / trakem2_exportAreaLists-asMasks_limitZ.bsh
Created March 8, 2018 22:37
trakem2_exportAreaLists-asMasks_limitZ.bsh
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;