Commit ebdac01
committed
Refactor and re-implement virtual fitting (OpenwaterHealth#147)
Major changes:
- The input volume is now just given as a numpy array with an affine,
not an xarray thing. This is more like how a user would actually
have a volume after reading it from disk.
- Many operations are now vectorized rather than relying on a python loop.
There is still a python loop over the virtual fit search grid points,
but there is no inner python loop over the plane-fitting points.
- We work in RAS rather than LPS, since typically when you load a nifti
file into memory it will come in with an affine that maps into RAS.
We can always add a conversion layer later if we want to add flexibility
with how the volume and target are provided. (The transducer transforms
that are returned however still map into LPS space, since all openlifu
transducer transforms have been working this way.) This is just keeping
things simpler for the initial approach.
- The algorithm has been written in an imperative functional style rather than using
a dataclass. This is easier to read and iterate on at first, and while
some object oriented approach probably makes sense eventually, it is
hard to get it exactly right without first having a fully working
algorithm in place to see how it fits in with the rest of the
application.
- The virtual_fit module has been moved to the top level, so no more vf
package to go through first. We can move it into its own vf package if
we add tons of new independent files, but to start with we should
organize things more simply.
- (internal change) yaw and pitch are internally converted to spherical
coordinates $\theta$ and $\phi$ to make it easier to work in that
coordinate system. Also $\theta$ and $\phi$ were swapped from the minor
previously existing usage, to match the physics convention. The relation
is that pitch is $\phi$ and yaw is $90-\theta$. The $90-\theta$ is there
to allow us to use a more standard version of spherical coordinates
(where previously we had a confusing swap of sines with cosines from the
standard approach).1 parent 9c2e72b commit ebdac01
4 files changed
Lines changed: 209 additions & 367 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
| |||
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
This file was deleted.
This file was deleted.
0 commit comments