Closed dickscheid closed 1 month ago
what I would it expect to be doing is sth like this:
import siibra
import nibabel as nib
import numpy as np
labelled_map = siibra.get_map('julich 3', maptype='labelled', space='mni152')
mapimg = labelled_map.fetch()
region = labelled_map.parcellation.get_region('cerebral cortex')
child_labels = [
labelled_map.get_index(_).label
for _ in labelled_map.regions
if labelled_map.parcellation.get_region(_).has_parent(region)
]
mapdata = np.asanyarray(mapimg.dataobj)
maskdata = np.zeros_like(mapdata)
for l in child_labels:
maskdata[mapdata == l] = 1
result = nib.Nifti1Image(maskdata, mapimg.affine)
Resampling is necessary for maps that do not have the same affine and resample will return the same nifti if resmapling is not required (thanks to nilearn). So the existing version is more robust.
Merge, by definition requires more than 1 volume but we can just return the volume provided.
Observed in version 1.0a14:
fails when it ends up trying to merge less than two volumes in volumes/volume.py:673. It also appears to resample several volumes, which should not be necessary. I think this problem is already fixed in the siibra 2 development branches, but we might need a fix in the production version for the time being.