 (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)
-
-(declare settings)
 
 (defn pairs [x]
   (partition 2 1 (concat x [nil])))

(defn create-loops [dimensions]
  (reduce #(apply (partial nest-loop %1) %2) [{:task :snap}] dimensions))

(defn make-main-loops []
  (create-loops (make-dimensions)))

(defn manage-shutter [events]
  (for [[e1 e2] (pairs events)]
    (assoc e1 :close-shutter
      (if e2 (or
               (and
                 (not (settings :keep-shutter-open-channels))
                 (not= (e1 :channel) (e2 :channel)))
               (and
                 (not (settings :keep-shutter-open-slices))
                 (not= (e1 :slice) (e2 :slice)))
               (not= (e1 :frame) (e2 :frame))
               (not= (e1 :position) (e2 :position)))
        true))))

(defn process-skip-z-stack [events]
  (let [slices (settings :slices)
        middle-slice (nth slices (int (/ (count slices) 2)))]
    (filter
      #(or
         (nil? (% :channel))
         (-> % :channel :use-z-stack)
         (= middle-slice (% :slice)))
      events)))

(defn process-channel-skip-frames [events]
  (filter

    :use-autofocus true :autofocus-skip 3 :relative-slices true :exposure 100
    :interval-ms 100))

;(def result (generate-acq-sequence null-settings))

;(count result)