 
 (defn pop-tagged-image []
   (try (core popNextTaggedImage)
-       (catch Exception e nil))) ;(println e))))
+       (catch Exception e nil)))
 
 (defn pop-tagged-image-timeout
   [timeout-ms]
   (let [start-time (System/currentTimeMillis)]
     (loop []
-      (when (keep-collecting-from-circular-buffer?)
-        (if-let [image (pop-tagged-image)]
-          image
-          (if (< timeout-ms (- (System/currentTimeMillis) start-time))
-            (do (println "Timed out waiting for image to arrive from camera.")
-                (throw (Exception. "Timed out waiting for image to arrive from camera.")))
-            (do (Thread/sleep 1)
-                (recur))))))))
+      (if-let [image (pop-tagged-image)]
+        image
+        (if (< timeout-ms (- (System/currentTimeMillis) start-time))
+          (throw-exception "Timed out waiting for image\nto arrive from camera.")
+          (do (Thread/sleep 1)
+              (recur)))))))
 
 (defn pop-burst-image
   [timeout-ms]
   (let [tagged-image (pop-tagged-image-timeout timeout-ms)]
-    ;(println "pop")
-        ;(println tagged-image)
     {:pix (.pix tagged-image)
      :tags (json-to-data (.tags tagged-image))}))
 

   burst-events))

(defn burst-cleanup []
 (when (@state :circular-buffer-overflow)
   (ReportingUtils/showError "Circular buffer overflowed."))
 (while (and (not (@state :stop)) (. mmc isSequenceRunning))
   (Thread/sleep 5)))


(def active-slice-sequence (atom nil))

(def pixel-type-depths {"GRAY8" 1 "GRAY16" 2 "RGB32" 4 "RGB64" 8})

(defn throw-exception [msg]
  (throw (Exception. msg)))

;; time

