Login  Register

Re: Remove slices from a virtual stack

Posted by Wayne Rasband on Sep 23, 2009; 5:08pm
URL: http://imagej.273.s1.nabble.com/Remove-slices-from-a-virtual-stack-tp3690894p3690902.html

The Process>Batch>Virtual Stack command in the v1.43g daily build will
crop a virtual stack, creating a new virtual stack.

    1. Run Process>Batch>Virtual Stack
    2. Click "Output" and select an empty folder
    3. Select "Crop" from the "Add Macro Code" menu
    4. Edit the macro as needed
    5. Click "Process"

-wayne

 > 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