                    :pos         50
                    :label-dist  15
                    :label-style {:text-anchor "end"}})
-        :data   [(merge (heatmap-spec id) opts)]}
+        :data   [(merge (heatmap-spec id the-matrix) opts)]}
        (viz/svg-plot2d-cartesian)
        (svg/svg {:width 600 :height 300})
        (svg/serialize)
        (spit (str prefix "-" (name id) ".svg"))))
 
 (defn display-state [props grid-cells]
-  (let [cluster-positions (remove nil? (map (fn [[pos-idx char-vec]]
-                                              (let [cluster (::core/cluster char-vec)]
-                                                (if-not (or (= nil cluster)
-                                                            (= "NO_CLASS" cluster))
-                                                  pos-idx)))
-                                            grid-cells))]
-    (if (= 2 (::core/dimensions props))
-      {"none" cluster-positions}
-      (let [_            (println "cluster positions: " cluster-positions)
-            input-matrix (matrix/array :vectorz cluster-positions)
-            _            (println "input mat;" input-matrix)
-            algo-name    :parallel-bht
-            _            (println "tsne: " algo-name)
-            output-map   {algo-name (tsne/tsne input-matrix 2 :tsne-algorithm algo-name :perplexity 0.01)}]
-        output-map)))
+  #_(let [cluster-positions (remove nil? (map (fn [[pos-idx char-vec]]
+                                                (let [cluster (::core/cluster char-vec)]
+                                                  (if-not (or (= nil cluster)
+                                                              (= "NO_CLASS" cluster))
+                                                    pos-idx)))
+                                              grid-cells))]
+      (if (= 2 (::core/dimensions props))
+        {"none" cluster-positions}
+        (let [_            (println "cluster positions: " cluster-positions)
+              input-matrix (matrix/array :vectorz cluster-positions)
+              _            (println "input mat;" input-matrix)
+              algo-name    :parallel-bht
+              _            (println "tsne: " algo-name)
+              output-map   {algo-name (tsne/tsne input-matrix 2 :tsne-algorithm algo-name :perplexity 0.01)}]
+          output-map)))
 
-  ;(cartesian-viz "hm" :rainbow2)
-  ;(cartesian-viz "hm" :orange-blue)
+  (cartesian-viz "hm" :rainbow2 (grids-2d->heatmap-vec grid-cells props))
+  (cartesian-viz "hm" :orange-blue (grids-2d->heatmap-vec grid-cells props))
   )
 
 

  (->> (for [y (range 10) x (range 50)] (n/noise2 (* x 0.1) (* y 0.25)))
       (viz/matrix-2d 50 10)))

(defn heatmap-spec
  [id]
  {:matrix        test-matrix
   :value-domain  (viz/value-domain-bounds test-matrix)
   :palette       (->> id (grad/cosine-schemes) (apply grad/cosine-gradient 100))
   :palette-scale viz/linear-scale
   :layout        viz/svg-heatmap})

(defn cartesian-viz
  [prefix id & [opts]]
  (->> {:x-axis (viz/linear-axis
                  {:domain [0 50]
                   :range  [50 550]

                      ::core/beta        0.3
                      ::core/dimensions  2
                      ::core/phase-space [
                                          {::core/domain-start    -2.5
                                           ::core/domain-end      2.5
                                           ::core/domain-interval 0.1}
                                          {::core/domain-start    -0.5
                                           ::core/domain-end      0.5
                                           ::core/domain-interval 0.1}]
                      ::core/gap-time    50}
        centroids    (vec (repeatedly 3 (fn [] (get-random-sample :unifrom test-props))))
        _            (println "centroids: " centroids)
        samples      (repeatedly 10000 #(hash-map
                                         ::core/raw-datum
                                         {::core/position-value
                                                       (get-random-sample :normal test-props
                                                                          :centroids
                                                                          centroids)
                                          ::core/value 1.0}))

        test-state   {::core/state {::core/grid-cells           {}
                                    ::core/properties           test-props
