Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rounding scheme for neuroglancer fetching needs revision #642

Merged
merged 3 commits into from
Mar 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions siibra/volumes/providers/neuroglancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,7 @@
if voi is None:
bbox_ = _boundingbox.BoundingBox((0, 0, 0), self.size, space=None)
else:
bbox_ = voi.transform(np.linalg.inv(self.affine))

for dim in range(3):
if bbox_.shape[dim] < 1:
logger.warning(
f"Bounding box in voxel space will be enlarged to by {self.res_mm[dim]} along axis {dim}."
)
bbox_.maxpoint[dim] = bbox_.maxpoint[dim] + self.res_mm[dim]
bbox_ = voi.transform(np.linalg.inv(self.affine), space=None)

Check warning on line 532 in siibra/volumes/providers/neuroglancer.py

View check run for this annotation

Codecov / codecov/patch

siibra/volumes/providers/neuroglancer.py#L532

Added line #L532 was not covered by tests

# extract minimum and maximum the chunk indices to be loaded
gx0, gy0, gz0 = self._point_to_lower_chunk_idx(tuple(bbox_.minpoint))
Expand All @@ -559,8 +552,12 @@
# exact bounding box requested, to cut off undesired borders
data_min = np.array([gx0, gy0, gz0]) * self.chunk_sizes
x0, y0, z0 = (np.array(bbox_.minpoint) - data_min).astype("int")
xd, yd, zd = np.ceil((np.array(bbox_.maxpoint))).astype(int) - np.floor((np.array(bbox_.minpoint))).astype(int)
xd, yd, zd = np.ceil(bbox_.maxpoint).astype(int) - np.floor(bbox_.minpoint).astype(int)
offset = tuple(bbox_.minpoint)
if voi is not None:
logger.debug(

Check warning on line 558 in siibra/volumes/providers/neuroglancer.py

View check run for this annotation

Codecov / codecov/patch

siibra/volumes/providers/neuroglancer.py#L558

Added line #L558 was not covered by tests
f"Input: {voi.minpoint.coordinate}, {voi.maxpoint.coordinate}.\nVoxel space: {bbox_.minpoint.coordinate}, {bbox_.maxpoint.coordinate}"
)

# build the nifti image
trans = np.identity(4)[[2, 1, 0, 3], :] # zyx -> xyz
Expand Down
Loading