         (catch Exception e (println e))
         (finally (.close file)))
       filename))
+
+(defn acquire-and-map
+  [num-images]
+  (let [buffer-queue (time (byte-buffer-queue num-images))]
+    (let [filename (str "D:/AcquisitionData/test" (rand-int 100000) ".dat")
+          file (RandomAccessFile. filename "rw")
+          channel (.getChannel file)
+          out (.. file getChannel (map FileChannel$MapMode/READ_WRITE 0 (* num-images 2560 2160 2)))]
+      (try
+        (dotimes-timed [i num-images] 100
+                       (let [pixels (.take buffer-queue)]
+                         (.put out pixels)))
+        (catch Exception e (println e))
+        (finally (.close file))))))
+        
 
 (defn acquire-and-store-in-ram
   "Simulate running a sequence acquisition, and store

   images to a file using the direct byte buffer method."
  [num-images]
    (let [filename (str "D:/AcquisitionData/test" (rand-int 100000) ".dat")
          file (RandomAccessFile. filename "rw")
          channel (.getChannel file)]
      (try
        (let [buffer-queue (time (byte-buffer-queue num-images))]

  (:import (java.util.concurrent LinkedBlockingQueue)
           (mmcorej TaggedImage)
           (java.nio ByteBuffer ByteOrder)
           (java.io FileOutputStream RandomAccessFile)
           (java.nio.channels FileChannel$MapMode))
  (:require [org.micromanager.mm :as mm])
  (:use [org.micromanager.mm :only (core)]))

