6 (nuc (first (get-visible-nuclei k
)))
7 (vol (get-lcos-volume k nuc
)))
8 (format t
"~a~%" `(nuc ,nuc
))
9 (write-section "/home/martin/tmp/angular-0lcos-cut.pgm" vol
)
10 (save-stack-ub8 "/home/martin/tmp/angular-0lcos" (normalize-3-csf/ub8-realpart vol
)))
12 ;; FIXME: are these coordinates in mm or relative positions for a bfp-radius of 1?
13 ;; I think the latter, but I'm not sure.
19 (z (array-dimension *spheres
* 0))
20 (psf (angular-psf :x r
:y r
:z
(* 2 z
)
21 :pixel-size-x dx
:pixel-size-z dz
22 :window-radius
*bfp-window-radius
*
27 :integrand-evaluations
400)))
28 (save-stack-ub8 "/home/martin/tmp/psf" (normalize3-cdf/ub8-realpart psf
))
32 ;; calculate the excitation one nucleus
34 (defun calc-light-field (k nucleus
)
35 (declare (fixnum k nucleus
))
37 (lcos (get-lcos-volume k nucleus
))
38 (bfp-pos (find-optimal-bfp-window-center nucleus
))
42 (z (array-dimension *spheres
* 0)))
43 (multiple-value-bind (h ddx ddz
)
44 (angular-intensity-psf-minimal-resolution
45 :x-um
(* r dx
) :y-um
(* r dx
) :z-um
(* 2 z dz
)
46 :window-radius
*bfp-window-radius
*
47 :window-x
(vec2-x bfp-pos
)
48 :window-y
(vec2-y bfp-pos
)
51 :integrand-evaluations
1000)
52 (resample-3-cdf h ddx ddx ddz dx dx dz
)))))
53 (format t
"~a~%" `(bfp-pos ,bfp-pos
))
54 (write-section (format nil
"/home/martin/tmp/angular-1expsf-cut-~3,'0d.pgm" nucleus
) psf
)
56 (multiple-value-bind (conv conv-start
)
57 (convolve-nocrop lcos psf
)
58 ;; light distribution in sample
59 (defparameter *angular-light-field
* conv
)
60 (defparameter *angular-light-field-start
* conv-start
)
61 (write-section (format nil
"/home/martin/tmp/angular-2light-cut-~3,'0d.pgm" nucleus
)
63 (vec-i-y (aref *centers
* nucleus
)))
64 (save-stack-ub8 (format nil
"/home/martin/tmp/angular-2light-~3,'0d/" nucleus
)
65 (normalize-3-cdf/ub8-realpart conv
))
66 ;; multiply fluorophore concentration with light distribution
67 (let ((excite (.
* conv
*spheres
* conv-start
)))
68 (defparameter *excite
* excite
)
69 (write-section (format nil
"/home/martin/tmp/angular-3excite-cut-~3,'0d.pgm" nucleus
)
71 (vec-i-y (aref *centers
* nucleus
)))
72 (save-stack-ub8 (format nil
"/home/martin/tmp/angular-3excite-~3,'0d/" nucleus
)
73 (normalize-3-cdf/ub8-realpart excite
))
74 (destructuring-bind (z y x
)
75 (array-dimensions excite
)
76 (declare (ignorable z
))
77 (let* ((in-focus (extract-bbox-3-cdf excite
78 (make-bbox :start
(v 0d0
0d0
(* 1d0 k
))
79 :end
(v (* 1d0
(1- x
))
82 (save-stack-ub8 "/home/martin/tmp/angular-4in-focus/"
83 (normalize-3-cdf/ub8-realpart in-focus
))
84 (let*((mplane (mean (convert-3-cdf/df-realpart in-focus
)))
85 (mvol (mean (convert-3-cdf/df-realpart excite
)))
86 (gamma (/ mplane mvol
)))
87 (push (list mplane mvol gamma
) result
)
88 (debug-out mplane mvol gamma
)
89 (format t
"plane-result ~f ~f ~f~%" mplane mvol gamma
))
95 (with-open-file (*standard-output
* "/home/martin/tmp/angular-stack.log"
98 :if-does-not-exist
:create
)
100 (dotimes (k (array-dimension *spheres
* 0))
101 (let* ((nucs (get-visible-nuclei k
)))
102 (loop for nuc in nucs do
103 (format t
"~a~%" (list 'doing k nucs
))
104 (push (list k nuc
(calc-light-field k nuc
)) result
))))
105 (defparameter *scan-result
* result
)))
106 (with-open-file (s "/home/martin/tmp/angular-stack-struc.lisp"
108 :if-exists
:supersede
109 :if-does-not-exist
:create
)
110 (write *scan-result
* :stream s
))))
117 (let ((vol (make-array dims
:element-type
'(unsigned-byte 8))))
118 (loop for i in
'(4.0d-3 -
.2d-3
) do
119 (draw-ray-into-vol i
0d0
.99d0
.0d0 vol
)
120 #+nil
(draw-ray-into-vol i
0d0 -
.99d0
.0d0 vol
)
121 (draw-ray-into-vol i
0d0
0d0
.99d0 vol
)
122 (draw-ray-into-vol i
0d0
0d0 -
.99d0 vol
))
124 (save-stack-ub8 "/home/martin/tmp/line"
128 frontend
::merit-function
133 (a (make-array (list n n
) :element-type
'(unsigned-byte 8)))
134 (nn (length *spheres-c-r
*))
135 (mosaicx (ceiling (sqrt nn
)))
136 (mosaic (make-array (list (* n mosaicx
) (* n mosaicx
))
137 :element-type
'(unsigned-byte 8))))
138 (with-open-file (*standard-output
* "/dev/shm/a"
140 :if-exists
:supersede
)
141 (dotimes (*nucleus-index
* 1 nn
)
144 (multiple-value-bind (min point
)
145 (simplex-anneal:anneal
(simplex-anneal:make-simplex
146 (make-vec2 :x -
1d0
:y -
1d0
) 1d0
)
148 ;; set temperature bigger than the
149 ;; maxima in the bfp but smaller
151 :start-temperature
2.4d0
156 (unless (<= min
100d0
)
158 (let* ((x (aref point
0))
160 (ix (floor (* n
(+ x
1)) 2))
161 (iy (floor (* n
(+ y
1)) 2))
162 (mx (mod *nucleus-index
* mosaicx
))
163 (my (floor *nucleus-index
* mosaicx
)))
164 (incf (aref mosaic
(+ (* n my
) iy
) (+ (* n mx
) ix
)))
165 (format t
"min ~a~%" (list min ix iy
))))))))
166 (write-pgm "/home/martin/tmp/scan-mosaic-max.pgm" mosaic
)))