Skip to content

Instantly share code, notes, and snippets.

abs(n)
acos(n)
Array.concat(array1, array2)
Array.copy(array)
Array.deleteValue(array, value)
Array.deleteIndex(array, index)
Array.fill(array, value)
Array.filter(array, filter)
Array.findMaxima(array, tolerance)
Array.findMinima(array, tolerance)
@mutterer
mutterer / LineAndProfileTool_.ijm
Created January 22, 2023 21:39
draws a line, and overlays its profile and some infos
// This tool draws a line, and overlays its profile and some infos
// 2023-01-22 fixed profile origin by moving Overlay.moveTo after setColor.
macro "Line and Profile Tool -C00bL1de0L1ee1" {
getCursorLoc(x, y, z, flags);
xstart = x; ystart = y;
x2=x; y2=y;
while (true) {
getCursorLoc(x, y, z, flags);
if (flags&16==0) {
@mutterer
mutterer / inches_mm_toggle.ijm
Created October 12, 2022 18:52
toggles between inches and mm for images from flatbed scanner
macro "inches_mm_toggle Action Tool - C000T0608iT3608nT8f08mTef08mL0dd0" {
getVoxelSize(width, height, depth, unit);
if (unit.startsWith("inch")) {
width=width*25.4;
height=height*25.4;
depth=depth*25.4;
unit = "mm";
} else if (unit.startsWith("mm")) {
width=width/25.4;
height=height/25.4;
@mutterer
mutterer / overlay_transparency_tool.ijm
Last active September 22, 2022 21:22
image overlay transparency adjustment tool
macro "Adjust Overlay Transparency Tool - C00cT0f20A" {
getCursorLoc(x, y, z, flags);
px=x;
while (flags&16>0) {
getCursorLoc(x, y, z, flags);
if (x!=px) {
Overlay.activateSelectionAndWait(Overlay.size-1);
run("Properties... ","opacity="+100*x/getWidth+" transparent");
Overlay.removeSelection(Overlay.size-1);
Overlay.addSelection;
@mutterer
mutterer / curtain_tool.ijm
Created September 22, 2022 20:53
Example curtain tool macro; uses partial image overlay.
macro "Curtain Tool - C00cT0f20A" {
getCursorLoc(x, y, z, flags);
setBatchMode(true);
id=getImageID;
run("Duplicate...","title=temp");
// here goes the image transform to preview
run("Gaussian Blur...","sigma=5");
//
id2=getImageID;
px=x;
@mutterer
mutterer / Linegraph_Anlayzer_demo.ijm
Last active August 25, 2022 14:34
// ImageJ 1.53t Linegraph Anlayzer demo
// ImageJ 1.53t Linegraph Anlayzer demo
run("Line Graph");
// calibrate and set plot origin
makeRectangle(80, 27, 409, 261);
Roi.getBounds(x, y, width, height);
calibrateFormRect(400,700,0,800);
function calibrateFormRect(xmin,xmax,ymin,ymax) {
@mutterer
mutterer / Data_To_Midi.groovy
Created August 25, 2022 11:59 — forked from lacan/Data_To_Midi.groovy
[Data to MIDI sound] Use results from a Results table as notes to form a melody #midi #imagej
#@ File saveLocation (label="Location of MIDI save file")
/**
* Testing Spots to Sound using MIDI
* Each hit is given a unique note based on some metric and intensity is related to volume
*
* = AUTHOR INFORMATION =
* Code written by Olivier Burri, EPFL - SV - PTECH - BIOP
* for Samuel Vernon, McCabe Lab
* 2022.08.23
// a simplified IJ macro version of https://github.com/BIOP/ijp-LaRoMe
roiManager("reset");
run("Duplicate...","title=temp");
id=getImageID;
h=getHeight;
w=getWidth;
for (y=0;y<h;y++){
for (x=0;x<w;x++){
if (getPixel(x,y)>0) {
doWand(x,y);
@mutterer
mutterer / 2D_Gaussian_Fit_Tool.ijm
Last active November 29, 2022 17:40
2D_Gaussian_Fit_Tool.ijm
var r =6;
macro "2D Gaussian Fit Tool - C00cT0f16GTbf16f" {
setBatchMode(1);
getCursorLoc(x, y, z, f);
while (f&16>0) {
Overlay.clear;
getCursorLoc(x, y, z, f);
makeRectangle(x-r,y-r,2*r,2*r);
@mutterer
mutterer / compare center of mass and gaussian fit.ijm
Last active January 29, 2022 19:18
compare center of mass and gaussian fit.ijm
// see https://twitter.com/Maurice_Y_Lee/status/1487093624982499330
// show center of mass
makePoint(getValue('XM'),getValue('YM'),"medium green hybrid");
Overlay.addSelection('green');
// gaussian fit
makePoint(gaussianFit(true),gaussianFit(false),"medium red hybrid");
Overlay.addSelection('red');