netneurolab / neuromaps

A toolbox for comparing brain maps
https://netneurolab.github.io/neuromaps
Other
246 stars 55 forks source link

Issue transforming fsaverage164k to fslr32k #169

Open VictorBarnes opened 3 months ago

VictorBarnes commented 3 months ago

Description of issue

Hi team,

I'm encountering some issues when transforming fsaverage 164k annotations to fslr 32k.

Here I load the flumazenil annotation (in fsaverage 164k), mask out the medial wall vertices, and plot the distribution.

import nibabel as nib
import matplotlib.pyplot as plt
from neuromaps.datasets import fetch_annotation, fetch_atlas

flum_files = fetch_annotation(desc="flumazenil", space="fsaverage", den="164k")
flum_lh = nib.load(flum_files[0]).darrays[0].data
fsavg = fetch_atlas(atlas="fsaverage", density="164k")
medmask = nib.load(fsavg["medial"][0]).darrays[0].data.astype(bool)

plt.hist(flum_lh[medmask], bins=100)
plt.show()

image

Everything looks fine so far but when I transform to fslr 32k, mask the medial wall, and plot the distribution I get a bunch of vertices with a value of 0 (which I assume to be medial wall vertices).

from neuromaps.transforms import fsaverage_to_fslr

flum_fslr = fsaverage_to_fslr(flum_files, "32k")
fslr = fetch_atlas(atlas="fsLR", density="32k")
medmask = nib.load(fslr["medial"][0]).darrays[0].data.astype(bool)

plt.hist(flum_fslr[0].darrays[0].data[medmask], bins=100)
plt.show()

image

So the fslr 32k mask isn't properly masking out all the medial wall vertices. Plotting these zero indices on the surface seems to indicate that these are medial vertices that just haven't been masked out properly.

image

Do you know what might be the issue? There could be something wrong with the way I'm doing the transforms so do let me know if that's the case. Also, I'm not sure if this is related to #135 ?

Which fsaverage template version does neuromaps use? Maybe the issue is due to the flumazenil data having a different fsaverage version?

Thanks in advance!

Code of Conduct