Skip to content

Instantly share code, notes, and snippets.

View ctrueden's full-sized avatar
🛸
Experiencing technical difficulties

Curtis Rueden ctrueden

🛸
Experiencing technical difficulties
View GitHub Profile
@ctrueden
ctrueden / gist:2238895
Created March 29, 2012 15:56
I am an idiot who deserves public shame
: curtis@sirius ~/code/ImageJ/imglib (master)
find . -exec sed -i '' -e 's/^M//' {} \;
sed: .: in-place editing only works for regular files
sed: ./.git: in-place editing only works for regular files
sed: ./.git/hooks: in-place editing only works for regular files
sed: ./.git/info: in-place editing only works for regular files
sed: ./.git/logs: in-place editing only works for regular files
sed: ./.git/logs/refs: in-place editing only works for regular files
sed: ./.git/logs/refs/heads: in-place editing only works for regular files
sed: ./.git/logs/refs/remotes: in-place editing only works for regular files
@ctrueden
ctrueden / add-bio-formats.groovy
Last active January 13, 2020 09:26
Add Bio-Formats to a SciJava Jupyter notebook
#@ImageJ ij
// -- Functions --
registerAndCreatePlugin = { pluginClass, pluginType ->
info = new org.scijava.plugin.PluginInfo(pluginClass, pluginType)
ij.plugin().addPlugin(info)
ij.plugin().createInstance(info)
}
registerService = { serviceClass ->
service = registerAndCreatePlugin(serviceClass, org.scijava.service.Service.class)
@ctrueden
ctrueden / apidiff.sh
Created September 22, 2019 10:05
How to diff the API of two JAR files
#!/bin/sh
# TODO: Why doesn't this work
trap "exit" INT
die() {
echo "$1" 2>&1
exit 1
}
@ctrueden
ctrueden / charting-extension.pom
Last active September 20, 2019 13:56
Unifying multiple POMs at different BOM versions
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ij-env-test</groupId>
<artifactId>charting-extension</artifactId>
<packaging>pom</packaging>
<version>1</version>
<name>Charting Plugin</name>
@ctrueden
ctrueden / Vertical_Stacker.groovy
Created September 11, 2019 16:33
Create a vertical stack of images, each horizontally centered
#@ ImageJ ij
#@ File[] imageFiles
#@ File(style = "save") outFile
#@ boolean showStack
import java.util.Arrays
import net.imglib2.FinalInterval
import net.imglib2.type.numeric.integer.UnsignedByteType
import net.imglib2.util.Intervals
@ctrueden
ctrueden / Generative_Image.groovy
Created June 18, 2019 18:06
Generate an image from a function in ImageJ
#@ Long(value = 3000) size
import java.util.function.BiConsumer
import net.imglib2.img.display.imagej.ImageJFunctions
import net.imglib2.position.FunctionRandomAccessible
import net.imglib2.type.numeric.integer.UnsignedByteType
import net.imglib2.view.Views
// Define a function in 2-space.
ndim = 2
@ctrueden
ctrueden / SCIFIO_Import_Region.py
Last active May 21, 2019 19:42
Import a cropped region of a 2D image using SCIFIO
#@ DatasetIOService dio
#@ File imageFile
#@ long x
#@ long y
#@ long width
#@ long height
#@output Dataset dataset
from io.scif.config import SCIFIOConfig
from io.scif.img import ImageRegion, Range
@ctrueden
ctrueden / Open-as-numpy-array-via-Bio-Formats.ipynb
Last active April 20, 2019 18:26
Open an image with Bio-Formats as a numpy array via pyimagej
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ctrueden
ctrueden / boofcv-seeded-watershed.groovy
Last active March 25, 2019 21:21
Seeded watershed in ImageJ using BoofCV
#@dependency(group="org.boofcv", module="boofcv-core", version="0.33")
#@dependency(group="org.boofcv", module="boofcv-swing", version="0.32")
#@both ImagePlus imp
#@output ImagePlus (label="Watersheds") watersheds
#@output ImagePlus (label="Regions") regions
#@output ImagePlus (label="Seeds") seeds
import boofcv.alg.filter.binary.BinaryImageOps
import boofcv.alg.filter.binary.ThresholdImageOps
@ctrueden
ctrueden / ImageJ1-with-Jython-via-BeakerX.ipynb
Last active March 22, 2019 18:11
Use Jython to invoke ImageJ 1.x API in a BeakerX Groovy notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.