     (reduce #(apply rekey %1 %2)
       m (partition 2 (conj ks knew kold)))))
 
+(defn select-and-rekey [m & ks]
+    (apply rekey (select-keys m (apply concat (partition 1 2 ks))) ks))
+
 ;; mm utils
 (defn get-default-devices []
   {:camera          (. mmc getCameraDevice)

                     (clock-ms))]
    (when (pos? sleep-time)
      (Thread/sleep sleep-time)))
  (clock-ms))
  
(defn wait-for-devices [event]
  (. mmc waitForDevice (. mmc getFocusDevice))
  ;; more
  )
  
(defn run-event [event last-wake-time]
  (update-channel event)
  (update-position event)
  (let [new-wake-time (acq-sleep event last-wake-time)]
    (run-autofocus event)
    (update-slice event)
    (wait-for-devices event)
    (snap-image event)
    new-wake-time))

(defn run-events [events]
  (doall (map run-event events)))
  
(defn run-acquisition [settings] 
  (def acq-settings settings)
  (let [acq-seq (generate-acq-sequence settings)]
     (def acq-sequence acq-seq)
     (doall (map println acq-seq))))
  
(defn convert-settings [^SequenceSettings settings]
  (-> settings
    (data-object-to-map)
    (assoc :frames (range (.numFrames settings))
           :channels (filter :use-channel (map ChannelSpec-to-map (.channels settings)))
           :positions (map MultiStagePosition-to-map (.positions settings)))
    (rekey
      :slicesFirst             :slices-first
      :timeFirst               :time-first

              2 [(.x stage-pos) (.y stage-pos)])])))})

;; acq-engine
 
(defn clock-ms []
  (quot (System/nanoTime) 1000000))

