FZJ-INM1-BDA / siibra-python

Software interfaces for interacting with brain atlases - Python client
Apache License 2.0
48 stars 10 forks source link

Default fetch() for probability maps fails #596

Closed dickscheid closed 3 months ago

dickscheid commented 3 months ago

siibra version: 1.0a11

When fetching from a sparse map without arguments, the expected behavior would be that siibra informs that a region or index needs to be specified. The current version however fails:

pmaps = siibra.parcellations.get('julich').get_map(space='mni152', maptype='statistical')
pmaps.fetch()

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
File ~/venvs/siibra-prod/lib/python3.11/site-packages/siibra/volumes/sparsemap.py:416, in SparseMap.fetch(self, region_or_index, index, region, **kwargs)
    415 try:
--> 416     assert len(self) == 1
    417     volidx = 0

AssertionError: 

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
Cell In[63], line 1
----> 1 pmaps.fetch()

File ~/venvs/siibra-prod/lib/python3.11/site-packages/siibra/volumes/sparsemap.py:419, in SparseMap.fetch(self, region_or_index, index, region, **kwargs)
    417         volidx = 0
    418     except AssertionError:
--> 419         raise parcellationmap.InsufficientArgumentException(
    420             f"{self.__class__.__name__} provides {len(self)} volumes. "
    421             "Specify 'region' or 'index' for fetch() to identify one."
    422         )
    424 assert isinstance(volidx, int)
    425 x, y, z, v = self.sparse_index.mapped_voxels(volidx)

AttributeError: module 'siibra.volumes.parcellationmap' has no attribute 'InsufficientArgumentException'
dickscheid commented 3 months ago

I think that raising an appropriate exception would also be ok, which is probably meant here but not correctly implemented.