Skip to content

Commit

Permalink
Update resampled_array.py
Browse files Browse the repository at this point in the history
Allow resampled array to implicitly handle requests for non-integer scaling of the source array by finding the common multiple voxel size of the source array and request.
  • Loading branch information
rhoadesScholar authored Sep 19, 2024
1 parent 3430d6a commit ba7fa43
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ def roi(self) -> Roi:
This method returns the region of interest of the resampled array.
"""
return self._source_array.roi.snap_to_grid(self.voxel_size, mode="shrink")
return self._source_array.roi.snap_to_grid(
np.lcm(self._source_array.voxel_size, self.voxel_size), mode="shrink"
)

@property
def writable(self) -> bool:
Expand Down Expand Up @@ -281,7 +283,9 @@ def __getitem__(self, roi: Roi) -> np.ndarray:
Note:
This method returns the data of the resampled array within the given region of interest.
"""
snapped_roi = roi.snap_to_grid(self._source_array.voxel_size, mode="grow")
snapped_roi = roi.snap_to_grid(
np.lcm(self._source_array.voxel_size, self.voxel_size), mode="grow"
)
resampled_array = funlib.persistence.Array(
rescale(
self._source_array[snapped_roi].astype(np.float32),
Expand Down

0 comments on commit ba7fa43

Please sign in to comment.