Skip to content

Instantly share code, notes, and snippets.

View imagejan's full-sized avatar

Jan Eglinger imagejan

  • Friedrich Miescher Institute for Biomedical Research
  • Basel, Switzerland
  • X @jan_eglinger
View GitHub Profile
#@ File (style="extension:bmf") meshFile
#@ File (style="save") newMeshFile
#@ ImagePlus intensity_image
#@ LogService log
#@ Double (value=200.0) gamma
#@ Double (value=3.0) alpha
#@ Double (value=0.0) pressure
#@ Double (value=0.0) steric_neighbors
#@ Double (value=0.0002) image_weight
#@ Integer (value=2) divisions
@imagejan
imagejan / Sliding_Window_Projection.groovy
Created April 22, 2022 15:03
[Fiji/ImgLib2] Create a partial projection of a stack, with a sliding interval of defined size.
#@ Dataset input
#@ OpService ops
#@ Integer (label="Width of sliding window (frames)") window
#@output projected
// Add a new dimension of window size
added = ops.transform().addDimensionView(input, 0, window-1)
extended = ops.transform().extendBorderView(added)
// Shear along time dimension,
/**
* This ImageJ script opens the icon from a given file
* (as displayed in the operating system) as an ij.ImagePlus
*/
#@ File iconFile
import sun.awt.shell.ShellFolder
import ij.ImagePlus
import ij.process.ColorProcessor
@imagejan
imagejan / Invert_RGB.groovy
Created February 2, 2020 21:04
ImageJ script to invert RGB images with unchanged color (hue).
#@ Dataset input
#@ OpService ops
#@ DatasetService ds
#@ ConvertService cs
import net.imagej.axis.Axes
import net.imglib2.IterableInterval
import net.imglib2.type.numeric.integer.UnsignedShortType
import ij.CompositeImage
import ij.ImagePlus
Verifying my Blockstack ID is secured with the address 1LyvZSDS5vYQdFXivZDsamwieqbieaFRAT https://explorer.blockstack.org/address/1LyvZSDS5vYQdFXivZDsamwieqbieaFRAT
@imagejan
imagejan / Transfer_files_with_history.sh
Created March 22, 2019 13:46
Copy files or directories from another git repository preserving the history
# see http://blog.neutrino.es/2012/git-copy-a-file-or-directory-from-another-repository-preserving-history/
mkdir /tmp/mergepatchs
cd ~/repo/org
export reposrc="path/to/file1 path/to/file2"
git format-patch -o /tmp/mergepatchs $(git log $reposrc|grep ^commit|tail -1|awk '{print $2}')^..HEAD $reposrc
cd ~/repo/dest
git am /tmp/mergepatchs/*.patch
@imagejan
imagejan / Open_Cell_Counter_XML_as_ROI.groovy
Last active April 24, 2024 08:06
Open an XML file saved by Cell Counter as an ImageJ PointRoi (ignoring stack position)
/*
* Open an XML file saved by Cell Counter as an ImageJ PointRoi (ignoring stack position)
*
* (see https://forum.image.sc/t/convert-cell-counter-markers-to-multi-point/23844?u=imagejan)
*/
#@ ImagePlus imp
#@ File input
import groovy.xml.XmlParser
@imagejan
imagejan / Mode_of_Image_Histogram.groovy
Created June 25, 2018 20:14
Get the mode of an image histogram in ImageJ (using ImageJ Ops and ImgLib2)
#@ Img input
#@ OpService ops
import net.imglib2.algorithm.stats.Max
histogram = ops.run("histogram", input)
cursor = Max.findMax(histogram)
value = input.firstElement().copy()
histogram.getCenterValue(cursor.getLongPosition(0), value)
@imagejan
imagejan / IJ1_Snippets.groovy
Created April 19, 2018 12:42
Small Groovy code snippets useful when working with ImagePlus and other IJ1 classes
import ij.WindowManager
/**
* Get all open images as list of {@code ImagePlus}
*/
def getImagesAsList() {
count = WindowManager.getImageCount()
return (1..count).collect { WindowManager.getImage(it) }
}
@imagejan
imagejan / Run_TrackMate_Headless.groovy
Created September 19, 2017 07:39
Groovy script to start TrackMate without the UI wizard
#@ ImagePlus imp
#@ File (style = "directory", label = "Output folder") outputFolder
#@ String (label = "Output file name") filename
#@ double (label = "Spot radius", stepSize=0.1) radius
#@ double (label = "Quality threshold") threshold
#@ int (label = "Max frame gap") frameGap
#@ double (label = "Linking max distance") linkingMax
#@ double (label = "Gap-closing max distance") closingMax
import fiji.plugin.trackmate.Model