Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous map does not have the same shape as the template #122

Closed
valentin-pinkau opened this issue Apr 19, 2023 · 8 comments
Closed

Continuous map does not have the same shape as the template #122

valentin-pinkau opened this issue Apr 19, 2023 · 8 comments

Comments

@valentin-pinkau
Copy link

valentin-pinkau commented Apr 19, 2023

The continous map of Area Fp1 has a different shape than the corresponding template (97, 115, 97) vs. (193, 229, 193) for the parcellation julich 2.9, space mni152.

@xgui3783
Copy link
Member

related: FZJ-INM1-BDA/siibra-python#302

@valentin-pinkau valentin-pinkau changed the title Continous Map does not have the same shape as the template Continuous Map does not have the same shape as the template Apr 19, 2023
@valentin-pinkau valentin-pinkau changed the title Continuous Map does not have the same shape as the template Continuous map does not have the same shape as the template Apr 19, 2023
@AhmetNSimsek
Copy link
Collaborator

AhmetNSimsek commented Apr 19, 2023

The issue is caused by the template being fetched from a different format, i.e. "neuroglancer/precomputed". siibra-python has the same issue depending on the machine.
After a discussion with @dickscheid, we decided to implement following to siibra-python:

@xgui3783
Copy link
Member

I suspect this can also lead to indeterministic behaviours, especially when network is unstable.

see related issue FZJ-INM1-BDA/siibra-python#318

@AhmetNSimsek
Copy link
Collaborator

I see. So we need to make sure NG returns the "correct" one. We could define a default resolution_mm to be fetched when it is not provided instead of getting the lowest. What do you think?

@xgui3783
Copy link
Member

I see. So we need to make sure NG returns the "correct" one. We could define a default resolution_mm to be fetched when it is not provided instead of getting the lowest. What do you think?

could be a solution.

But this will vary, depending on the voxel resolution of the nifti

@xgui3783
Copy link
Member

a fix is being pushed to dev instanced, deployd at https://siibra-api-latest.apps-dev.hbp.eu/. e.g.:

import requests
import nibabel as nib
SIIBRA_API_HOST = "https://siibra-api-latest.apps-dev.hbp.eu"

MNI152_ID="minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2"
JBA_29_ID="minds/core/parcellationatlas/v1.0.0/94c1125b-b87e-45e4-901c-00daee7f2579-290"
regions = ["Area hOc1 (V1, 17, CalcS) - right hemisphere", "Area Fp1 (FPole) - right hemisphere", None]
endpoints = ["/v3_0/map/statistical_map.nii.gz", "/v3_0/map/labelled_map.nii.gz"]
for endpoint in endpoints:
    for region in regions:
        if region is None and endpoint == "/v3_0/map/statistical_map.nii.gz":
            continue
        
        query_param = {
            'space_id': MNI152_ID,
            'parcellation_id': JBA_29_ID,
        }

        if region:
            query_param['region_id'] = region
        
        resp = requests.get(f"{SIIBRA_API_HOST}{endpoint}", params=query_param)
        resp.raise_for_status()
        with open("boo.nii.gz", "wb") as fp:
            fp.write(resp.content)
        nii = nib.load("boo.nii.gz")
        assert nii.get_fdata().shape == (193, 229, 193)

I will post another update when the changes hits prod.

@xgui3783
Copy link
Member

xgui3783 commented May 3, 2023

I wanted to close this issue, but upon further testing the issue is not yet resolved from upstream siibra-python.

see FZJ-INM1-BDA/siibra-python#368 for the continuation of the issue report.

What this means for siibra-api: you may continue to see masks/statisticalmap/labelled map to have different dimension than the template.

I will post an update when there are new developments.

@xgui3783
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants