                  :when (not (neg? v))]
             [k v]))]
     (swap! attached-runnables conj [template runnable])))
-  
+
 (defn -clearRunnables [this]
   (reset! attached-runnables (vec nil)))
 

  (core snapImage)
  (let [events (make-multicamera-events (create-basic-event))]
    (for [event events]
      (annotate-image (collect-snap-image event nil) event (create-basic-state) nil))))

(defn add-to-album []
  (doseq [img (acquire-tagged-images)]

    (core startSequenceAcquisition (if (first-trigger-missing?) (inc length) length) 0 true)
    (swap! state assoc-in [:last-stage-positions (core getFocusDevice)]
           (last absolute-slices))))

(defn pop-burst-image
  "Returns a TaggedImage from the circular buffer -- times out if no
   image is found in circular buffer after waiting up to timeout-ms."
  [timeout-ms]
  (let [start-time (System/currentTimeMillis)]
    (while (and (. mmc isSequenceRunning)
                (zero? (. mmc getRemainingImageCount)))
      (if (< timeout-ms (- (System/currentTimeMillis) start-time))
        (throw (Exception. "Timed out waiting for image to arrive from camera."))
        (Thread/sleep 5))))
  (let [tagged-image (core popNextTaggedImage)]
    {:pix (.pix tagged-image)
     :tags (json-to-data (.tags tagged-image))}))

(defn make-multicamera-channel [raw-channel-index camera-channel]
  (+ camera-channel (* (core getNumberOfCameraChannels) (or raw-channel-index 0))))

