Login  Register

Re: Remove slices from a virtual stack

Posted by Bill Mohler on Sep 23, 2009; 3:14pm
URL: http://imagej.273.s1.nabble.com/Remove-slices-from-a-virtual-stack-tp3690894p3690899.html

I thought there was already a deleteSlice(int n) method in
VirtualStack.java. Is that what you used?

Bill

Michael Doube wrote:

> Never mind,
>
> I discovered the VirtualStack class and hacked a very quick plugin:
>
> http://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/VirtualDelete.java 
>
>
> Mike
>
> Michael Doube wrote:
>> Hi all
>>
>> Is there a quick way to remove slices from a virtual stack?
>>
>> I have several GB of microCT slices that I drag 'n drop in their
>> directory (i.e. drag 'n drop the directory), but then I want to
>> remove the first 300 or so slices and the last 300 or so slices so
>> that I can crop the stack without running out of RAM (the result of
>> the crop operation is not a virtual stack so must be smaller than
>> IJ's allocated memory).
>>
>> I have automated a slice range deletion with this macro, however it's
>> very slow as it has to open each image before deleting it.
>>
>>
>> macro "Delete Slice Range [b]"{
>> Dialog.create("Delete Slice Range");
>> Dialog.addMessage("Inclusive range of slices to delete");
>> Dialog.addNumber("First", getSliceNumber());
>> Dialog.addNumber("Last", getSliceNumber());
>> Dialog.show();
>> first = Dialog.getNumber();
>> last = Dialog.getNumber();
>> setBatchMode(true);
>> deletable = last - first +1;
>> for (deleted = 0; deleted < deletable; deleted++){
>>     showStatus("Deleting slices...");
>>     showProgress(deleted/(deletable-1));
>>     setSlice(first);
>>     run("Delete Slice");
>>    
>> }
>>
>> }
>>
>>
>> Can I simply dereference the images on the hard disk from the virtual
>> stack instead?  I.e. tell the the virtual stack to no longer include
>> images within a specified range?  Another approach might be to create
>> a new virtual stack with the desired images by defining the new slice
>> range in File->Import->Image Sequence... and closing the original.
>>
>>
>> Mike
>>  
>
>