netneurolab / neuromaps

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

Errors when running nulls.burt2020 #71

Closed Melissa1909 closed 11 months ago

Melissa1909 commented 2 years ago

Description of issue

Dear neuromapers,

I am running neuromaps inside a docker container on a Linux machine but I run into two errors when working with nulls.burt2020...

The first one occurs for every subject; however the null model seems to be generated anyways: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpxg0d1k9k.mmap' Might this be related to my python setup?

The other one occurs for some subjects (~20/50) and seems to be related to the data. However, I could not figure out how exactly so far. ValueError: knn must be less than len(X) Exit error code: 1

See more details in the attached log-file. I call the function like this: nulls_ki=nulls.burt2020(alff_map, atlas='mni152', density='2mm', n_perm=100, seed=1234, n_proc=10)

Any suggestions highly appreciated! Cheers, Melissa

Code of Conduct

neuromaps_error_160922.log

VinceBaz commented 1 year ago

Hey @Melissa1909, sorry for the super late reply!

So for the first error: it seems like there is an issue when Python tries to delete the temporary files used to store the distance matrices used in nulls.burt2020. When Python tries to delete them, they are apparently already deleted, so that's why you get this FileNotFoundError. I am still unsure why this is happening, but it should not be a big problem: it does not prevent you from generating the nulls, and it should not affect the results you get.

For the second error: it occurs because your input data (your nifti image) has fewer than 1000 "valid" values (i.e. that are not nan). The burt2020 function assumes that the user wants to generate spatially auto-correlated brain maps of the whole brain. For that, it needs an input map that covers the whole brain. Could it be that your brain maps are thresholded in some way?

Once again, sorry for the late reply, and hopefully my answer is still relevant Best, Vincent

Melissa1909 commented 1 year ago

Dear VinceBaz, don't worry, thanks for the reply! For the second error: yes, I actually want to assess a correlation between two different brain masks restricted to a ROI. Could I circumvent this error by simply using the wholebrain map of one feature (e.g., wholebrain FC map, which I used as a masked map in the correlation)? Does this fit to my correlation restricted to one ROI then? Best, Melissa

VinceBaz commented 1 year ago

Hi Melissa, If you only have non-nan entries for a single ROI, I suggest you do not use the whole brain map to generate your surrogate maps. The reason being that the surrogates generated in that way might preserve the spatial autocorrelation of the whole brain, but not necessarily the spatial auto-correlation of the ROI you are interested in. So the p-value you get when you assess the correlation restricted to a single ROI might be biased.

Instead, I would suggest you do exactly as you had done, but use nulls.moran instead of nulls.burt2020. This null model also works for volumetric brain maps, but does not require you to have whole brain maps. Note however, that there was a bug in nulls.moran, which I fixed in a recent Pull Request . So to use nulls.moran, you will want to update your docker container to the most recent version, which was uploaded yesterday!

Let me know if you run into any issue! Best, Vincent

VinceBaz commented 11 months ago

Hi @Melissa1909, I closed this issue since you've opened a new one with additional questions. However, feel free to re-open this one if there's any issue!