     (. mmc setShutterOpen false))
     (. mmc waitForDevice (. mmc getShutterDevice)))
 
-(defn generate-tagged-image [img event]
-  (let [tags (JSONObject. (generate-metadata event))]
-    (TaggedImage. img tags)))
+(defn annotate-image [img event]
+  (TaggedImage. img
+    (JSONObject. (merge
+      (map-config (. mmc getSystemStateCache))
+      (generate-metadata event)
+      {"ElapsedTime-ms" (clock-ms)}))))
 
 (defn collect-image [event out-queue]
-  (println event)
-  (.add out-queue (generate-tagged-image (. mmc getImage) (assoc event "ElapsedTime-ms" (clock-ms)))))
+    (.add out-queue (annotate-image (. mmc getImage) event)))
   
 (defn run-event [event last-wake-time out-queue]
   (run-actions (create-presnap-actions event))

   :xy-stage        (. mmc getXYStageDevice)
   :autofocus       (. mmc getAutoFocusDevice)
   :image-processor (. mmc getImageProcessorDevice)})

(defn get-config [group config]
  (let [data (. mmc getConfigData group config)

           [org.micromanager.acquisition AcquisitionWrapperEngine LiveAcqDisplay]
           [org.micromanager.acquisition.engine SequenceSettings]
           [org.micromanager.navigation MultiStagePosition StagePosition]
           [mmcorej TaggedImage Configuration]
           [java.util.prefs Preferences]
           [org.micromanager.utils ChannelSpec MDUtils]
           [org.json JSONObject]
           [java.util.concurrent LinkedBlockingQueue]))

