Skip to content

Commit

Permalink
Merge pull request #272 from Image-X-Institute/bugfix/marker_translation
Browse files Browse the repository at this point in the history
add translation test, remove cast to int on rotate
  • Loading branch information
bwheelz36 committed Jan 25, 2024
2 parents 68a56f1 + 11c1967 commit 7335ff8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mri_distortion_toolkit/MarkerAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def rotate_markers(self, xaxis_angle=0, yaxis_angle=0, zaxis_angle=0):
:param zaxis_angle: rotation around z angle in degrees
"""

rotate = np.array([xaxis_angle, yaxis_angle, zaxis_angle], dtype=np.int16)
rotate = np.array([xaxis_angle, yaxis_angle, zaxis_angle])
rotation_vector = transform.Rotation.from_euler('xyz', rotate, degrees=True)
# Transform centroids
rotated = rotation_vector.apply(self.MarkerCentroids[['x', 'y', 'z']])
Expand Down
2 changes: 1 addition & 1 deletion mri_distortion_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
https://acrf-image-x-institute.github.io/MRI_DistortionQA/index.html
"""

__version__ = '0.14.7'
__version__ = '0.14.8'
try:
import FreeCAD
except ImportError:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_MarkerAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,19 @@ def test_marker_matching_rigid():
matched_volume = MatchedMarkerVolumes(volume1, volume2, sorting_method='nearest')
assert np.allclose(matched_volume.MatchedCentroids.match_distance, expected_distance)


def test_marker_translation():

x_shift = 1.1
y_shift = 2.2
z_shift = 3
data_loc = this_dir / 'test_data' / 'CT.mrk.json'
volume = MarkerVolume(data_loc)
volume_to_move = MarkerVolume(data_loc)
volume_to_move.translate_markers(x_shift=x_shift, y_shift=y_shift, z_shift=z_shift)

diff = volume.MarkerCentroids - volume_to_move.MarkerCentroids
assert np.isclose(np.mean(diff.x), -x_shift)
assert np.isclose(np.mean(diff.y), -y_shift)
assert np.isclose(np.mean(diff.z), -z_shift)

0 comments on commit 7335ff8

Please sign in to comment.