public ImageStack makeStack (String path, int firstFrame, int lastFrame,
            boolean isVirtual, boolean convertToGray, boolean flipVertical) {
        this.firstFrame = firstFrame;
        this.lastFrame = lastFrame;
        this.isVirtual = isVirtual;
        this.convertToGray = convertToGray;
        this.flipVertical = flipVertical;
        String exceptionMessage = null;
        IJ.showProgress(.001);
        try {
            readAVI(path);
        } catch (OutOfMemoryError e) {
            stack.trim();
            IJ.showMessage("AVI Reader", "Out of memory.  " + stack.getSize() + " of " + dwTotalFrames + " frames will be opened.");
        } catch (Exception e) {
            exceptionMessage = exceptionMessage(e);
        } finally {
            try {
                raFile.close();
                if (verbose)
                    IJ.log("File closed.");
            } catch (Exception e) {}
            IJ.showProgress(1.0);
        }
        if (exceptionMessage != null) {
           error(exceptionMessage);
           return null;
        }
        if (isVirtual && frameInfos != null)
            stack = this;
        if (stack!=null && cm!=null)
            stack.setColorModel(cm);
        return stack;
    }