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 / zarrObjs.ipynb
Created February 15, 2023 22:20
Playing with zarr object stores
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bogovicj
bogovicj / composeDfields.groovy
Created December 22, 2022 21:45
ImageJ2 script to compose displacement fields
#@ Dataset da
#@ Dataset db
dap = Views.moveAxis( da, 2, 0 );
dbp = Views.moveAxis( da, 2, 0 );
spacing = [1, 1, 1] as double[];
dfA = new DisplacementFieldTransform( dap, spacing );
dfB = new DisplacementFieldTransform( dbp, spacing );
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bogovicj
bogovicj / zarrQuantization.ipynb
Created September 29, 2022 18:29
Quantizing and compressing with zarr.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bogovicj
bogovicj / ConditionBenchmark.java
Created September 1, 2022 19:30
How expensive is an addition if statement
package net.imglib2.benchmarks;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
@bogovicj
bogovicj / RealPointIteratorConverter.java
Created September 1, 2022 18:54
create an interator over a real interval using an imgli2 converter
public static IterableInterval< RealPoint > usingConverters( RealInterval interval, int... numSteps )
{
final int nd = interval.numDimensions();
final double[] steps = stepsFromSamples( interval, fillWithLast( nd, numSteps ) );
final RandomAccessibleInterval< Localizable > samples = Localizables.randomAccessibleInterval(
new FinalInterval( Arrays.stream( steps ).mapToLong( x -> (long)x ).toArray() ));
RandomAccessibleInterval< RealPoint > positions = Converters.convert2( samples, (x,y) -> {
for( int i = 0; i < nd; i++ )
y.setPosition(
@bogovicj
bogovicj / Hemi2Fafb.java
Last active August 29, 2022 20:38
Visualize the hemibrain and fafb together
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import org.janelia.saalfeldlab.n5.N5DatasetDiscoverer;
import org.janelia.saalfeldlab.n5.N5FSReader;
import org.janelia.saalfeldlab.n5.N5Reader;
import org.janelia.saalfeldlab.n5.N5TreeNode;
import org.janelia.saalfeldlab.n5.hdf5.N5HDF5Reader;
import org.janelia.saalfeldlab.n5.ij.N5Importer;
@bogovicj
bogovicj / fitGaussianToCosine.ipynb
Last active August 30, 2022 20:45
What sigma makes a gaussian most similar to a cosine?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bogovicj
bogovicj / rigid_slice_align.groovy
Created July 21, 2022 17:05
Rigidly align slices using landmarks (ImageJ2)
#@ ImagePlus imp
#@ UIService ui
/**
* Rigidly align slices with point rois.
*
* Usage:
* 1) Click at least 3 point landmarks in every slice of your image.
* There must be an equal number of landmarks in each slice.
* Landmarks must be clicked in the same order in each slice.
#@ UIService ui
#@ DatasetService ds
/*
* Happy Pi Day 2022
*
* This visualizes the bifurcation diagram for the "standard circle map"
* https://en.wikipedia.org/wiki/Arnold_tongue#Standard_circle_map
*
* (and its parameters are expressed in terms of pi)