FZJ-INM1-BDA / siibra-api

Apache License 2.0
4 stars 3 forks source link

Error while getting template of the fsaverage space #106

Closed marcenko closed 8 months ago

marcenko commented 2 years ago

Getting templates for the fsaverage space return an HTTP 500 error.

Example: https://siibra-api-latest.apps-dev.hbp.eu/v1_0/atlases/juelich%2Fiav%2Fatlas%2Fv1.0.0%2F1/spaces/minds%2Fcore%2Freferencespace%2Fv1.0.0%2Ftmp-fsaverage/templates

Atlas: Juelich atlas Space: fsaverage

marcenko commented 2 years ago

So far it seems to be a problem, that the templates for fsaverage are returned as GIfTI and not as Nifti.

The error occurs while saving the template to disk.

Code: nib.save(nibabel_object, filename)

Error: AttributeError: 'dict' object has no attribute 'to_filename'

xgui3783 commented 2 years ago

I have responded to Valetin, but here's my response in full:

Issue

1/ The current v1 endpoint relies on siibra v 0.3a6. It appears that fetching surface based templates are buggy (and I can only assume to continue to be buggy in latest siibra, please see pt 2) 2/ fsaverage, unlike other templates (MNI152, big brain, colin 27, etc) contains different surface models (inflated, pial and white matter). Additionally, each surface model contains 2 separate hemispheres (i.e. two separate gifti files - surface analog to nifti files). As the current /template endpoint serves a single nifti file, some discussions are needed to be had on how surfaces can be served. As a zip file containing all surfaces perhaps?

Temporary fix

I would recommend querying the space detail. In your example, it would be https://siibra-api-latest.apps-dev.hbp.eu/v1_0/atlases/juelich%2Fiav%2Fatlas%2Fv1.0.0%2F1/spaces/minds%2Fcore%2Freferencespace%2Fv1.0.0%2Ftmp-fsaverage . Under _dataset_specs, look for volume_type: threesurfer/gii . Then, in detail.[threesurfer/gii].surfaces, you will find urls to the gifti files.

At this point, I also regret to inform you that there is one final piece of unorthodoxy: some URLs do not start with https?://, but with root: . I take full responsibility for this. There was a lot of trial and error when attempting to convert fsaverage related data that were given to us. In order to streamline the workflow (at the time), I had this idea of only changing the root URL, so we push iterations rather quickly. We really should have (removed the reference to root: in URL schemes).

So in short, for example, to get gifti for pial projection, left hemisphere, whilst the url reads: root:/lh.pial.gii, it should be https://neuroglancer.humanbrainproject.eu/precomputed/freesurfer/20210305/fsaverage/fsaverage/lh.pial.gii

Please also let me know re: Issue Pt2, from your perspective, would a zip file suffice?

xgui3783 commented 2 years ago

re: the error: it seems the nibabel_object is a dict, likely mapping of {left,right}{pial,white,inflated} to gifti

if it is a gifti file, nibabel should be able to save it.

xgui3783 commented 8 months ago

This issue has been addressed. Whilst https://github.com/FZJ-INM1-BDA/siibra-python/issues/396 continues to be an issue, it is tracked upstream, and will be tracked as such.