Re: Stack Shuffler Macro

Posted by Gabriel Landini on
URL: http://imagej.273.s1.nabble.com/Stack-Shuffler-Macro-tp3700695p3700696.html

On Friday 05 January 2007 02:26, Michael Doube wrote:

> 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?

I had similar problems with other macros that deal with slices.

Perhaps not very elegant, but try to add a pause somewhere in the macro:

wait(200);

or something like that (you can try smaller/larger values and see if it solves
it). It helped in my case, so I presume that one command was executed while
the previous one hadn't released the lock). This seemed to happen in linux
but not in windows, but I am not sure why.

Cheers,

G.

>
> 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);
> }
> --------------------------