Skip to content

Commit ebdac01

Browse files
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

File tree

src/openlifu/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
seg_methods,
3535
)
3636
from openlifu.sim import SimSetup
37-
from openlifu.vf import VirtualFit
37+
from openlifu.virtual_fit import virtual_fit
3838
from openlifu.xdc import Transducer
3939

4040
from ._version import version as __version__
@@ -44,7 +44,6 @@
4444
"Transducer",
4545
"Protocol",
4646
"Solution",
47-
"VirtualFit",
4847
"Material",
4948
"SegmentationMethod",
5049
"seg_methods",
@@ -65,6 +64,7 @@
6564
"SimSetup",
6665
"Database",
6766
"User",
67+
"virtual_fit",
6868
"LIFUInterface",
6969
"__version__",
7070
]

src/openlifu/vf/__init__.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/openlifu/vf/virtual_fit.py

Lines changed: 0 additions & 358 deletions
This file was deleted.

0 commit comments

Comments
 (0)