Stack Shuffler Macro
Posted by Michael Doube-2 on Jan 05, 2007; 2:26am
URL: http://imagej.273.s1.nabble.com/Stack-Shuffler-Macro-tp3700695.html
Dear List,
I wanted to shuffle images in a stack into order of severity of
pathology for later rank analysis, so I wrote a little macro to help.
I traverse the slices of the stack with [<] and [>], and decide whether
to promote [l] or demote [j] the slice to a severe position (high slice
number) or mild position (low slice number), based on a comparison
between the image of interest and its neighbours in the stack.
Sometimes I get the error "Image is Locked" and the copied data seems to
get lost - particularly when I'm operating the macro a bit too fast. Is
there a good way around that problem?
Cheers, and a slightly late Happy New Year,
Mike
StackShuffler.txt
----------------------------
macro "Promote Slice... [l]"{
n = getSliceNumber();
if (n == nSlices){exit("Can't promote the last image of a stack");}
name = getMetadata;
run("Select All");
run("Copy");
run("Delete Slice");
setSlice(n);
run("Add Slice");
run("Paste");
setMetadata(name);
}
macro "Demote Slice... [j]"{
n = getSliceNumber();
if (n == 1){exit("Can't demote the first image of a stack");}
name = getMetadata;
run("Select All");
run("Copy");
run("Delete Slice");
setSlice(n-2);
run("Add Slice");
run("Paste");
setMetadata(name);
}
--------------------------
--
Michael Doube BPhil BVSc MRCVS
PhD Student
Dental Institute
Queen Mary, University of London
New Rd
London E1 1BB
United Kingdom
Phone +44 (0)20 7377 7000 ext 2681