Skip to content

Commit

Permalink
ENH: Add option in tracking mask
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineTheb committed May 9, 2024
1 parent e552c76 commit 05a3f0f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions dwi_ml/tracking/tracking_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,27 @@ def is_vox_corner_in_bound(self, xyz: torch.Tensor):
torch.any(torch.less(xyz, self.lower_bound), dim=-1),
torch.any(torch.greater_equal(xyz, self.higher_bound), dim=-1))

def get_value_at_vox_corner_coordinate(self, xyz, interpolation):
def get_value_at_vox_corner_coordinate(
self, xyz, interpolation, clear_cache=True
):
""" Get the value at the voxel corner coordinate.
Parameters
----------
xyz : torch.Tensor
Coordinates in voxel space, corner origin. Of shape [n, 3].
interpolation : str
Either 'nearest' or 'trilinear'.
clear_cache : bool
Whether to clear the cache after computing the interpolation.
Can be useful to save memory but will slow down the function.
Only used if interpolation is 'trilinear'.
"""

if interpolation == 'nearest':
return torch_nearest_neighbor_interpolation(self.data, xyz)
else:
return torch_trilinear_interpolation(self.data, xyz)
return torch_trilinear_interpolation(self.data, xyz, clear_cache)

def is_vox_corner_in_mask(self, xyz):
# Clipping to bound.
Expand Down

0 comments on commit 05a3f0f

Please sign in to comment.