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 / ImageJNiiReadExample.java
Last active March 11, 2016 15:02
Reading a 3d Nifti image into an ImageJ ImagePlus
import java.io.IOException;
import loci.formats.FormatException;
import loci.formats.in.NiftiReader;
import loci.plugins.util.ImageProcessorReader;
import ij.IJ;
import ij.ImageJ;
import ij.ImagePlus;
import ij.ImageStack;
@bogovicj
bogovicj / maskingRai.java
Last active July 21, 2016 14:47
Masking a RandomAccessibleInterval
public static <T extends RealType<T>, M extends RealType<M>> void maskToValue(
RandomAccessibleInterval<T> img,
RandomAccessibleInterval<M> mask,
RandomAccessibleInterval<T> out,
T val )
{
Cursor< M > maskC = Views.flatIterable( mask ).cursor();
RandomAccess< T > ira = img.randomAccess();
RandomAccess< T > ora = out.randomAccess();
@bogovicj
bogovicj / SpaceToContinueExample.java
Last active January 3, 2017 17:18
ImageJ Keypress example
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import ij.IJ;
import ij.ImageJ;
import ij.ImagePlus;
public class SpaceToContinueExample implements KeyListener {
final ImageJ ij;
@bogovicj
bogovicj / DownsampleGaussian.java
Created February 28, 2017 14:55
Downsample after gaussian blurring
package process;
import java.util.Arrays;
import org.janelia.utility.parse.ParseUtils;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import bdv.util.Bdv;
@bogovicj
bogovicj / bashParameterExpansion.sh
Last active July 25, 2017 12:34
bashParameterExpansion.sh
#!/bin/bash
# See
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html#Shell-Parameter-Expansion
# ${parameter:-word} substitutes word if parameter is unset
echo '${parameter:-word}'
dog="dog"
echo "${dog:-"cow"}" # Prints "dog"
echo "${cow:-"cow"}" # Prints "cow"
echo "${cow}" # Prints nothing (cow is unset)
@bogovicj
bogovicj / ResaveVolume.java
Created June 23, 2017 19:05
Convert image to nii with mipav
package mipavProject;
import java.io.File;
import java.io.IOException;
import gov.nih.mipav.model.file.FileIO;
import gov.nih.mipav.model.file.FileNIFTI;
import gov.nih.mipav.model.file.FileUtility;
import gov.nih.mipav.model.file.FileWriteOptions;
import gov.nih.mipav.model.structures.ModelImage;
@bogovicj
bogovicj / trakem2_exportAreaLists.bsh
Created February 23, 2018 17:33
trakem2_exportAreaLists.bsh
import ij.IJ;
import ij.ImagePlus;
import java.util.ArrayList;
import ini.trakem2.Project;
import ini.trakem2.tree.ProjectThing;
import ini.trakem2.display.Display;
import ini.trakem2.display.AreaList;
@bogovicj
bogovicj / trakem2_exportAreaLists-asMasks.bsh
Last active March 4, 2018 17:50
trakem2_exportAreaLists-asMasks.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;
@bogovicj
bogovicj / concatOpenImages.groovy
Last active August 21, 2018 14:39
concatOpenImages.groovy
// @UIService ui
// @ImageDisplayService disp
// @DatasetService data
// @LogService log
import java.util.ArrayList;
import net.imagej.axis.Axes
import net.imglib2.view.Views;
@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;