netneurolab / neuromaps

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

Spin permutations for case-control betamaps #101

Closed clarkenj closed 1 year ago

clarkenj commented 1 year ago

Description of issue

Thank you for creating such an awesome tool! I'm wondering if I can use neuromaps for my research and would be grateful for any advice you can give.

I have computed whole-brain connectomes for different groups of patients and respective controls, z scored connectivity based on the controls and then used regression to estimate connectivity at each connection, generating case versus control betamaps. I then want to correlate each of these betamaps with each other to test for overlap in connectivity alterations. I am currently just doing a permutation test where I permute subject labels to get null models and compute a p value, but would like to run a spin permutation to account for autocorrelation.

I see I can load arrays using neuromaps. Could I load the case and control connectomes as arrays and generate spun permutations for each connection, run the regression and calculate p value (masking all other connections), then correct across connections? Or is there a different approach you would recommend? Thank you so much, please let me know if this is not clear!

Code of Conduct

justinehansen commented 1 year ago

Hi Natasha, thanks for reaching out with your question!

Honestly I don't quite understand your specific scenario so here are some general use-cases but feel free to expand on what you're doing so I can give a more tailored response 😅

If you're correlating brain maps with one another then yes you can definitely use neuromaps to generate your rotated data. You can either generate rotated maps for a specific map or you can generate the indices which you can reuse. If your data is at the surface level then all you need to know is the name and density of your surface space (eg fsaverage 164k); if it's volumetric then unfortunately the spin nulls won't work but you can try the generative/parametrized nulls (eg nulls.burt2018()); if it's parcellated data then you'll need the parcellation file that maps from surface to parcels. More info about how to generate these nulls here.

That said, unless I'm misunderstanding something (very possible) then it sounds like your maps aren't brain maps but edge-level connectomes (eg region x region matrices instead of region x 1 arrays). If that's the case, what I've done before is use neuromaps to generate the spin indices (by setting data=None) and then use the indices to spin the rows and columns of my connectome. Something like this:

idx = nulls.alexander_bloch(data=None, atlas='fsaverage', density='10k', n_perm=1, seed=1234, parcellation=parcellation)`
connectome_null = connectome[np.ix_(idx, idx)]

Let me know if this is unclear of if I've misunderstood your question!

Best, Justine

clarkenj commented 1 year ago

Hi Justine,

Thank you so much for your quick response! You're absolutely correct with your second part, my maps are edge-level connectomes (apologies for my confusing explanation!), so I will try what you suggest, thank you! Do you have any papers using this approach that you could point me to at all?

Best, Natasha

justinehansen commented 1 year ago

Great - glad I can be helpful! Re papers: I used this approach in Fig 5 of this paper, but I don't formally introduce the method. I'm honestly not sure where else this approach has been used. I usually just see distance-regression instead of the spin null, which I think is also a good approach.

Actually @frantisekvasa had a poster about this at OHBM last year and might have better advice to give. I think he was recommending spinning within-hemisphere for both rows and columns but it's very possible I'm misremembering. Frantisek, do you know of any papers that introduce edge-level spatial null methods/is your OHBM poster preprinted? 👀 👀

Best, Justine

clarkenj commented 1 year ago

Thank you so much, I will try some things out! Looking forward to any advice Frantisek can offer also, if possible.

clarkenj commented 1 year ago

Hi Justine, please could I check something with you? I have used the MIST parcellation in my study which is in MNI152 space. It looks from the documentation like the appropriate null modelsneuromaps.nulls.burt2018(), neuromaps.nulls.burt2020() and neuromaps.nulls.moran() do not accept None type for Data, is this correct?

Also, I am using 64 parcels and at this scale parcels are not lateralized, so I don't think I can pass a parcellation image in the form ([left, right] hemisphere). I tried with just the nifti and got an error. Apologies for bothering you with these questions, I wonder if there is something I have missed, or misunderstood. If you can point me in the right direction of I would be really grateful! Thank you for your time!

Best, Natasha

justinehansen commented 1 year ago

Ahh hm that's a good question. The tl;dr is that I'm not sure what you can do 😅

You're right that data=None doesn't work for parametric spatial nulls. This is because these nulls estimate the autocorrelation of your data and generate surrogate maps with approximately the same autocorrelation - which it can't do without data. (In contrast, the spin test is a geometric procedure applied on the physical surface.) So this won't work for you because in your case you just need the indices.

Second option is to transform the parcellation file from MNI152 to a surface to run the spins. You can use neuromaps.transforms.mni152_to_fsaverage() to do this but be sure to set method='nearest' (not the default) so that the output is still made up of discrete label values. But the problem with this is that spins are applied on each hemisphere separately so this doesn't work for you either since you have parcels that cover both hemispheres.

Soo I'm a bit stumped. Tagging @VinceBaz to see if he has ideas?

Sorry I don't have a satisfying answer for you!

Justine

clarkenj commented 1 year ago

Thank you so much for your help Justine!

VinceBaz commented 1 year ago

Hi Nathasha and Justine,

This is an interesting problem. I have a few suggestions/comments to make.

First, regarding Justine's suggestion of transforming the parcellation in volumetric space to surface space and then generate spin surrogates: it's indeed tricky since the parcels are not lateralized. However, it's worth noting that the rotation used to generate a "spin" null for one hemisphere is mirrored across the Y-Z plane to obtain the rotation for the other hemisphere. So technically, the inter-hemispheric relationships should be preserved, which makes me think that it would be fine to use spin nulls even thought the parcels are not lateralized? This should however be tested as I've never tried it.

Second, you could "technically" use nulls.burt2020, even thought it is a parametric null model since the Base generator from brainSMASH (which is what neuromaps relies on), has a resample parameter which, when set to True, resamples the surrogate map values from the original brain map. In other words, the original distribution would be preserved. So technically, you could map each parcel in the surrogate maps to it's original parcel and create a "permutation" from your surrogate map. nulls.burt2020 accepts any keyword argument from the underlying null method generator. So all you would need to do is set this resample parameter to True when calling nulls.burt2020. Note, however, that these permutations would not "optimally" perserve spatial auto-correlation but it might still be good enough? Again, this should be tested first. Also, unfortunately, generating parametric nulls from volumetric brain maps using neuromaps is currently extremely inefficient, both timewise and spacewise. We've had a couple of ideas on how to fix this but currently, I would not recommand this option unless you really need to.

Hopefully this help!

Best, Vince

clarkenj commented 1 year ago

Hi Vince,

Thank you so much for your detailed response, that's super helpful. It sounds like it would be better to look at other approaches for now, but I may come back to one of your suggestions later!

Best, Natasha

frantisekvasa commented 1 year ago

Hi All,

It seems like everything has been covered quite comprehensively. A few extra comments:

I don't think the matrix spin has been used elsewhere - apart from Justine's use, which I was unaware of. What has been done before is the "Mantel permutation test", a random permutation of the rows and columns (without using the spin); e.g. by Aaron Alexander-Bloch, in https://www.jneurosci.org/content/33/7/2889. The matrix spin builds on this, by using spin indices to permute the rows and columns, instead of using a random permutation.

Re: "spinning within hemisphere" - in a way the spin is always "within hemisphere", but then there are two flavours of this. you can either i) rotate one hemisphere, and then mirror the rotation across to the other hemisphere - which might not result in identical permutation indices, as the parcel centroids aren't perfectly symmetric across hemispheres; or you can ii) rotate one hemisphere, obtain the permutation indices, and mirror these - which will result in identical permutation across hemispheres (by design). Note that the second option assumes that your parcellation has an equal number of broadly symmetric regions - otherwise option one should be used. Also, this is relevant to maps as well as matrices, but to my knowledge hasn't been applied before. In any case there isn't much of a difference between these.

The work I presented at OHBM compares the effect of the spin-Mantel, standard Mantel and naive approach (which assumes that edges are independent) when comparing pairs of matrices. It's not pre-printed yet, due to a heavy teaching workload, but I've finally returned to it and hope to wrap it up soon. To pre-empt the take-home / re-summarise from OHBM: the above permutations are likely to only lead to non-significant relationships if you either have weak effects (with r < 0.1-0.2), or very small parcellations (on the order of <50 ROIs). In other cases, even these more conservative null models will likely lead to significant p-values - although they will be lower than the naive independence-assuming p-values returned by Pearson's r or Spearman's rho.

I hope this helps.

Cheers, Frantisek

clarkenj commented 1 year ago

Hi Frantisek,

Thank you so much for your advice with this, that's very helpful. I look forward to reading your pre-print when it's out!

Best, Natasha