   (while (and (not (@state :stop)) (. mmc isSequenceRunning))
     (Thread/sleep 5)))
 
-(defn collect-snapped-images [event out-queue]
-  (log "collect-snapped-images")
+(defn collect-snap-image [event out-queue]
+  (log "collect-snap-image")
   (doall
     (for [event1 (make-multicamera-events event)]
       (let [image
             {:pix (core getImage (event1 :camera-channel-index))
              :tags nil}]
-        (log "collect-snapped-images: "
-             (select-keys event1 [:position-index :frame-index
+        (log "collect-snap-image: "
+             (select-keys event [:position-index :frame-index
                                  :slice-index :channel-index]))
-        (let [taggedImage (make-TaggedImage (annotate-image image event1 @state (elapsed-time @state)))]
-          (when out-queue
-            (.put out-queue taggedImage))
-          taggedImage)))))
+        (when out-queue
+          (.put out-queue
+                (make-TaggedImage (annotate-image image event1 @state (elapsed-time @state)))))
+        image))))
 
 (defn return-config []
   (dorun (map set-property

    image-tags
    ["Width" "Height" "PixelType"]))  

(defn create-image-window [tagged-images]
  (let [summary {:interval-ms 0.0, :custom-intervals-ms [] :use-autofocus false, :autofocus-skip 0,
                 :relative-slices true, :keep-shutter-open-slices false, :comment "",
                 :prefix "Untitled", :root "",
                 :time-first false, :positions (), :channels [:first], :slices-first true,
                 :slices nil, :numFrames 0, :keep-shutter-open-channels false,
                 :zReference 0.0, :frames (), :save false}
		summary-metadata (make-summary-metadata summary)

   :pixel-type (get-pixel-type)
   :binning (core getProperty (core getCameraDevice) "Binning")})

(defn acquire-tagged-image []
  (binding [state (atom (create-basic-state))]
    (let [event (create-basic-event)]
      (core snapImage)
      (annotate-image (collect-snap-image event nil) event @state nil))))
    
(defn show-image [display tagged-img focus]
  (let [myTaggedImage (make-TaggedImage tagged-img)
        cache (.getImageCache display)]
    (.putImage cache myTaggedImage)
    (.showImage display myTaggedImage)
    (when focus
      (.show display))))

(defn add-to-album []
  (.addToAlbum gui (make-TaggedImage (acquire-tagged-image))))

(defn reset-snap-window [tagged-image]
  (when-not (and @snap-window
                   ;(compatible-image? @snap-window tagged-image)
                   (not (.windowClosed @snap-window)))
    (when @snap-window (.close @snap-window))
    (reset! snap-window (create-image-window tagged-image))))

(defn do-snap []
  (let [tagged-image (acquire-tagged-image)]
    (reset-snap-window tagged-image)
    (show-image @snap-window tagged-image true)))

;; live mode

