constantinpape/torch-em

Error messages for ROIs

Opened this issue · 0 comments

Description

When using ROIs in the torch_em Dataloader (I used: torch_em.default_segmentation_loader) there is a generic error message if the ROIs do not fit (e.g. empty or incorrect size).
Error message:

File "/home/freckmann15/miniforge3/envs/sam/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 631, in __next__
    data = self._next_data()
           ^^^^^^^^^^^^^^^^^
  File "/home/freckmann15/miniforge3/envs/sam/lib/python3.11/site-packages/torch/utils/data/dataloader.py", line 1319, in _next_data
    raise StopIteration
StopIteration

This message is quite difficult to interpret and therefore it is difficult to fix.
The error can be fixed by having a min_shape for the ROIs so ROIs are at least the shape of the patch_shape used.
I would suggest a more specific error message for this case.