MICA-MNI / ENIGMA

The ENIGMA Toolbox is an open-source repository for accessing 100+ ENIGMA statistical maps, visualizing cortical and subcortical surface data, and relating neuroimaging findings to micro- and macroscale brain organization. 🤠
https://enigma-toolbox.readthedocs.io
BSD 3-Clause "New" or "Revised" License
128 stars 31 forks source link

Spin Permutation Test #4

Closed pesojka closed 3 years ago

pesojka commented 3 years ago

Hello, I ran spin permutation tests with the example data set provided and got this error:

~/.local/lib/python3.8/site-packages/enigmatoolbox/permutation_testing/permutation_testing.py in perm_sphere_p(x, y, perm_id, corr_type, null_dist) 264 y_perm2 =[] 265 for ii in range(nroi): --> 266 x_perm2 = np.append(x_perm2, x[int(perm_id[ii, rr])]) 267 y_perm2 = np.append(y_perm2, y[int(perm_id[ii, rr])]) 268 x_perm = np.vstack((x_perm, x_perm2))

IndexError: index 69 is out of bounds for axis 0 with size 68

saratheriver commented 3 years ago

Hello!

Many thanks for letting us know - this issue should now be resolved (it was not excluding the corpus callosum when extracting the centroids hence the index error).

Please let us know if you have any more issues!

Sara. 🤠

pesojka commented 3 years ago

Hi Sara, many thanks for your quick reply. I reran the code with your fix and unfortunately I am still getting the same error:

~/.local/lib/python3.8/site-packages/enigmatoolbox/permutation_testing/permutation_testing.py in perm_sphere_p(x, y, perm_id, corr_type, null_dist) 264 y_perm2 =[] 265 for ii in range(nroi): --> 266 x_perm2 = np.append(x_perm2, x[int(perm_id[ii, rr])]) 267 y_perm2 = np.append(y_perm2, y[int(perm_id[ii, rr])]) 268 x_perm = np.vstack((x_perm, x_perm2))

IndexError: index 68 is out of bounds for axis 0 with size 68

Best, Petr

saratheriver commented 3 years ago

Hi Petr,

Can you please tell me which command produces the error and which dataset you load as I can't seem to be able to reproduce the error.

Sara.

pesojka commented 3 years ago

Hi Sara, please find bellow the script that produces the error:

from enigmatoolbox.datasets import load_summary_stats from enigmatoolbox.datasets import load_fc from enigmatoolbox.permutation_testing import spin_test

Load summary statistics for ENIGMA-Epilepsy

sum_stats = load_summary_stats('epilepsy')

Get case-control cortical thickness tables

CT = sum_stats['CortThick_case_vs_controls_ltle']

Extract Cohen's d values

CT_d = CT['d_icv']

Load functional connectivity data

fc_ctx, fc_ctxlabels, , _ = load_fc()

The following piece of code is copied from https://enigma-toolbox.readthedocs.io/en/latest/pages/07.epicenter/index.html

fc_ctx_epi = [] fc_ctx_epi_p = []

for seed in range(fc_ctx.shape[0]): seed_con = fc_ctx[:, seed] fc_ctx_epi = np.append(fc_ctx_epi, np.corrcoef(seed_con, CT_d)[0, 1]) fc_ctx_epi_p = np.append(fc_ctx_epi_p, spin_test(seed_con, CT_d, surface_name='fsa5', parcellation_name='aparc', type='pearson', n_rot=1000, null_dist=False))

saratheriver commented 3 years ago

Hi Petr,

I ran this in python 3.8 and did not get an error:

from enigmatoolbox.datasets import load_summary_stats
from enigmatoolbox.datasets import load_fc
from enigmatoolbox.permutation_testing import spin_test
import numpy as np

sum_stats = load_summary_stats('epilepsy')
CT = sum_stats['CortThick_case_vs_controls_ltle']
CT_d = CT['d_icv']

#Load functional connectivity data
fc_ctx, fc_ctx_labels, _, _ = load_fc()

#The following piece of code is copied from https://enigma-toolbox.readthedocs.io/en/latest/pages/07.epicenter/index.html
fc_ctx_epi = []
fc_ctx_epi_p = []

for seed in range(fc_ctx.shape[0]):
    seed_con = fc_ctx[:, seed]
    fc_ctx_epi = np.append(fc_ctx_epi, np.corrcoef(seed_con, CT_d)[0, 1])
    fc_ctx_epi_p = np.append(fc_ctx_epi_p,
    spin_test(seed_con, CT_d, surface_name='fsa5', parcellation_name='aparc', type='pearson', n_rot=1000, null_dist=False))

Perhaps make sure to cd into the ENIGMA folder, git pull, and python setup.py install

I've also just published a new v1.1.0 release with the updated functions (should you prefer to download the .zip file). Also make sure however to python setup.py install to update the python package.

pesojka commented 3 years ago

Dear Sara, it works now! Many thanks, I really appreciate! Best Wishes, Petr