Login  Register

Re: Remove Blocks of Slices from Stack

Posted by John Oreopoulos on Mar 03, 2010; 6:57pm
URL: http://imagej.273.s1.nabble.com/Remove-Blocks-of-Slices-from-Stack-tp3689145p3689148.html

Hi Kevin. I had a similar need a couple years ago and someone on the  
ImageJ list helped me put together a small macro that does what you  
described you wanted it to do:

a=0;
n=getNumber("Frame reduction ratio (1/n)", 5);
for (i=1;i<=nSlices;)
{
        run("Set Slice...", "slice="+i);
        if(a!=0)
                run("Delete Slice");
        else
                i++;
        a++;
        if(a==n)
                a=0;
}

John Oreopoulos


On 3-Mar-10, at 1:23 PM, Kevin Clark wrote:

> Excellent Thanks, I'll give it a try. Plus I was unaware of Fiji  
> until now.
>  Checking it out.
>
> Thanks
>
> KEvin
>
> On Wed, Mar 3, 2010 at 10:24 AM, Johannes Schindelin <
> [hidden email]> wrote:
>
>> Hi,
>>
>> On Wed, 3 Mar 2010, kev0153 wrote:
>>
>>> I have a stack of 1000 slices.  I would like to remove a block of 6
>>> slices. For example Slice 1 keep, slice 1-6 remove, slice 8 keep,  
>>> slice
>>> 8-14 remove, slice 15 keep etc..
>>>
>>> I could do this by hand but with 1000 slices it would take  
>>> awhile.  I
>>> don't really know java so any help would be appreciated thanks
>>
>> If you are using Fiji, you can use Image>Stacks>Manipulation>Substack
>> Maker. Otherwise, you might want to run a macro like this:
>>
>>        Dialog.create("Delete slice range");
>>        Dialog.addNumber("first_slice", 1);
>>        Dialog.addNumber("last_slice", 1);
>>        Dialog.show();
>>
>>        first = Dialog.getNumber();
>>        count = Dialog.getNumber() + 1 - first;
>>
>>        setSlice(first);
>>        for (i = 0; i < count; i++)
>>                run("Delete Slice");
>>
>> (Note: this is completely untested, so you might need to fix a  
>> typo or
>> two.)
>>
>> This macro only allows deleting one consecutive slice range,  
>> though, so
>> you have to start it 6 times.
>>
>> Ciao,
>> Johannes
>>
>>