Skip to content

Instantly share code, notes, and snippets.

@mutterer
Last active October 13, 2018 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutterer/29660e44fb273627cf9508d1d4e3e2f8 to your computer and use it in GitHub Desktop.
Save mutterer/29660e44fb273627cf9508d1d4e3e2f8 to your computer and use it in GitHub Desktop.
An ImageJ macroset with a tool that places dots with colors reflecting their z position and slice navigation that adjusts dot size to according to distance to the current slice.
var sizes = newArray("Extra Large","Large","Medium","Small","Tiny");
macro "Z-Colored_Dots Tool - Cc0co1166C00co5366C0c0o5866Cc00o8a66" {
roiManager("Associate", false);
r=newArray(256);
for (i=0;i<r.length;i++) {
r[i] = floor(127*(1+sin(2*PI*i/256)));
}
g=Array.copy(r);
b=Array.copy(r);
Array.rotate(g, 80);
Array.rotate(b, 160);
getCursorLoc(x, y, z, flags);
makePoint(x,y);
i = floor(255*(z+1)/nSlices);
col = toHex(r[i]<<16+g[i]<<8+b[i]);
while(lengthOf(col)<6) {col="0"+col;};
run("Properties... ", "stroke=#"+col+" point=Dot size=[Extra Large]");
roiManager('add');
roiManager("Show None");
roiManager("Show All");
}
macro "next slice [q]" {
run("Next Slice [>]");
resizeDots();
}
macro "previous slice [w]" {
run("Previous Slice [<]");
resizeDots();
}
function resizeDots() {
id=getImageID;
cs=getSliceNumber();
setBatchMode(1);
newImage("Untitled", "8-bit ramp", 1, 1, nSlices);
n = roiManager('count');
for (i=0; i<n; i++) {
roiManager('select', i);
sn = getSliceNumber();
size = abs(cs-sn);
if (size<0) size =0;
if (size>4) size =4;
run("Properties... ", "size=["+sizes[size]+"]");
}
selectImage(id);
setBatchMode(0);
setSlice(cs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment