Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/torchio/data/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def load(self) -> None:
f'Files shape do not match, found {tensor.shape}'
f'and {new_tensor.shape}'
)
RuntimeError(message)
raise RuntimeError(message)
tensors.append(new_tensor)
tensor = torch.cat(tensors)
self.set_data(tensor)
Expand Down
8 changes: 8 additions & 0 deletions tests/data/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ def test_axis_name_2d(self):
assert image.height == image.shape[height_idx]
assert image.width == image.shape[width_idx]

def test_different_shape(self):
path_1 = self.get_image_path('im_shape1', shape=(5, 5, 5))
path_2 = self.get_image_path('im_shape2', shape=(7, 5, 5))

image = tio.ScalarImage([path_1, path_2])
with pytest.raises(RuntimeError):
image.load()

@pytest.mark.slow
@pytest.mark.skipif(sys.platform == 'win32', reason='Unstable on Windows')
def test_plot(self):
Expand Down
Loading