Skip to content

Instantly share code, notes, and snippets.

@mutterer
mutterer / LineAndProfileTool.txt
Last active December 25, 2015 01:58
// This ImageJ macro tool draws a line, and overlays it's profile. // see https://list.nih.gov/cgi-bin/wa.exe?A2=IMAGEJ;197bef78.1310
// This tool draws a line, and overlays its profile and some infos
 
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) {
dx=x2-xstart; dy=y2-ystart;
@mutterer
mutterer / RoiClassesTest.ijm
Last active April 3, 2019 21:57
A sample image menu macro that allows manually assigning classes to ROIs
var tags = newArray("nucleus-1","nucleus-2","cyto-1", "cyto-2");
var colors = newArray("red", "green", "blue", "magenta");
var commands = newArray("Select by tag...");
var menu = Array.concat(commands, tags);
var pmCmds = newMenu("Popup Menu", menu);
macro "Popup Menu" {
cmd = getArgument();
if (cmd=="Select by tag...") {
Dialog.create("Title");
// CZI batch project macro
// parses the file metadata to work around a bioformat bug
// that assigns wrong channel colors.
// edit the first two lines to use DIC in the projection or not
// and what projection mode is needed (see Image>stacks>Z project...)
useDic = true;
projectionMode = "Max Intensity";
var r,g,b;
@mutterer
mutterer / multipage_montage.ijm
Created January 15, 2014 20:39
// creates series of montages // use case: input stack of 200 images // user wants 4x5 montage: 10 pages output.
// creates series of montages
// use case: input stack of 200 images
// user wants 4x5 montage: 10 pages output.
source = getImageID;
slices=nSlices;
cols = 4;
rows = 5;
imagesPerPage = cols*rows;
for (i=0; i<slices/imagesPerPage; i++) {
@mutterer
mutterer / sameImageToStack.ijm
Created March 17, 2014 10:33
creates a stack, duplicating the source image
// creates a stack, duplicating the source image
// after an idea by Mathieu Fallet
x=getNumber("no of Slices", 10);
run("Select All");
run("Copy");
for(i=1;i<x;i++){
run("Add Slice");
run("Paste");
}
run("Blobs (25K)");
run("Smooth");
run("Mean...", "radius=2");
setAutoThreshold("Intermodes");
run("Analyze Particles...", "exclude clear add");
resetThreshold();
run("Remove Overlay");
n = roiManager("count");
Dialog.create("Choix");
Dialog.addChoice("paramètre", newArray("Area","Mean","Circ."),"");
Dialog.show();
param = Dialog.getChoice();
m=moy(param);
for (i=0;i<n;i++) {
roiManager("select",i);
dir = File.directory;
data = dir+ File.nameWithoutExtension+".txt";
if (File.exists(data)) {
data=File.openAsString(data);
setMetadata("Info", data);
List.setList(data);
size=split(List.get('$CM_FULL_SIZE'));
makeRectangle(0,0,size[0],size[1]);
run("Crop");
pixels = List.get('$$SM_MICRON_BAR');
@mutterer
mutterer / Fix_display_range.ijm
Created September 11, 2014 08:31
Fix display range of multichannel images with bitdepth>8
// fixes the display range of lsm files with pixelDepth>8
macro "fix display range [f]" {
Stack.getDimensions(width, height, channels, slices, frames);
for (c=0;c<channels;c++){
Stack.setChannel(c+1);
getStatistics(area, mean, min, max, std, histogram);
setMinAndMax(min, max);
}
}
// yet another multichannel profile plotter
// with smart(?) lookuptables
// 20181114 : works as a macro Tool thanks to Sophie Allart
// plot x-axis is calibrated thanks to Christian Rouviere
// works with 16-bit images thanks to Tiago Ferreira (https://gist.github.com/tferr/863b630d7da2dbcdbed0/revisions)
// Add Image popup menu with Inverted Background command to get dark mode plots (Christian Rouvière)
// Add standard line adjusting behavior (Christian Rouvière)
// Works with RGB or Composite images
macro "multichannel profile plotter Tool - Cf00D02D13D14D24D25D26D27D38D46D47D56D65D75D85D95Da5Db5Dc5Dc6Dd6Dd7Dd8De7De8Df6Df7C00fD09D1aD1bD2cD2dD2eD3eD3fD4dD4eD5cD6bD7bD7cD8bD9aDabDbaDcaDdbDdcDddDecDedDfbC000T06102"{