Login  Register

Remove slices from a virtual stack

Posted by Michael Doube on Sep 23, 2009; 10:58am
URL: http://imagej.273.s1.nabble.com/Remove-slices-from-a-virtual-stack-tp3690894.html

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