Skip to content

Commit da431a7

Browse files
committed
Fix references to image attribute in nifiti provider
1 parent e8800e2 commit da431a7

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

siibra/volumes/providers/nifti.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def fetch(
168168
result = loader()
169169

170170
if voi is not None:
171-
bb_vox = voi.transform_bbox(np.linalg.inv(result.affine))
171+
bb_vox = voi.transform(np.linalg.inv(result.affine))
172172
(x0, y0, z0), (x1, y1, z1) = bb_vox.minpoint, bb_vox.maxpoint
173173
shift = np.identity(4)
174174
shift[:3, -1] = bb_vox.minpoint
@@ -191,15 +191,22 @@ def get_shape(self, resolution_mm=None):
191191
"NiftiVolume does not support to specify different image resolutions"
192192
)
193193
try:
194-
return self.image.shape
194+
loader_shapes = {loader().shape for loader in self._img_loaders.values()}
195+
if len(loader_shapes) == 1:
196+
return next(iter(loader_shapes))
197+
else:
198+
raise RuntimeError(f"Fragments have different shapes: {loader_shapes}")
195199
except AttributeError as e:
196200
logger.error(
197-
f"Invalid object type {type(self.image)} of image for {self} {self.name}"
201+
f"Invalid object type/s {[type(loader()) for loader in self._img_loaders.values()]} of image for {self}."
198202
)
199203
raise (e)
200204

201205
def is_float(self):
202-
return self.image.dataobj.dtype.kind == "f"
206+
return all(
207+
loader().dataobj.dtype.kind == "f"
208+
for loader in self._img_loaders.values()
209+
)
203210

204211
def find_peaks(self, min_distance_mm=5):
205212
"""

0 commit comments

Comments
 (0)