       (assoc event dim dim-val))
     events))
 
-(defn make-dimensions []
+(defn make-dimensions [settings]
   (let [{:keys [slices channels frames positions
                 slices-first time-first]} settings
         a [[slices :slice] [channels :channel]]

       (not= 0 (mod (% :frame) (-> % :channel :skip-frames inc))))
    events))

(defn process-use-autofocus [events]
  (for [event events]
    (assoc event :autofocus
      (and (settings :use-autofocus)
        (or
          (nil? (event :frame))
          (zero? (mod (event :frame) (inc (settings :autofocus-skip)))))))))

(defn process-wait-time [events]
  (cons
    (assoc (first events) :wait-time-ms 0)
    (for [[e1 e2] (pairs events) :when e2]
      (assoc e2 :wait-time-ms
        (if (= (:frame e1) (:frame e2))
          0
          (settings :interval-ms))))))

(defn generate-acq-sequence [seq-settings]
  (binding [settings seq-settings]
    (-> (make-main-loops)
      process-skip-z-stack
      manage-shutter
      process-use-autofocus
      process-wait-time)))

; Testing:


(defstruct acq-settings :frames :positions :channels :slices :slices-first
  :time-first :keep-shutter-open-slices :keep-shutter-open-channels
  :use-autofocus :autofocus-skip :relative-slices :exposure)

(defn pairs [x]
  (partition 2 1 (concat x [nil])))
