Skip to content

Commit 9d3acf7

Browse files
Move ArrayTransform into geo
This is part of work towards OpenwaterHealth#166. The standoff_transform that goes into virtual fit ought to have units associated with it, since it may often be provided in transducer native units which can be different from the volume RAS space units. So at this point ArrayTransform is more generally useful and doesn't belong in session.py.
1 parent 975282c commit 9d3acf7

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

src/openlifu/db/session.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,11 @@
99

1010
import numpy as np
1111

12-
from openlifu.geo import Point
12+
from openlifu.geo import ArrayTransform, Point
1313
from openlifu.util.json import PYFUSEncoder
1414
from openlifu.util.strings import sanitize
1515

1616

17-
@dataclass
18-
class ArrayTransform:
19-
"""Class representing the transform on a transducer array to position it in space.
20-
units:
21-
"""
22-
23-
matrix: np.ndarray
24-
"""4x4 affine transform matrix"""
25-
26-
units : str
27-
"""The units of the space on which to apply the transform matrix , e.g. "mm"
28-
(In order to apply the transform to transducer points,
29-
first represent the points in these units.)"""
30-
3117
@dataclass
3218
class TransducerTrackingResult:
3319
"""

src/openlifu/geo.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ def to_json(self, compact:bool) -> str:
139139
return json.dumps(self.to_dict(), indent=4)
140140

141141

142+
@dataclass
143+
class ArrayTransform:
144+
"""An affine transform with a unit string, often intended to represent how a transducer array is positionsed in space."""
145+
146+
matrix: np.ndarray
147+
"""4x4 affine transform matrix"""
148+
149+
units : str
150+
"""The units of the space on which to apply the transform matrix , e.g. "mm"
151+
(In order to apply the transform to points, first represent the points in these units.)
152+
"""
153+
142154
# === Tools to work with spherical coordinate systems ===
143155

144156
def cartesian_to_spherical(x:float,y:float,z:float) -> Tuple[float, float, float]:

tests/test_database.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
from helpers import dataclasses_are_equal
1414
from vtk import vtkImageData, vtkPolyData
1515

16-
from openlifu import Point, Solution
16+
from openlifu import Solution
1717
from openlifu.db import Session, Subject, User
1818
from openlifu.db.database import Database, OnConflictOpts
19-
from openlifu.db.session import ArrayTransform, TransducerTrackingResult
19+
from openlifu.db.session import TransducerTrackingResult
20+
from openlifu.geo import ArrayTransform, Point
2021
from openlifu.photoscan import Photoscan
2122
from openlifu.plan import Protocol, Run
2223
from openlifu.xdc import Transducer

0 commit comments

Comments
 (0)