Stack Shuffler Macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Stack Shuffler Macro

Michael Doube-2
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
Reply | Threaded
Open this post in threaded view
|

Re: Stack Shuffler Macro

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